hexok 1.0.1 → 2.0.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.
- package/README.md +4 -26
- package/dist/adapter.d.ts +18 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +21 -0
- package/dist/adapter.js.map +1 -0
- package/dist/catalog.d.ts +88 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +79 -0
- package/dist/catalog.js.map +1 -0
- package/dist/{core/coded-error.d.ts → coded-error.d.ts} +9 -4
- package/dist/coded-error.d.ts.map +1 -0
- package/dist/{core/coded-error.js → coded-error.js} +9 -4
- package/dist/coded-error.js.map +1 -0
- package/dist/cow-draft.d.ts.map +1 -0
- package/dist/cow-draft.js.map +1 -0
- package/dist/entity.d.ts +63 -0
- package/dist/entity.d.ts.map +1 -0
- package/dist/{domain/entity.js → entity.js} +52 -80
- package/dist/entity.js.map +1 -0
- package/dist/error-map.d.ts +22 -0
- package/dist/error-map.d.ts.map +1 -0
- package/dist/error-map.js +2 -0
- package/dist/error-map.js.map +1 -0
- package/dist/errors.d.ts +85 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +85 -0
- package/dist/errors.js.map +1 -0
- package/dist/event-handler.d.ts +31 -0
- package/dist/event-handler.d.ts.map +1 -0
- package/dist/event-handler.js +28 -0
- package/dist/event-handler.js.map +1 -0
- package/dist/event.d.ts +37 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +44 -0
- package/dist/event.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/mapper.d.ts +100 -0
- package/dist/mapper.d.ts.map +1 -0
- package/dist/mapper.js +167 -0
- package/dist/mapper.js.map +1 -0
- package/dist/port.d.ts +20 -0
- package/dist/port.d.ts.map +1 -0
- package/dist/port.js +25 -0
- package/dist/port.js.map +1 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js.map +1 -0
- package/dist/schema.d.ts +37 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +50 -0
- package/dist/schema.js.map +1 -0
- package/dist/{core/standard-schema.d.ts → standard-schema.d.ts} +1 -1
- package/dist/standard-schema.d.ts.map +1 -0
- package/dist/standard-schema.js.map +1 -0
- package/dist/use-case.d.ts +183 -0
- package/dist/use-case.d.ts.map +1 -0
- package/dist/use-case.js +221 -0
- package/dist/use-case.js.map +1 -0
- package/dist/{core/schema.d.ts → validate.d.ts} +1 -1
- package/dist/validate.d.ts.map +1 -0
- package/dist/{core/schema.js → validate.js} +1 -1
- package/dist/validate.js.map +1 -0
- package/package.json +5 -25
- package/dist/app/callable-use-case.d.ts +0 -34
- package/dist/app/callable-use-case.d.ts.map +0 -1
- package/dist/app/callable-use-case.js +0 -41
- package/dist/app/callable-use-case.js.map +0 -1
- package/dist/app/contract.d.ts +0 -46
- package/dist/app/contract.d.ts.map +0 -1
- package/dist/app/contract.js +0 -28
- package/dist/app/contract.js.map +0 -1
- package/dist/app/error-factory.d.ts +0 -9
- package/dist/app/error-factory.d.ts.map +0 -1
- package/dist/app/error-factory.js +0 -30
- package/dist/app/error-factory.js.map +0 -1
- package/dist/app/event-channel.d.ts +0 -133
- package/dist/app/event-channel.d.ts.map +0 -1
- package/dist/app/event-channel.js +0 -49
- package/dist/app/event-channel.js.map +0 -1
- package/dist/app/event-use-case.d.ts +0 -47
- package/dist/app/event-use-case.d.ts.map +0 -1
- package/dist/app/event-use-case.js +0 -54
- package/dist/app/event-use-case.js.map +0 -1
- package/dist/app/execute-ctx.d.ts +0 -92
- package/dist/app/execute-ctx.d.ts.map +0 -1
- package/dist/app/execute-ctx.js +0 -2
- package/dist/app/execute-ctx.js.map +0 -1
- package/dist/app/external-use-case.d.ts +0 -25
- package/dist/app/external-use-case.d.ts.map +0 -1
- package/dist/app/external-use-case.js +0 -25
- package/dist/app/external-use-case.js.map +0 -1
- package/dist/app/index.d.ts +0 -9
- package/dist/app/index.d.ts.map +0 -1
- package/dist/app/index.js +0 -8
- package/dist/app/index.js.map +0 -1
- package/dist/app/internal-use-case.d.ts +0 -26
- package/dist/app/internal-use-case.d.ts.map +0 -1
- package/dist/app/internal-use-case.js +0 -26
- package/dist/app/internal-use-case.js.map +0 -1
- package/dist/app/nest.d.ts +0 -9
- package/dist/app/nest.d.ts.map +0 -1
- package/dist/app/nest.js +0 -28
- package/dist/app/nest.js.map +0 -1
- package/dist/app/types.d.ts +0 -153
- package/dist/app/types.d.ts.map +0 -1
- package/dist/app/types.js +0 -17
- package/dist/app/types.js.map +0 -1
- package/dist/core/coded-error.d.ts.map +0 -1
- package/dist/core/coded-error.js.map +0 -1
- package/dist/core/error-map.d.ts +0 -21
- package/dist/core/error-map.d.ts.map +0 -1
- package/dist/core/error-map.js +0 -5
- package/dist/core/error-map.js.map +0 -1
- package/dist/core/index.d.ts +0 -6
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -5
- package/dist/core/index.js.map +0 -1
- package/dist/core/result.d.ts.map +0 -1
- package/dist/core/result.js.map +0 -1
- package/dist/core/schema.d.ts.map +0 -1
- package/dist/core/schema.js.map +0 -1
- package/dist/core/standard-schema.d.ts.map +0 -1
- package/dist/core/standard-schema.js.map +0 -1
- package/dist/domain/capabilities.d.ts +0 -42
- package/dist/domain/capabilities.d.ts.map +0 -1
- package/dist/domain/capabilities.js +0 -2
- package/dist/domain/capabilities.js.map +0 -1
- package/dist/domain/catalog.d.ts +0 -46
- package/dist/domain/catalog.d.ts.map +0 -1
- package/dist/domain/catalog.js +0 -114
- package/dist/domain/catalog.js.map +0 -1
- package/dist/domain/channel.d.ts +0 -36
- package/dist/domain/channel.d.ts.map +0 -1
- package/dist/domain/channel.js +0 -2
- package/dist/domain/channel.js.map +0 -1
- package/dist/domain/cow-draft.d.ts.map +0 -1
- package/dist/domain/cow-draft.js.map +0 -1
- package/dist/domain/entity.d.ts +0 -120
- package/dist/domain/entity.d.ts.map +0 -1
- package/dist/domain/entity.js.map +0 -1
- package/dist/domain/envelope.d.ts +0 -59
- package/dist/domain/envelope.d.ts.map +0 -1
- package/dist/domain/envelope.js +0 -2
- package/dist/domain/envelope.js.map +0 -1
- package/dist/domain/event.d.ts +0 -44
- package/dist/domain/event.d.ts.map +0 -1
- package/dist/domain/event.js +0 -21
- package/dist/domain/event.js.map +0 -1
- package/dist/domain/index.d.ts +0 -8
- package/dist/domain/index.d.ts.map +0 -1
- package/dist/domain/index.js +0 -5
- package/dist/domain/index.js.map +0 -1
- package/dist/domain/port.d.ts +0 -45
- package/dist/domain/port.d.ts.map +0 -1
- package/dist/domain/port.js +0 -41
- package/dist/domain/port.js.map +0 -1
- package/dist/infra/adapter.d.ts +0 -22
- package/dist/infra/adapter.d.ts.map +0 -1
- package/dist/infra/adapter.js +0 -18
- package/dist/infra/adapter.js.map +0 -1
- package/dist/infra/index.d.ts +0 -3
- package/dist/infra/index.d.ts.map +0 -1
- package/dist/infra/index.js +0 -3
- package/dist/infra/index.js.map +0 -1
- package/dist/infra/mapper.d.ts +0 -48
- package/dist/infra/mapper.d.ts.map +0 -1
- package/dist/infra/mapper.js +0 -77
- package/dist/infra/mapper.js.map +0 -1
- package/dist/runtime/app.d.ts +0 -100
- package/dist/runtime/app.d.ts.map +0 -1
- package/dist/runtime/app.js +0 -292
- package/dist/runtime/app.js.map +0 -1
- package/dist/runtime/channel.d.ts +0 -34
- package/dist/runtime/channel.d.ts.map +0 -1
- package/dist/runtime/channel.js +0 -110
- package/dist/runtime/channel.js.map +0 -1
- package/dist/runtime/client.d.ts +0 -21
- package/dist/runtime/client.d.ts.map +0 -1
- package/dist/runtime/client.js +0 -2
- package/dist/runtime/client.js.map +0 -1
- package/dist/runtime/completeness.d.ts +0 -89
- package/dist/runtime/completeness.d.ts.map +0 -1
- package/dist/runtime/completeness.js +0 -2
- package/dist/runtime/completeness.js.map +0 -1
- package/dist/runtime/envelope.d.ts +0 -7
- package/dist/runtime/envelope.d.ts.map +0 -1
- package/dist/runtime/envelope.js +0 -69
- package/dist/runtime/envelope.js.map +0 -1
- package/dist/runtime/events.d.ts +0 -6
- package/dist/runtime/events.d.ts.map +0 -1
- package/dist/runtime/events.js +0 -48
- package/dist/runtime/events.js.map +0 -1
- package/dist/runtime/http-status.d.ts +0 -3
- package/dist/runtime/http-status.d.ts.map +0 -1
- package/dist/runtime/http-status.js +0 -11
- package/dist/runtime/http-status.js.map +0 -1
- package/dist/runtime/http.d.ts +0 -4
- package/dist/runtime/http.d.ts.map +0 -1
- package/dist/runtime/http.js +0 -58
- package/dist/runtime/http.js.map +0 -1
- package/dist/runtime/index.d.ts +0 -10
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js +0 -6
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/interceptor.d.ts +0 -61
- package/dist/runtime/interceptor.d.ts.map +0 -1
- package/dist/runtime/interceptor.js +0 -7
- package/dist/runtime/interceptor.js.map +0 -1
- package/dist/runtime/invoke.d.ts +0 -34
- package/dist/runtime/invoke.d.ts.map +0 -1
- package/dist/runtime/invoke.js +0 -235
- package/dist/runtime/invoke.js.map +0 -1
- package/dist/runtime/middleware.d.ts +0 -20
- package/dist/runtime/middleware.d.ts.map +0 -1
- package/dist/runtime/middleware.js +0 -2
- package/dist/runtime/middleware.js.map +0 -1
- package/dist/runtime/rpc.d.ts +0 -24
- package/dist/runtime/rpc.d.ts.map +0 -1
- package/dist/runtime/rpc.js +0 -16
- package/dist/runtime/rpc.js.map +0 -1
- package/dist/testing/app-test.d.ts +0 -77
- package/dist/testing/app-test.d.ts.map +0 -1
- package/dist/testing/app-test.js +0 -109
- package/dist/testing/app-test.js.map +0 -1
- package/dist/testing/in-memory-bus.d.ts +0 -19
- package/dist/testing/in-memory-bus.d.ts.map +0 -1
- package/dist/testing/in-memory-bus.js +0 -31
- package/dist/testing/in-memory-bus.js.map +0 -1
- package/dist/testing/in-memory-channel.d.ts +0 -32
- package/dist/testing/in-memory-channel.d.ts.map +0 -1
- package/dist/testing/in-memory-channel.js +0 -65
- package/dist/testing/in-memory-channel.js.map +0 -1
- package/dist/testing/in-memory-queue.d.ts +0 -24
- package/dist/testing/in-memory-queue.d.ts.map +0 -1
- package/dist/testing/in-memory-queue.js +0 -66
- package/dist/testing/in-memory-queue.js.map +0 -1
- package/dist/testing/in-memory-repository.d.ts +0 -44
- package/dist/testing/in-memory-repository.d.ts.map +0 -1
- package/dist/testing/in-memory-repository.js +0 -60
- package/dist/testing/in-memory-repository.js.map +0 -1
- package/dist/testing/index.d.ts +0 -6
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js +0 -6
- package/dist/testing/index.js.map +0 -1
- /package/dist/{domain/cow-draft.d.ts → cow-draft.d.ts} +0 -0
- /package/dist/{domain/cow-draft.js → cow-draft.js} +0 -0
- /package/dist/{core/result.d.ts → result.d.ts} +0 -0
- /package/dist/{core/result.js → result.js} +0 -0
- /package/dist/{core/standard-schema.js → standard-schema.js} +0 -0
package/dist/domain/entity.d.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { type ErrorMap, type Infer, type StandardSchemaV1 } from '../core/index.js';
|
|
2
|
-
/** Recursively readonly view of entity props. `Date` values stay `Date`. */
|
|
3
|
-
export type DeepReadonly<T> = T extends Date ? T : T extends readonly (infer U)[] ? ReadonlyArray<DeepReadonly<U>> : T extends object ? {
|
|
4
|
-
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
5
|
-
} : T;
|
|
6
|
-
/**
|
|
7
|
-
* Aggregates mutate **this** via `set` and return `this`.
|
|
8
|
-
* They never I/O, never publish, never hold ports.
|
|
9
|
-
*
|
|
10
|
-
* Validation, invariants, and declared refusals **throw**.
|
|
11
|
-
* `create` / `parse` run the schema. `restore` does not — it rehydrates
|
|
12
|
-
* mapper output as-is. `set` re-runs the schema after a write.
|
|
13
|
-
* `validate()` is the optional fail-fast for a restored instance.
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* class Incident extends Entity<IncidentProps> {
|
|
17
|
-
* static readonly key = 'Incident'
|
|
18
|
-
* static readonly schema = z.object({ id: z.string(), status: z.enum(['open', 'closed']) })
|
|
19
|
-
* static readonly errors = { ALREADY_CLOSED: { message: 'Incident already closed' } } as const
|
|
20
|
-
* close(now: Date): this {
|
|
21
|
-
* if (this.props.status === 'closed') Incident.error('ALREADY_CLOSED')
|
|
22
|
-
* return this.set((draft) => {
|
|
23
|
-
* draft.status = 'closed'
|
|
24
|
-
* draft.closedAt = now
|
|
25
|
-
* })
|
|
26
|
-
* }
|
|
27
|
-
* }
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export declare abstract class Entity<P extends object> {
|
|
31
|
-
#private;
|
|
32
|
-
/** Entity name used in validation and undeclared-error messages. Declare on each subclass. */
|
|
33
|
-
static readonly key: string;
|
|
34
|
-
/** Standard Schema for `create` / `parse` / `set` / `validate()`. Declare on each subclass. */
|
|
35
|
-
static readonly schema: StandardSchemaV1;
|
|
36
|
-
/** Declared refusal codes. Keys are the `error()` union. Declare on each subclass. */
|
|
37
|
-
static readonly errors: ErrorMap;
|
|
38
|
-
protected _props: P;
|
|
39
|
-
/** Live props. Read-only; write through `set`. */
|
|
40
|
-
get props(): DeepReadonly<P>;
|
|
41
|
-
/** True after `create` until `commit`. `restore` / `parse` start false. */
|
|
42
|
-
get isNew(): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* True after `create`, `parse`, a writing `set`, or `validate()`.
|
|
45
|
-
* `restore` starts false — the schema has not run.
|
|
46
|
-
*/
|
|
47
|
-
get isValidated(): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Pre-mutation props after the first `set` on a restored entity.
|
|
50
|
-
* `undefined` when same-ref (clean) or `create`d and never `commit`ted.
|
|
51
|
-
*/
|
|
52
|
-
get original(): DeepReadonly<P> | undefined;
|
|
53
|
-
protected constructor(props: P);
|
|
54
|
-
/** Copy-on-write mutate. Edit `draft` and return `this`. Re-validates the schema after a write. */
|
|
55
|
-
set(producer: (draft: P) => void): this;
|
|
56
|
-
/**
|
|
57
|
-
* Run the schema if it has not already passed on this instance.
|
|
58
|
-
* No-op when `isValidated`. Does not rewrite props (no strip/defaults).
|
|
59
|
-
* Throws `CodedError` `VALIDATION` if the schema rejects current props.
|
|
60
|
-
*/
|
|
61
|
-
validate(): this;
|
|
62
|
-
/** Shallow keys that differ from `original`. `{ deep: true }` returns dotted leaf paths. */
|
|
63
|
-
getChangedKeys(): Array<ChangedKey<P>>;
|
|
64
|
-
getChangedKeys(opts: {
|
|
65
|
-
deep: true;
|
|
66
|
-
}): string[];
|
|
67
|
-
getChangedKeys(opts?: {
|
|
68
|
-
deep?: boolean;
|
|
69
|
-
}): string[];
|
|
70
|
-
/** True when `create`d and not yet `commit`ted, or any shallow key changed. */
|
|
71
|
-
isDirty(): boolean;
|
|
72
|
-
/** Accept current props as original; `isNew` becomes false. Adapters after persist; not use-cases. */
|
|
73
|
-
commit(): this;
|
|
74
|
-
/** Deep frozen snapshot for persistence and use-case output. Reused until the next `set`. */
|
|
75
|
-
toProps(): DeepReadonly<P>;
|
|
76
|
-
/** JSON serialization is the plain props snapshot. */
|
|
77
|
-
toJSON(): DeepReadonly<P>;
|
|
78
|
-
/**
|
|
79
|
-
* Throw a declared entity error. Codes are the keys of the subclass
|
|
80
|
-
* `static errors` when called as `Incident.error('ALREADY_CLOSED')`.
|
|
81
|
-
* An undeclared code is a type error on that call, and a programming
|
|
82
|
-
* error at runtime.
|
|
83
|
-
*/
|
|
84
|
-
static error<E extends object, K extends keyof E & string>(this: {
|
|
85
|
-
errors: E;
|
|
86
|
-
key: string;
|
|
87
|
-
}, code: K, data?: unknown): never;
|
|
88
|
-
/**
|
|
89
|
-
* Validate typed props and construct a new instance (`isNew: true`).
|
|
90
|
-
* Throws `CodedError` `VALIDATION` if the schema rejects the props.
|
|
91
|
-
*/
|
|
92
|
-
static create<T extends EntityConstructor>(this: T, props: SchemaOutput<T> | DeepReadonly<SchemaOutput<T>>): T['prototype'];
|
|
93
|
-
/**
|
|
94
|
-
* Reconstruct an existing instance (`isNew: false`) without running the
|
|
95
|
-
* schema. Props are stored as given (no strip/defaults). `isValidated`
|
|
96
|
-
* starts false until `set` writes or `validate()` runs.
|
|
97
|
-
*/
|
|
98
|
-
static restore<T extends EntityConstructor>(this: T, props: SchemaOutput<T> | DeepReadonly<SchemaOutput<T>>): T['prototype'];
|
|
99
|
-
/**
|
|
100
|
-
* Trust boundary for untyped input. Validates like `create`;
|
|
101
|
-
* tracking matches `restore` (`isNew: false`).
|
|
102
|
-
* Throws `CodedError` `VALIDATION` if the schema rejects the value.
|
|
103
|
-
*/
|
|
104
|
-
static parse<T extends EntityConstructor>(this: T, value: unknown): T['prototype'];
|
|
105
|
-
}
|
|
106
|
-
/** Subclass constructor shape for `create` / `restore` / `parse`. */
|
|
107
|
-
export type EntityConstructor = {
|
|
108
|
-
/** Entity name used in validation and error messages. */
|
|
109
|
-
readonly key: string;
|
|
110
|
-
/** Standard Schema for `create` / `parse` / `set` / `validate()`. Declare on each subclass. */
|
|
111
|
-
readonly schema: StandardSchemaV1;
|
|
112
|
-
/** Declared refusal codes. Keys are the `error()` union. Declare on each subclass. */
|
|
113
|
-
readonly errors: ErrorMap;
|
|
114
|
-
readonly prototype: Entity<any>;
|
|
115
|
-
};
|
|
116
|
-
type SchemaOutput<T extends EntityConstructor> = Infer<T['schema']>;
|
|
117
|
-
/** `keyof object` is `never`; widen so `Entity<P>` stays assignable to `Entity<object>`. */
|
|
118
|
-
type ChangedKey<P extends object> = keyof P extends never ? string : keyof P & string;
|
|
119
|
-
export {};
|
|
120
|
-
//# sourceMappingURL=entity.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/domain/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,gBAAgB,EAGtB,MAAM,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IACtE,CAAC;IACD,MAAM,IAAI,UAAU,CAAC;QACnB,IAAI;QACJ,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,IAAI;QAC5B,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACxC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/** `'bus'` is fan-out; `'queue'` is competing consumers with ack/nack. */
|
|
2
|
-
export type CatalogKind = 'bus' | 'queue';
|
|
3
|
-
/**
|
|
4
|
-
* Runtime value on the wire. `kind` is copied from the catalog.
|
|
5
|
-
*/
|
|
6
|
-
export type Envelope<K extends string = string, P = unknown, Cat extends string = string, Kind extends CatalogKind = CatalogKind, Ctx = unknown> = {
|
|
7
|
-
/** Event class key, e.g. `'incident.closed'`. */
|
|
8
|
-
key: K;
|
|
9
|
-
/** Event payload. */
|
|
10
|
-
payload: P;
|
|
11
|
-
/** Catalog name this event was published through. */
|
|
12
|
-
catalog: Cat;
|
|
13
|
-
/** Copied from the catalog: `'bus'` or `'queue'`. */
|
|
14
|
-
kind: Kind;
|
|
15
|
-
/** When the event was wrapped for the wire. */
|
|
16
|
-
occurredAt: Date;
|
|
17
|
-
/** Catalog ctx when `.ctx()` was declared; omitted otherwise. */
|
|
18
|
-
ctx?: Ctx;
|
|
19
|
-
/** Copied from request ctx when that field is a string. */
|
|
20
|
-
correlationId?: string;
|
|
21
|
-
/** Copied from request ctx when that field is a string. */
|
|
22
|
-
causationId?: string;
|
|
23
|
-
/** Adapter/interceptor scratch. Hexok writes `{}`; domain code should not. */
|
|
24
|
-
meta: Record<string, unknown>;
|
|
25
|
-
};
|
|
26
|
-
/** Fire-and-forget pub/sub. No ack, no consumer group, no persistence in the contract. */
|
|
27
|
-
export interface BusAdapter {
|
|
28
|
-
/** Discriminant. Must be `'bus'`. */
|
|
29
|
-
kind: 'bus';
|
|
30
|
-
/** Put one envelope on the bus. */
|
|
31
|
-
publish(envelope: Envelope): Promise<void>;
|
|
32
|
-
/** Register a handler for one event key. */
|
|
33
|
-
subscribe(key: string, handler: (envelope: Envelope) => Promise<void>): void;
|
|
34
|
-
/** Tear down the adapter. Optional. */
|
|
35
|
-
stop?(): Promise<void>;
|
|
36
|
-
}
|
|
37
|
-
/** Ack/nack and delivery attempt for one queue message. */
|
|
38
|
-
export interface QueueConsumeCtx {
|
|
39
|
-
/** 1-based delivery attempt. */
|
|
40
|
-
attempt: number;
|
|
41
|
-
/** Mark this delivery succeeded. */
|
|
42
|
-
ack: () => Promise<void>;
|
|
43
|
-
/** Reject this delivery so it can retry. */
|
|
44
|
-
nack: () => Promise<void>;
|
|
45
|
-
}
|
|
46
|
-
/** Work queue. One consumer in a group; ack/nack; `attempt`. */
|
|
47
|
-
export interface QueueAdapter {
|
|
48
|
-
/** Discriminant. Must be `'queue'`. */
|
|
49
|
-
kind: 'queue';
|
|
50
|
-
/** Put one envelope on the queue. */
|
|
51
|
-
publish(envelope: Envelope): Promise<void>;
|
|
52
|
-
/** Register a competing consumer for one event key in `group`. */
|
|
53
|
-
consume(key: string, group: string, handler: (envelope: Envelope, ctx: QueueConsumeCtx) => Promise<void>): void;
|
|
54
|
-
/** Tear down the adapter. Optional. */
|
|
55
|
-
stop?(): Promise<void>;
|
|
56
|
-
}
|
|
57
|
-
/** Bound event transport: a bus or a queue. */
|
|
58
|
-
export type EventAdapter = BusAdapter | QueueAdapter;
|
|
59
|
-
//# sourceMappingURL=envelope.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/domain/envelope.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,OAAO,CAAC;AAE1C;;GAEG;AACH,MAAM,MAAM,QAAQ,CAClB,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,GAAG,OAAO,EACX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C;IACvC,IAAI,EAAE,OAAO,CAAC;IACd,qCAAqC;IACrC,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,kEAAkE;IAClE,OAAO,CACL,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,GACnE,IAAI,CAAC;IACR,uCAAuC;IACvC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,+CAA+C;AAC/C,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,YAAY,CAAC"}
|
package/dist/domain/envelope.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../src/domain/envelope.ts"],"names":[],"mappings":""}
|
package/dist/domain/event.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { Infer, StandardSchemaV1 } from '../core/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Domain events are classes. Construction types the payload;
|
|
4
|
-
* validation happens at the use-case edge, not in the constructor.
|
|
5
|
-
*
|
|
6
|
-
* ```ts
|
|
7
|
-
* class IncidentClosed extends DomainEvent {
|
|
8
|
-
* static readonly key = 'incident.closed'
|
|
9
|
-
* static readonly schema = z.object({ id: z.string(), closedAt: z.date() })
|
|
10
|
-
* constructor(public readonly payload: Infer<typeof IncidentClosed.schema>) {
|
|
11
|
-
* super()
|
|
12
|
-
* }
|
|
13
|
-
* }
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare abstract class DomainEvent<P = unknown> {
|
|
17
|
-
/** Dotted event name, e.g. `'incident.closed'`. Declare on each subclass. */
|
|
18
|
-
static readonly key: string;
|
|
19
|
-
/** Standard Schema for the payload, applied at the use-case edge. */
|
|
20
|
-
static readonly schema: StandardSchemaV1;
|
|
21
|
-
/** Event body. Typed by the subclass constructor; not validated here. */
|
|
22
|
-
abstract readonly payload: P;
|
|
23
|
-
}
|
|
24
|
-
/** Event subclass constructor: `key`, `schema`, and `new (payload)`. */
|
|
25
|
-
export type EventClass<P = never> = {
|
|
26
|
-
/** Dotted event name, e.g. `'incident.closed'`. */
|
|
27
|
-
readonly key: string;
|
|
28
|
-
/** Standard Schema for the payload, applied at the use-case edge. */
|
|
29
|
-
readonly schema: StandardSchemaV1;
|
|
30
|
-
new (payload: P, ...args: never[]): DomainEvent<unknown>;
|
|
31
|
-
};
|
|
32
|
-
/** Payload type inferred from an event class's `schema`. */
|
|
33
|
-
export type EventPayload<E extends EventClass> = Infer<E['schema']>;
|
|
34
|
-
type EventKeyOf<E> = E extends {
|
|
35
|
-
readonly key: infer K extends string;
|
|
36
|
-
} ? K : string;
|
|
37
|
-
/** `catalog.event()` argument when the catalog declared `.ctx<T>()`. */
|
|
38
|
-
export type EventWithCtx<E extends EventClass, Ctx> = [
|
|
39
|
-
InstanceType<E>
|
|
40
|
-
] extends [{
|
|
41
|
-
ctx: Ctx;
|
|
42
|
-
}] ? E : `hexok: event "${EventKeyOf<E>}" is missing ctx for this catalog`;
|
|
43
|
-
export {};
|
|
44
|
-
//# sourceMappingURL=event.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/domain/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEhE;;;;;;;;;;;;;GAaG;AACH,8BAAsB,WAAW,CAAC,CAAC,GAAG,OAAO;IAC3C,6EAA6E;IAC7E,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IACzC,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;CAC9B;AAED,wEAAwE;AACxE,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,KAAK,IAAI;IAClC,mDAAmD;IACnD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,KAAK,OAAO,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;CAC1D,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,UAAU,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEpE,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;CAAE,GACnE,CAAC,GACD,MAAM,CAAC;AAEX,wEAAwE;AACxE,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,UAAU,EAAE,GAAG,IAAI;IACpD,YAAY,CAAC,CAAC,CAAC;CAChB,SAAS,CAAC;IAAE,GAAG,EAAE,GAAG,CAAA;CAAE,CAAC,GACpB,CAAC,GACD,iBAAiB,UAAU,CAAC,CAAC,CAAC,mCAAmC,CAAC"}
|
package/dist/domain/event.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Domain events are classes. Construction types the payload;
|
|
3
|
-
* validation happens at the use-case edge, not in the constructor.
|
|
4
|
-
*
|
|
5
|
-
* ```ts
|
|
6
|
-
* class IncidentClosed extends DomainEvent {
|
|
7
|
-
* static readonly key = 'incident.closed'
|
|
8
|
-
* static readonly schema = z.object({ id: z.string(), closedAt: z.date() })
|
|
9
|
-
* constructor(public readonly payload: Infer<typeof IncidentClosed.schema>) {
|
|
10
|
-
* super()
|
|
11
|
-
* }
|
|
12
|
-
* }
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export class DomainEvent {
|
|
16
|
-
/** Dotted event name, e.g. `'incident.closed'`. Declare on each subclass. */
|
|
17
|
-
static key;
|
|
18
|
-
/** Standard Schema for the payload, applied at the use-case edge. */
|
|
19
|
-
static schema;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=event.js.map
|
package/dist/domain/event.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/domain/event.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAgB,WAAW;IAC/B,6EAA6E;IAC7E,MAAM,CAAU,GAAG,CAAS;IAC5B,qEAAqE;IACrE,MAAM,CAAU,MAAM,CAAmB;CAG1C"}
|
package/dist/domain/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type { CrudRepository, RequestScoped, Transactional, UnitOfWork, } from './capabilities.js';
|
|
2
|
-
export { type AnyEventCatalog, type CatalogEvents, EventCatalog, } from './catalog.js';
|
|
3
|
-
export type { ChannelAdapter, ChannelConnection, } from './channel.js';
|
|
4
|
-
export { type DeepReadonly, Entity, type EntityConstructor, } from './entity.js';
|
|
5
|
-
export type { BusAdapter, CatalogKind, Envelope, EventAdapter, QueueAdapter, QueueConsumeCtx, } from './envelope.js';
|
|
6
|
-
export { DomainEvent, type EventClass, type EventPayload, type EventWithCtx, } from './event.js';
|
|
7
|
-
export { Port, type PortCapabilities, PortToken, type PortType, } from './port.js';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/domain/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,aAAa,EACb,aAAa,EACb,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,cAAc,EACd,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,YAAY,EACjB,MAAM,EACN,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,IAAI,EACJ,KAAK,gBAAgB,EACrB,SAAS,EACT,KAAK,QAAQ,GACd,MAAM,WAAW,CAAC"}
|
package/dist/domain/index.js
DELETED
package/dist/domain/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/domain/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,YAAY,GACb,MAAM,cAAc,CAAC;AAKtB,OAAO,EAEL,MAAM,GAEP,MAAM,aAAa,CAAC;AASrB,OAAO,EACL,WAAW,GAIZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,IAAI,EAEJ,SAAS,GAEV,MAAM,WAAW,CAAC"}
|
package/dist/domain/port.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
declare const portType: unique symbol;
|
|
2
|
-
/** Runtime flags checked by `App.provide`. Type the port with `Transactional` / `RequestScoped` as well. */
|
|
3
|
-
export type PortCapabilities = {
|
|
4
|
-
transactional?: boolean;
|
|
5
|
-
requestScoped?: boolean;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* A port is a TypeScript interface plus a token used at compose time.
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* export interface IncidentRepository {
|
|
12
|
-
* get(id: string): Promise<Incident | null>
|
|
13
|
-
* save(incident: Incident): Promise<void>
|
|
14
|
-
* }
|
|
15
|
-
* export const IncidentRepository = Port.token<IncidentRepository>(
|
|
16
|
-
* 'IncidentRepository',
|
|
17
|
-
* )
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* `.build()` names a missing port by its use-case alias
|
|
21
|
-
* (`ports: { incidents: IncidentRepository }` → `"incidents"`).
|
|
22
|
-
* Pass `{ transactional: true }` / `{ requestScoped: true }` so `provide`
|
|
23
|
-
* throws if the impl is missing `bindTo` / `fork`.
|
|
24
|
-
*/
|
|
25
|
-
export declare class PortToken<out I> {
|
|
26
|
-
/** Name used in runtime provide/completeness errors. */
|
|
27
|
-
readonly key: string;
|
|
28
|
-
/** Runtime capability flags. `provide()` checks `bindTo` / `fork` when set. */
|
|
29
|
-
readonly capabilities: {
|
|
30
|
-
readonly transactional: boolean;
|
|
31
|
-
readonly requestScoped: boolean;
|
|
32
|
-
};
|
|
33
|
-
readonly [portType]: I;
|
|
34
|
-
private constructor();
|
|
35
|
-
/** Create a token for interface `I`. Prefer `Port.token<I>('Name')` at call sites. */
|
|
36
|
-
static token<I>(key: string, capabilities?: PortCapabilities): PortToken<I>;
|
|
37
|
-
}
|
|
38
|
-
/** `Port.token<I>('Name')` — the usual way to create a `PortToken`. */
|
|
39
|
-
export declare const Port: {
|
|
40
|
-
token: typeof PortToken.token;
|
|
41
|
-
};
|
|
42
|
-
/** Interface stored on a `PortToken`. */
|
|
43
|
-
export type PortType<T> = T extends PortToken<infer I> ? I : never;
|
|
44
|
-
export {};
|
|
45
|
-
//# sourceMappingURL=port.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../../src/domain/port.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,EAAE,OAAO,MAAM,CAAC;AAEtC,4GAA4G;AAC5G,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,SAAS,CAAC,GAAG,CAAC,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,EAAE;QACrB,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;QAChC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;KACjC,CAAC;IACF,SAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE/B,OAAO;IASP,sFAAsF;IACtF,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAAC,CAAC;CAG5E;AAED,uEAAuE;AACvE,eAAO,MAAM,IAAI,EAAE;IAAE,KAAK,EAAE,OAAO,SAAS,CAAC,KAAK,CAAA;CAEjD,CAAC;AAEF,yCAAyC;AACzC,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
|
package/dist/domain/port.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A port is a TypeScript interface plus a token used at compose time.
|
|
3
|
-
*
|
|
4
|
-
* ```ts
|
|
5
|
-
* export interface IncidentRepository {
|
|
6
|
-
* get(id: string): Promise<Incident | null>
|
|
7
|
-
* save(incident: Incident): Promise<void>
|
|
8
|
-
* }
|
|
9
|
-
* export const IncidentRepository = Port.token<IncidentRepository>(
|
|
10
|
-
* 'IncidentRepository',
|
|
11
|
-
* )
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* `.build()` names a missing port by its use-case alias
|
|
15
|
-
* (`ports: { incidents: IncidentRepository }` → `"incidents"`).
|
|
16
|
-
* Pass `{ transactional: true }` / `{ requestScoped: true }` so `provide`
|
|
17
|
-
* throws if the impl is missing `bindTo` / `fork`.
|
|
18
|
-
*/
|
|
19
|
-
export class PortToken {
|
|
20
|
-
/** Name used in runtime provide/completeness errors. */
|
|
21
|
-
key;
|
|
22
|
-
/** Runtime capability flags. `provide()` checks `bindTo` / `fork` when set. */
|
|
23
|
-
capabilities;
|
|
24
|
-
constructor(key, capabilities) {
|
|
25
|
-
this.key = key;
|
|
26
|
-
this.capabilities = Object.freeze({
|
|
27
|
-
transactional: capabilities?.transactional === true,
|
|
28
|
-
requestScoped: capabilities?.requestScoped === true,
|
|
29
|
-
});
|
|
30
|
-
Object.freeze(this);
|
|
31
|
-
}
|
|
32
|
-
/** Create a token for interface `I`. Prefer `Port.token<I>('Name')` at call sites. */
|
|
33
|
-
static token(key, capabilities) {
|
|
34
|
-
return new PortToken(key, capabilities);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/** `Port.token<I>('Name')` — the usual way to create a `PortToken`. */
|
|
38
|
-
export const Port = {
|
|
39
|
-
token: PortToken.token,
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=port.js.map
|
package/dist/domain/port.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"port.js","sourceRoot":"","sources":["../../src/domain/port.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,SAAS;IACpB,wDAAwD;IAC/C,GAAG,CAAS;IACrB,+EAA+E;IACtE,YAAY,CAGnB;IAGF,YAAoB,GAAW,EAAE,YAA+B;QAC9D,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;YAChC,aAAa,EAAE,YAAY,EAAE,aAAa,KAAK,IAAI;YACnD,aAAa,EAAE,YAAY,EAAE,aAAa,KAAK,IAAI;SACpD,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAED,sFAAsF;IACtF,MAAM,CAAC,KAAK,CAAI,GAAW,EAAE,YAA+B;QAC1D,OAAO,IAAI,SAAS,CAAI,GAAG,EAAE,YAAY,CAAC,CAAC;IAC7C,CAAC;CACF;AAED,uEAAuE;AACvE,MAAM,CAAC,MAAM,IAAI,GAAsC;IACrD,KAAK,EAAE,SAAS,CAAC,KAAK;CACvB,CAAC"}
|
package/dist/infra/adapter.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { PortToken } from '../domain/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Typed factory holder. Pass the **impl** to `provide`, or use `App.adapt(factory, ...deps)`.
|
|
4
|
-
*
|
|
5
|
-
* ```ts
|
|
6
|
-
* const factory = Adapter.of(IncidentRepository, (db: Pool) => new PgIncidentRepo(db))
|
|
7
|
-
* const app = App.from(useCases).adapt(factory, pool)
|
|
8
|
-
* ```
|
|
9
|
-
*/
|
|
10
|
-
export declare const Adapter: {
|
|
11
|
-
/**
|
|
12
|
-
* Pair a port token with a factory. Call `create(...deps)` and pass the impl
|
|
13
|
-
* to `App.provide` — not this holder.
|
|
14
|
-
*/
|
|
15
|
-
of<I, Deps extends unknown[]>(token: PortToken<I>, create: (...deps: Deps) => I): {
|
|
16
|
-
/** Port token for this adapter. Use with `App.provide(token, impl)`. */
|
|
17
|
-
token: PortToken<I>;
|
|
18
|
-
/** Build the adapter impl. Composition receives that value, not the holder. */
|
|
19
|
-
create: (...deps: Deps) => I;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/infra/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO;IAClB;;;OAGG;OACA,CAAC,EAAE,IAAI,SAAS,OAAO,EAAE,SACnB,SAAS,CAAC,CAAC,CAAC,UACX,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,GAC3B;QACD,wEAAwE;QACxE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;QACpB,+EAA+E;QAC/E,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,CAAC;KAC9B;CAGF,CAAC"}
|
package/dist/infra/adapter.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typed factory holder. Pass the **impl** to `provide`, or use `App.adapt(factory, ...deps)`.
|
|
3
|
-
*
|
|
4
|
-
* ```ts
|
|
5
|
-
* const factory = Adapter.of(IncidentRepository, (db: Pool) => new PgIncidentRepo(db))
|
|
6
|
-
* const app = App.from(useCases).adapt(factory, pool)
|
|
7
|
-
* ```
|
|
8
|
-
*/
|
|
9
|
-
export const Adapter = {
|
|
10
|
-
/**
|
|
11
|
-
* Pair a port token with a factory. Call `create(...deps)` and pass the impl
|
|
12
|
-
* to `App.provide` — not this holder.
|
|
13
|
-
*/
|
|
14
|
-
of(token, create) {
|
|
15
|
-
return { token, create };
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/infra/adapter.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB;;;OAGG;IACH,EAAE,CACA,KAAmB,EACnB,MAA4B;QAO5B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC3B,CAAC;CACF,CAAC"}
|
package/dist/infra/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/infra/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/infra/index.js
DELETED
package/dist/infra/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/infra/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/infra/mapper.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { type Result } from '../core/index.js';
|
|
2
|
-
import type { EntityConstructor } from '../domain/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* One entity, two functions. Inbound `from` wraps the mapping.
|
|
5
|
-
* `restore` does not run the schema; `parse` does (untyped trust
|
|
6
|
-
* boundary). `VALIDATION` from `parse` / `create` / `set` is rethrown
|
|
7
|
-
* with a mapper message.
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* const IncidentMapper = Mapper.for(Incident)
|
|
11
|
-
* .to((e) => ({ id: e.id, closed_at: e.closedAt?.toISOString() ?? null }))
|
|
12
|
-
* .from((row) => Incident.restore({
|
|
13
|
-
* id: row.id,
|
|
14
|
-
* closedAt: row.closed_at ? new Date(row.closed_at) : null,
|
|
15
|
-
* }))
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare class Mapper<E extends EntityConstructor, Row> {
|
|
19
|
-
#private;
|
|
20
|
-
private constructor();
|
|
21
|
-
/** Start a mapper for this entity class. Chain `.to` then `.from`. */
|
|
22
|
-
static for<E extends EntityConstructor>(_entity: E): MapperTo<E>;
|
|
23
|
-
/** Outbound. No parse. */
|
|
24
|
-
to(entity: E['prototype']): Row;
|
|
25
|
-
/** Run the inbound mapping. Rethrows `VALIDATION` from `parse` / `create` / `set`. */
|
|
26
|
-
from(row: Row): E['prototype'];
|
|
27
|
-
/**
|
|
28
|
-
* Same mapping, but `from` returns `Result` instead of throwing.
|
|
29
|
-
*/
|
|
30
|
-
unsafe(): {
|
|
31
|
-
to: Mapper<E, Row>['to'];
|
|
32
|
-
from: (row: Row) => Result<E['prototype'], 'VALIDATION'>;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
/** Next step after `Mapper.for`. Call `.to` with the outbound mapping. */
|
|
36
|
-
export type MapperTo<E extends EntityConstructor> = {
|
|
37
|
-
/** Set the outbound mapping (entity → row). Returns the `.from` builder. */
|
|
38
|
-
to<Row>(toFn: (entity: E['prototype']) => Row): MapperFrom<E, Row>;
|
|
39
|
-
};
|
|
40
|
-
/** Next step after `.to`. Call `.from` with the inbound mapping to finish. */
|
|
41
|
-
export type MapperFrom<E extends EntityConstructor, Row> = {
|
|
42
|
-
/**
|
|
43
|
-
* Set the inbound mapping (row → entity) and return the mapper.
|
|
44
|
-
* `restore` does not run the schema; `parse` does.
|
|
45
|
-
*/
|
|
46
|
-
from(fromFn: (row: Row) => E['prototype']): Mapper<E, Row>;
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=mapper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../src/infra/mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,MAAM,EAEZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAI5D;;;;;;;;;;;;;;GAcG;AACH,qBAAa,MAAM,CAAC,CAAC,SAAS,iBAAiB,EAAE,GAAG;;IAIlD,OAAO;IAQP,sEAAsE;IACtE,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,iBAAiB,EAAE,OAAO,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IAQhE,0BAA0B;IAC1B,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,GAAG;IAI/B,sFAAsF;IACtF,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,WAAW,CAAC;IAe9B;;OAEG;IACH,MAAM,IAAI;QACR,EAAE,EAAE,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC,CAAC;KAC1D;CAoBF;AAED,0EAA0E;AAC1E,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,iBAAiB,IAAI;IAClD,4EAA4E;IAC5E,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,WAAW,CAAC,KAAK,GAAG,GAAG,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;CACpE,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,iBAAiB,EAAE,GAAG,IAAI;IACzD;;;OAGG;IACH,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;CAC5D,CAAC"}
|
package/dist/infra/mapper.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { CodedError, fail, ok, } from '../core/index.js';
|
|
2
|
-
const TRUST = 'hexok: model.from() failed entity.parse (trust boundary)';
|
|
3
|
-
/**
|
|
4
|
-
* One entity, two functions. Inbound `from` wraps the mapping.
|
|
5
|
-
* `restore` does not run the schema; `parse` does (untyped trust
|
|
6
|
-
* boundary). `VALIDATION` from `parse` / `create` / `set` is rethrown
|
|
7
|
-
* with a mapper message.
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* const IncidentMapper = Mapper.for(Incident)
|
|
11
|
-
* .to((e) => ({ id: e.id, closed_at: e.closedAt?.toISOString() ?? null }))
|
|
12
|
-
* .from((row) => Incident.restore({
|
|
13
|
-
* id: row.id,
|
|
14
|
-
* closedAt: row.closed_at ? new Date(row.closed_at) : null,
|
|
15
|
-
* }))
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export class Mapper {
|
|
19
|
-
#toFn;
|
|
20
|
-
#fromFn;
|
|
21
|
-
constructor(toFn, fromFn) {
|
|
22
|
-
this.#toFn = toFn;
|
|
23
|
-
this.#fromFn = fromFn;
|
|
24
|
-
}
|
|
25
|
-
/** Start a mapper for this entity class. Chain `.to` then `.from`. */
|
|
26
|
-
static for(_entity) {
|
|
27
|
-
return {
|
|
28
|
-
to: (toFn) => ({
|
|
29
|
-
from: (fromFn) => new Mapper(toFn, fromFn),
|
|
30
|
-
}),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/** Outbound. No parse. */
|
|
34
|
-
to(entity) {
|
|
35
|
-
return this.#toFn(entity);
|
|
36
|
-
}
|
|
37
|
-
/** Run the inbound mapping. Rethrows `VALIDATION` from `parse` / `create` / `set`. */
|
|
38
|
-
from(row) {
|
|
39
|
-
try {
|
|
40
|
-
return this.#fromFn(row);
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
if (isValidation(error)) {
|
|
44
|
-
throw new CodedError({
|
|
45
|
-
code: error.code,
|
|
46
|
-
message: TRUST,
|
|
47
|
-
...(error.data !== undefined ? { data: error.data } : {}),
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
throw error;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Same mapping, but `from` returns `Result` instead of throwing.
|
|
55
|
-
*/
|
|
56
|
-
unsafe() {
|
|
57
|
-
return {
|
|
58
|
-
to: (entity) => this.to(entity),
|
|
59
|
-
from: (row) => {
|
|
60
|
-
try {
|
|
61
|
-
return ok(this.#fromFn(row));
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
if (isValidation(error)) {
|
|
65
|
-
const issues = error.data?.issues;
|
|
66
|
-
return fail('VALIDATION', issues);
|
|
67
|
-
}
|
|
68
|
-
throw error;
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function isValidation(error) {
|
|
75
|
-
return error instanceof CodedError && error.code === 'VALIDATION';
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=mapper.js.map
|
package/dist/infra/mapper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.js","sourceRoot":"","sources":["../../src/infra/mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,EAAE,GAGH,MAAM,kBAAkB,CAAC;AAG1B,MAAM,KAAK,GAAG,0DAA0D,CAAC;AAEzE;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,MAAM;IACjB,KAAK,CAAkC;IACvC,OAAO,CAA+B;IAEtC,YACE,IAAqC,EACrC,MAAoC;QAEpC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,sEAAsE;IACtE,MAAM,CAAC,GAAG,CAA8B,OAAU;QAChD,OAAO;YACL,EAAE,EAAE,CAAM,IAAqC,EAAsB,EAAE,CAAC,CAAC;gBACvE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC;aAC3C,CAAC;SACH,CAAC;IACJ,CAAC;IAED,0BAA0B;IAC1B,EAAE,CAAC,MAAsB;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,sFAAsF;IACtF,IAAI,CAAC,GAAQ;QACX,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC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