File size: 9,150 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 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 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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | import * as Schema from "../../Schema.ts";
import * as Msgpack from "../encoding/Msgpack.ts";
/**
* Unique type identifier used to mark event log event definitions.
*
* @category type IDs
* @since 4.0.0
*/
export type TypeId = "~effect/eventlog/Event";
/**
* Runtime type identifier used to mark event log event definitions.
*
* @category type IDs
* @since 4.0.0
*/
export declare const TypeId: TypeId;
/**
* Returns `true` when a value is an event log event definition.
*
* @category guards
* @since 4.0.0
*/
export declare const isEvent: (u: unknown) => u is Event<any, any, any, any>;
/**
* Definition of an event type that can be written to an `EventLog`.
*
* **Details**
*
* An event definition contains its tag, primary-key function, payload schema,
* MessagePack payload schema, success schema, and error schema.
*
* @category models
* @since 4.0.0
*/
export interface Event<out Tag extends string, in out Payload extends Schema.Top = typeof Schema.Void, in out Success extends Schema.Top = typeof Schema.Void, in out Error extends Schema.Top = typeof Schema.Never> {
readonly [TypeId]: TypeId;
readonly tag: Tag;
readonly primaryKey: (payload: Schema.Schema.Type<Payload>) => string;
readonly payload: Payload;
readonly payloadMsgPack: Msgpack.schema<Payload>;
readonly success: Success;
readonly error: Error;
}
/**
* Marker service associated with the handler for an event tag.
*
* **Details**
*
* `ToService` derives this service from an `Event` so handler layers can expose
* which events they implement.
*
* @category models
* @since 4.0.0
*/
export interface EventHandler<in out Tag extends string> {
readonly _: unique symbol;
readonly tag: Tag;
}
/**
* Type-erased event log event definition.
*
* **Details**
*
* It preserves the runtime tag, primary-key function, payload schema, success
* schema, and error schema without retaining the original type parameters.
*
* @category models
* @since 4.0.0
*/
export interface Any {
readonly [TypeId]: TypeId;
readonly tag: string;
readonly primaryKey: (payload: any) => string;
readonly payload: Schema.Top;
readonly payloadMsgPack: Msgpack.schema<Schema.Top>;
readonly success: Schema.Top;
readonly error: Schema.Top;
}
/**
* Type-erased event definition with its runtime properties available
* structurally.
*
* @category models
* @since 4.0.0
*/
export interface AnyWithProps extends Any {
}
/**
* Derives the handler service marker for an event definition.
*
* @category models
* @since 4.0.0
*/
export type ToService<A> = A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error> ? EventHandler<_Tag> : never;
/**
* Extracts the tag string from an event definition.
*
* @category models
* @since 4.0.0
*/
export type Tag<A> = A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error> ? _Tag : never;
/**
* Extracts the error schema from an event definition.
*
* @category models
* @since 4.0.0
*/
export type ErrorSchema<A extends Any> = A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error> ? _Error : never;
/**
* Decoded error value type for an event definition.
*
* @category models
* @since 4.0.0
*/
export type Error<A extends Any> = Schema.Schema.Type<ErrorSchema<A>>;
/**
* Returns an event definition type whose error schema also includes the provided
* error schema.
*
* @category models
* @since 4.0.0
*/
export type AddError<A extends Any, Error extends Schema.Top> = A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error> ? Event<_Tag, _Payload, _Success, _Error | Error> : never;
/**
* Extracts the payload schema from an event definition.
*
* @category models
* @since 4.0.0
*/
export type PayloadSchema<A extends Any> = A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error> ? _Payload : never;
/**
* Extracts the payload schema for the event in a union with the specified tag.
*
* @category models
* @since 4.0.0
*/
export type PayloadSchemaWithTag<A extends Any, Tag extends string> = A extends Event<Tag, infer _Payload, infer _Success, infer _Error> ? _Payload : never;
/**
* Decoded payload value type for an event definition.
*
* @category models
* @since 4.0.0
*/
export type Payload<A extends Any> = Schema.Schema.Type<PayloadSchema<A>>;
/**
* Tagged payload value for an event definition.
*
* **Details**
*
* The result contains `_tag` set to the event tag and `payload` set to the
* decoded payload value.
*
* @category models
* @since 4.0.0
*/
export type TaggedPayload<A extends Any> = A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error> ? {
readonly _tag: _Tag;
readonly payload: Schema.Schema.Type<_Payload>;
} : never;
/**
* Extracts the success schema from an event definition.
*
* @category models
* @since 4.0.0
*/
export type SuccessSchema<A extends Any> = A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error> ? _Success : never;
/**
* Decoded success value type for an event definition.
*
* @category models
* @since 4.0.0
*/
export type Success<A extends Any> = Schema.Schema.Type<SuccessSchema<A>>;
/**
* Schema services required by a client for an event definition.
*
* **Details**
*
* This includes payload encoding services plus success and error decoding
* services.
*
* @category models
* @since 4.0.0
*/
export type ServicesClient<A> = A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error> ? _Payload["EncodingServices"] | _Success["DecodingServices"] | _Error["DecodingServices"] : never;
/**
* Schema services required by a server for an event definition.
*
* **Details**
*
* This includes payload decoding services plus success and error encoding
* services.
*
* @category models
* @since 4.0.0
*/
export type ServicesServer<A> = A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error> ? _Payload["DecodingServices"] | _Success["EncodingServices"] | _Error["EncodingServices"] : never;
/**
* All schema services required to encode and decode the payload, success, and
* error schemas for an event definition.
*
* @category models
* @since 4.0.0
*/
export type Services<A> = A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error> ? _Payload["DecodingServices"] | _Success["EncodingServices"] | _Error["EncodingServices"] | _Payload["EncodingServices"] | _Success["DecodingServices"] | _Error["DecodingServices"] : never;
/**
* Extracts the event definition with the specified tag from an event union.
*
* @category models
* @since 4.0.0
*/
export type WithTag<Events extends Any, Tag extends string> = Extract<Events, {
readonly tag: Tag;
}>;
/**
* Removes event definitions with the specified tag from an event union.
*
* @category models
* @since 4.0.0
*/
export type ExcludeTag<Events extends Any, Tag extends string> = Exclude<Events, {
readonly tag: Tag;
}>;
/**
* Decoded payload value type for the event in a union with the specified tag.
*
* @category models
* @since 4.0.0
*/
export type PayloadWithTag<Events extends Any, Tag extends string> = Payload<WithTag<Events, Tag>>;
/**
* Decoded success value type for the event in a union with the specified tag.
*
* @category models
* @since 4.0.0
*/
export type SuccessWithTag<Events extends Any, Tag extends string> = Success<WithTag<Events, Tag>>;
/**
* Decoded error value type for the event in a union with the specified tag.
*
* @category models
* @since 4.0.0
*/
export type ErrorWithTag<Events extends Any, Tag extends string> = Error<WithTag<Events, Tag>>;
/**
* Client-side schema services required for the event in a union with the specified
* tag.
*
* @category models
* @since 4.0.0
*/
export type ServicesClientWithTag<Events extends Any, Tag extends string> = ServicesClient<WithTag<Events, Tag>>;
/**
* Creates an event log event definition.
*
* **Details**
*
* If omitted, the payload and success schemas default to `Schema.Void`, the error
* schema defaults to `Schema.Never`, and the MessagePack payload schema is derived
* from the payload schema.
*
* @category constructors
* @since 4.0.0
*/
export declare function make<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 | undefined;
readonly success?: Success | undefined;
readonly error?: Error | undefined;
}): Event<Tag, Payload, Success, Error>;
/**
* Adds another error schema to an event definition.
*
* **Details**
*
* The returned event keeps the same tag, primary key, payload, and success schema
* while replacing the error schema with a union of the existing and new errors.
*
* @category constructors
* @since 4.0.0
*/
export declare function addError<A extends Any, Error2 extends Schema.Top>(event: A, error: Error2): AddError<A, Error2>;
//# sourceMappingURL=Event.d.ts.map |