File size: 3,754 Bytes
31e8457
1b110ca
 
 
 
 
 
 
 
31e8457
 
 
 
 
 
 
1b110ca
 
 
31e8457
 
 
 
1b110ca
 
 
31e8457
 
 
 
1b110ca
 
31e8457
1b110ca
31e8457
 
 
1b110ca
 
31e8457
1b110ca
 
 
 
31e8457
 
1b110ca
31e8457
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1b110ca
 
31e8457
1b110ca
31e8457
 
 
 
 
1b110ca
 
31e8457
1b110ca
31e8457
 
 
1b110ca
 
31e8457
1b110ca
31e8457
 
 
1b110ca
 
31e8457
1b110ca
31e8457
 
 
1b110ca
 
31e8457
1b110ca
31e8457
 
 
1b110ca
 
31e8457
1b110ca
31e8457
 
 
1b110ca
31e8457
1b110ca
 
 
 
31e8457
 
1b110ca
31e8457
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
 * Defines groups of typed events for the unstable event-log system.
 *
 * An `EventGroup` collects event definitions that belong together. Start with
 * `empty`, add events with their payload, success, and error schemas, then use
 * the group to build clients with `EventLog.schema` and server handlers with
 * `EventLog.group`. The group only describes events; it does not write or run
 * them.
 *
 * @since 4.0.0
 */
import { type Pipeable } from "../../Pipeable.ts";
import * as Record from "../../Record.ts";
import type * as Schema from "../../Schema.ts";
import * as Event from "./Event.ts";
/**
 * Unique type identifier used to mark event log event groups.
 *
 * @category type IDs
 * @since 4.0.0
 */
export type TypeId = "~effect/eventlog/EventGroup";
/**
 * Runtime type identifier used to mark event log event groups.
 *
 * @category type IDs
 * @since 4.0.0
 */
export declare const TypeId: TypeId;
/**
 * Returns `true` when a value is an event log event group.
 *
 * @category guards
 * @since 4.0.0
 */
export declare const isEventGroup: (u: unknown) => u is Any;
/**
 * Typed collection of event definitions that represents a portion of an event log
 * domain.
 *
 * **When to use**
 *
 * Use when build groups from `empty.add(...)`, then provide implementations for the events
 * with `EventLog.group`.
 *
 * @category models
 * @since 4.0.0
 */
export interface EventGroup<out Events extends Event.Any = Event.Any> extends Pipeable {
    readonly [TypeId]: TypeId;
    readonly events: Record.ReadonlyRecord<string, Events>;
    /**
     * Add an `Event` to the `EventGroup`.
     */
    add<Tag extends string, Payload extends Schema.Top = typeof Schema.Void, Success extends Schema.Top = typeof Schema.Void, Error extends Schema.Top = typeof Schema.Never>(options: {
        readonly tag: Tag;
        readonly primaryKey: (payload: Schema.Schema.Type<Payload>) => string;
        readonly payload?: Payload;
        readonly success?: Success;
        readonly error?: Error;
    }): EventGroup<Events | Event.Event<Tag, Payload, Success, Error>>;
    /**
     * Add an error schema to all the events in the `EventGroup`.
     */
    addError<Error extends Schema.Top>(error: Error): EventGroup<Event.AddError<Events, Error>>;
}
/**
 * Type-erased marker for an event log event group.
 *
 * @category models
 * @since 4.0.0
 */
export interface Any {
    readonly [TypeId]: TypeId;
}
/**
 * Type-erased event group with its events record available structurally.
 *
 * @category models
 * @since 4.0.0
 */
export type AnyWithProps = EventGroup<Event.Any>;
/**
 * Derives the handler service markers required for all events in an event group.
 *
 * @category models
 * @since 4.0.0
 */
export type ToService<A> = A extends EventGroup<infer _Events> ? Event.ToService<_Events> : never;
/**
 * Extracts the union of event definitions contained in an event group.
 *
 * @category models
 * @since 4.0.0
 */
export type Events<Group> = Group extends EventGroup<infer _Events> ? _Events : never;
/**
 * Client-side schema services required by all events in an event group.
 *
 * @category models
 * @since 4.0.0
 */
export type ServicesClient<Group> = Event.ServicesClient<Events<Group>>;
/**
 * Server-side schema services required by all events in an event group.
 *
 * @category models
 * @since 4.0.0
 */
export type ServicesServer<Group> = Event.ServicesServer<Events<Group>>;
/**
 * Creates an empty event group used as the starting point for defining a group.
 *
 * **When to use**
 *
 * Use when you need the starting `EventGroup` value before adding event
 * definitions with `.add(...)`.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const empty: EventGroup<never>;
//# sourceMappingURL=EventGroup.d.ts.map