Suite of AT Protocol TypeScript libraries built on web standards
1import type { NsidString } from "../core/string-format.ts";
2import type { Infer } from "../validation.ts";
3import type { ObjectSchema } from "./object.ts";
4import type { ParamsSchema } from "./params.ts";
5import type { RefSchema } from "./ref.ts";
6import type { TypedUnionSchema } from "./typed-union.ts";
7
8export type InferSubscriptionParameters<S extends Subscription> = S extends
9 Subscription<any, infer P extends ParamsSchema, any> ? Infer<P> : never;
10
11export type InferSubscriptionMessage<S extends Subscription> = S extends
12 Subscription<
13 any,
14 any,
15 infer M extends RefSchema | TypedUnionSchema | ObjectSchema
16 > ? Infer<M>
17 : unknown;
18
19export class Subscription<
20 TNsid extends NsidString = any,
21 TParameters extends ParamsSchema = any,
22 TMessage extends
23 | undefined
24 | RefSchema
25 | TypedUnionSchema
26 | ObjectSchema = any,
27 TErrors extends undefined | readonly string[] = any,
28> {
29 readonly type = "subscription" as const;
30
31 constructor(
32 readonly nsid: TNsid,
33 readonly parameters: TParameters,
34 readonly message: TMessage,
35 readonly errors: TErrors,
36 ) {}
37}