spectrum-ts 1.5.0 → 1.7.2

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.
@@ -0,0 +1,1029 @@
1
+ import { Pipe, Tuples, Fn } from 'hotscript';
2
+ import z__default from 'zod';
3
+
4
+ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObject<{
5
+ type: z__default.ZodLiteral<"text">;
6
+ text: z__default.ZodString;
7
+ }, z__default.core.$strip>, z__default.ZodObject<{
8
+ type: z__default.ZodLiteral<"custom">;
9
+ raw: z__default.ZodUnknown;
10
+ }, z__default.core.$strip>, z__default.ZodObject<{
11
+ type: z__default.ZodLiteral<"attachment">;
12
+ name: z__default.ZodString;
13
+ mimeType: z__default.ZodString;
14
+ size: z__default.ZodOptional<z__default.ZodNumber>;
15
+ read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
16
+ stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
17
+ }, z__default.core.$strip>, z__default.ZodObject<{
18
+ type: z__default.ZodLiteral<"contact">;
19
+ user: z__default.ZodOptional<z__default.ZodObject<{
20
+ __platform: z__default.ZodString;
21
+ id: z__default.ZodString;
22
+ }, z__default.core.$strip>>;
23
+ name: z__default.ZodOptional<z__default.ZodObject<{
24
+ formatted: z__default.ZodOptional<z__default.ZodString>;
25
+ first: z__default.ZodOptional<z__default.ZodString>;
26
+ last: z__default.ZodOptional<z__default.ZodString>;
27
+ middle: z__default.ZodOptional<z__default.ZodString>;
28
+ prefix: z__default.ZodOptional<z__default.ZodString>;
29
+ suffix: z__default.ZodOptional<z__default.ZodString>;
30
+ }, z__default.core.$strip>>;
31
+ phones: z__default.ZodOptional<z__default.ZodArray<z__default.ZodObject<{
32
+ value: z__default.ZodString;
33
+ type: z__default.ZodOptional<z__default.ZodEnum<{
34
+ mobile: "mobile";
35
+ home: "home";
36
+ work: "work";
37
+ other: "other";
38
+ }>>;
39
+ }, z__default.core.$strip>>>;
40
+ emails: z__default.ZodOptional<z__default.ZodArray<z__default.ZodObject<{
41
+ value: z__default.ZodString;
42
+ type: z__default.ZodOptional<z__default.ZodEnum<{
43
+ home: "home";
44
+ work: "work";
45
+ other: "other";
46
+ }>>;
47
+ }, z__default.core.$strip>>>;
48
+ addresses: z__default.ZodOptional<z__default.ZodArray<z__default.ZodObject<{
49
+ street: z__default.ZodOptional<z__default.ZodString>;
50
+ city: z__default.ZodOptional<z__default.ZodString>;
51
+ region: z__default.ZodOptional<z__default.ZodString>;
52
+ postalCode: z__default.ZodOptional<z__default.ZodString>;
53
+ country: z__default.ZodOptional<z__default.ZodString>;
54
+ type: z__default.ZodOptional<z__default.ZodEnum<{
55
+ home: "home";
56
+ work: "work";
57
+ other: "other";
58
+ }>>;
59
+ }, z__default.core.$strip>>>;
60
+ org: z__default.ZodOptional<z__default.ZodObject<{
61
+ name: z__default.ZodOptional<z__default.ZodString>;
62
+ title: z__default.ZodOptional<z__default.ZodString>;
63
+ department: z__default.ZodOptional<z__default.ZodString>;
64
+ }, z__default.core.$strip>>;
65
+ urls: z__default.ZodOptional<z__default.ZodArray<z__default.ZodString>>;
66
+ birthday: z__default.ZodOptional<z__default.ZodString>;
67
+ note: z__default.ZodOptional<z__default.ZodString>;
68
+ photo: z__default.ZodOptional<z__default.ZodObject<{
69
+ mimeType: z__default.ZodString;
70
+ read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
71
+ }, z__default.core.$strip>>;
72
+ raw: z__default.ZodOptional<z__default.ZodUnknown>;
73
+ }, z__default.core.$strip>, z__default.ZodObject<{
74
+ type: z__default.ZodLiteral<"voice">;
75
+ name: z__default.ZodOptional<z__default.ZodString>;
76
+ mimeType: z__default.ZodString;
77
+ duration: z__default.ZodOptional<z__default.ZodNumber>;
78
+ size: z__default.ZodOptional<z__default.ZodNumber>;
79
+ read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
80
+ stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
81
+ }, z__default.core.$strip>, z__default.ZodObject<{
82
+ type: z__default.ZodLiteral<"richlink">;
83
+ url: z__default.ZodURL;
84
+ title: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
85
+ summary: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
86
+ cover: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodObject<{
87
+ mimeType: z__default.ZodOptional<z__default.ZodString>;
88
+ read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
89
+ stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
90
+ }, z__default.core.$strip>>>>;
91
+ }, z__default.core.$strip>, z__default.ZodObject<{
92
+ type: z__default.ZodLiteral<"reaction">;
93
+ emoji: z__default.ZodString;
94
+ target: z__default.ZodCustom<Message, Message>;
95
+ }, z__default.core.$strip>, z__default.ZodObject<{
96
+ type: z__default.ZodLiteral<"group">;
97
+ items: z__default.ZodArray<z__default.ZodCustom<Message, Message>>;
98
+ }, z__default.core.$strip>, z__default.ZodObject<{
99
+ type: z__default.ZodLiteral<"poll">;
100
+ title: z__default.ZodString;
101
+ options: z__default.ZodArray<z__default.ZodObject<{
102
+ title: z__default.ZodString;
103
+ }, z__default.core.$strip>>;
104
+ }, z__default.core.$strip>, z__default.ZodObject<{
105
+ type: z__default.ZodLiteral<"poll_option">;
106
+ option: z__default.ZodObject<{
107
+ title: z__default.ZodString;
108
+ }, z__default.core.$strip>;
109
+ poll: z__default.ZodObject<{
110
+ type: z__default.ZodLiteral<"poll">;
111
+ title: z__default.ZodString;
112
+ options: z__default.ZodArray<z__default.ZodObject<{
113
+ title: z__default.ZodString;
114
+ }, z__default.core.$strip>>;
115
+ }, z__default.core.$strip>;
116
+ selected: z__default.ZodBoolean;
117
+ title: z__default.ZodString;
118
+ }, z__default.core.$strip>, z__default.ZodObject<{
119
+ type: z__default.ZodLiteral<"effect">;
120
+ content: z__default.ZodDiscriminatedUnion<[z__default.ZodObject<{
121
+ type: z__default.ZodLiteral<"text">;
122
+ text: z__default.ZodString;
123
+ }, z__default.core.$strip>, z__default.ZodObject<{
124
+ type: z__default.ZodLiteral<"attachment">;
125
+ name: z__default.ZodString;
126
+ mimeType: z__default.ZodString;
127
+ size: z__default.ZodOptional<z__default.ZodNumber>;
128
+ read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
129
+ stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
130
+ }, z__default.core.$strip>], "type">;
131
+ effect: z__default.ZodString;
132
+ }, z__default.core.$strip>, z__default.ZodObject<{
133
+ type: z__default.ZodLiteral<"typing">;
134
+ state: z__default.ZodEnum<{
135
+ start: "start";
136
+ stop: "stop";
137
+ }>;
138
+ }, z__default.core.$strip>, z__default.ZodObject<{
139
+ type: z__default.ZodLiteral<"reply">;
140
+ content: z__default.ZodCustom<{
141
+ type: "contact";
142
+ user?: {
143
+ __platform: string;
144
+ id: string;
145
+ } | undefined;
146
+ name?: {
147
+ formatted?: string | undefined;
148
+ first?: string | undefined;
149
+ last?: string | undefined;
150
+ middle?: string | undefined;
151
+ prefix?: string | undefined;
152
+ suffix?: string | undefined;
153
+ } | undefined;
154
+ phones?: {
155
+ value: string;
156
+ type?: "mobile" | "home" | "work" | "other" | undefined;
157
+ }[] | undefined;
158
+ emails?: {
159
+ value: string;
160
+ type?: "home" | "work" | "other" | undefined;
161
+ }[] | undefined;
162
+ addresses?: {
163
+ street?: string | undefined;
164
+ city?: string | undefined;
165
+ region?: string | undefined;
166
+ postalCode?: string | undefined;
167
+ country?: string | undefined;
168
+ type?: "home" | "work" | "other" | undefined;
169
+ }[] | undefined;
170
+ org?: {
171
+ name?: string | undefined;
172
+ title?: string | undefined;
173
+ department?: string | undefined;
174
+ } | undefined;
175
+ urls?: string[] | undefined;
176
+ birthday?: string | undefined;
177
+ note?: string | undefined;
178
+ photo?: {
179
+ mimeType: string;
180
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
181
+ } | undefined;
182
+ raw?: unknown;
183
+ } | {
184
+ type: "text";
185
+ text: string;
186
+ } | {
187
+ type: "attachment";
188
+ name: string;
189
+ mimeType: string;
190
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
191
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
192
+ size?: number | undefined;
193
+ } | {
194
+ type: "custom";
195
+ raw: unknown;
196
+ } | {
197
+ type: "voice";
198
+ mimeType: string;
199
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
200
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
201
+ name?: string | undefined;
202
+ duration?: number | undefined;
203
+ size?: number | undefined;
204
+ } | {
205
+ type: "richlink";
206
+ url: string;
207
+ title: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
208
+ summary: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
209
+ cover: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodObject<{
210
+ mimeType: z__default.ZodOptional<z__default.ZodString>;
211
+ read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
212
+ stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
213
+ }, z__default.core.$strip>>>>;
214
+ } | {
215
+ type: "reaction";
216
+ emoji: string;
217
+ target: Message;
218
+ } | {
219
+ type: "group";
220
+ items: Message[];
221
+ } | {
222
+ type: "poll";
223
+ title: string;
224
+ options: {
225
+ title: string;
226
+ }[];
227
+ } | {
228
+ type: "poll_option";
229
+ option: {
230
+ title: string;
231
+ };
232
+ poll: {
233
+ type: "poll";
234
+ title: string;
235
+ options: {
236
+ title: string;
237
+ }[];
238
+ };
239
+ selected: boolean;
240
+ title: string;
241
+ } | {
242
+ type: "effect";
243
+ content: {
244
+ type: "text";
245
+ text: string;
246
+ } | {
247
+ type: "attachment";
248
+ name: string;
249
+ mimeType: string;
250
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
251
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
252
+ size?: number | undefined;
253
+ };
254
+ effect: string;
255
+ } | {
256
+ type: "typing";
257
+ state: "start" | "stop";
258
+ }, {
259
+ type: "contact";
260
+ user?: {
261
+ __platform: string;
262
+ id: string;
263
+ } | undefined;
264
+ name?: {
265
+ formatted?: string | undefined;
266
+ first?: string | undefined;
267
+ last?: string | undefined;
268
+ middle?: string | undefined;
269
+ prefix?: string | undefined;
270
+ suffix?: string | undefined;
271
+ } | undefined;
272
+ phones?: {
273
+ value: string;
274
+ type?: "mobile" | "home" | "work" | "other" | undefined;
275
+ }[] | undefined;
276
+ emails?: {
277
+ value: string;
278
+ type?: "home" | "work" | "other" | undefined;
279
+ }[] | undefined;
280
+ addresses?: {
281
+ street?: string | undefined;
282
+ city?: string | undefined;
283
+ region?: string | undefined;
284
+ postalCode?: string | undefined;
285
+ country?: string | undefined;
286
+ type?: "home" | "work" | "other" | undefined;
287
+ }[] | undefined;
288
+ org?: {
289
+ name?: string | undefined;
290
+ title?: string | undefined;
291
+ department?: string | undefined;
292
+ } | undefined;
293
+ urls?: string[] | undefined;
294
+ birthday?: string | undefined;
295
+ note?: string | undefined;
296
+ photo?: {
297
+ mimeType: string;
298
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
299
+ } | undefined;
300
+ raw?: unknown;
301
+ } | {
302
+ type: "text";
303
+ text: string;
304
+ } | {
305
+ type: "attachment";
306
+ name: string;
307
+ mimeType: string;
308
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
309
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
310
+ size?: number | undefined;
311
+ } | {
312
+ type: "custom";
313
+ raw: unknown;
314
+ } | {
315
+ type: "voice";
316
+ mimeType: string;
317
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
318
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
319
+ name?: string | undefined;
320
+ duration?: number | undefined;
321
+ size?: number | undefined;
322
+ } | {
323
+ type: "richlink";
324
+ url: string;
325
+ title: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
326
+ summary: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
327
+ cover: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodObject<{
328
+ mimeType: z__default.ZodOptional<z__default.ZodString>;
329
+ read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
330
+ stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
331
+ }, z__default.core.$strip>>>>;
332
+ } | {
333
+ type: "reaction";
334
+ emoji: string;
335
+ target: Message;
336
+ } | {
337
+ type: "group";
338
+ items: Message[];
339
+ } | {
340
+ type: "poll";
341
+ title: string;
342
+ options: {
343
+ title: string;
344
+ }[];
345
+ } | {
346
+ type: "poll_option";
347
+ option: {
348
+ title: string;
349
+ };
350
+ poll: {
351
+ type: "poll";
352
+ title: string;
353
+ options: {
354
+ title: string;
355
+ }[];
356
+ };
357
+ selected: boolean;
358
+ title: string;
359
+ } | {
360
+ type: "effect";
361
+ content: {
362
+ type: "text";
363
+ text: string;
364
+ } | {
365
+ type: "attachment";
366
+ name: string;
367
+ mimeType: string;
368
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
369
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
370
+ size?: number | undefined;
371
+ };
372
+ effect: string;
373
+ } | {
374
+ type: "typing";
375
+ state: "start" | "stop";
376
+ }>;
377
+ target: z__default.ZodCustom<Message, Message>;
378
+ }, z__default.core.$strip>, z__default.ZodObject<{
379
+ type: z__default.ZodLiteral<"edit">;
380
+ content: z__default.ZodCustom<{
381
+ type: "contact";
382
+ user?: {
383
+ __platform: string;
384
+ id: string;
385
+ } | undefined;
386
+ name?: {
387
+ formatted?: string | undefined;
388
+ first?: string | undefined;
389
+ last?: string | undefined;
390
+ middle?: string | undefined;
391
+ prefix?: string | undefined;
392
+ suffix?: string | undefined;
393
+ } | undefined;
394
+ phones?: {
395
+ value: string;
396
+ type?: "mobile" | "home" | "work" | "other" | undefined;
397
+ }[] | undefined;
398
+ emails?: {
399
+ value: string;
400
+ type?: "home" | "work" | "other" | undefined;
401
+ }[] | undefined;
402
+ addresses?: {
403
+ street?: string | undefined;
404
+ city?: string | undefined;
405
+ region?: string | undefined;
406
+ postalCode?: string | undefined;
407
+ country?: string | undefined;
408
+ type?: "home" | "work" | "other" | undefined;
409
+ }[] | undefined;
410
+ org?: {
411
+ name?: string | undefined;
412
+ title?: string | undefined;
413
+ department?: string | undefined;
414
+ } | undefined;
415
+ urls?: string[] | undefined;
416
+ birthday?: string | undefined;
417
+ note?: string | undefined;
418
+ photo?: {
419
+ mimeType: string;
420
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
421
+ } | undefined;
422
+ raw?: unknown;
423
+ } | {
424
+ type: "text";
425
+ text: string;
426
+ } | {
427
+ type: "attachment";
428
+ name: string;
429
+ mimeType: string;
430
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
431
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
432
+ size?: number | undefined;
433
+ } | {
434
+ type: "custom";
435
+ raw: unknown;
436
+ } | {
437
+ type: "voice";
438
+ mimeType: string;
439
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
440
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
441
+ name?: string | undefined;
442
+ duration?: number | undefined;
443
+ size?: number | undefined;
444
+ } | {
445
+ type: "richlink";
446
+ url: string;
447
+ title: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
448
+ summary: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
449
+ cover: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodObject<{
450
+ mimeType: z__default.ZodOptional<z__default.ZodString>;
451
+ read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
452
+ stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
453
+ }, z__default.core.$strip>>>>;
454
+ } | {
455
+ type: "reaction";
456
+ emoji: string;
457
+ target: Message;
458
+ } | {
459
+ type: "group";
460
+ items: Message[];
461
+ } | {
462
+ type: "poll";
463
+ title: string;
464
+ options: {
465
+ title: string;
466
+ }[];
467
+ } | {
468
+ type: "poll_option";
469
+ option: {
470
+ title: string;
471
+ };
472
+ poll: {
473
+ type: "poll";
474
+ title: string;
475
+ options: {
476
+ title: string;
477
+ }[];
478
+ };
479
+ selected: boolean;
480
+ title: string;
481
+ } | {
482
+ type: "effect";
483
+ content: {
484
+ type: "text";
485
+ text: string;
486
+ } | {
487
+ type: "attachment";
488
+ name: string;
489
+ mimeType: string;
490
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
491
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
492
+ size?: number | undefined;
493
+ };
494
+ effect: string;
495
+ } | {
496
+ type: "typing";
497
+ state: "start" | "stop";
498
+ }, {
499
+ type: "contact";
500
+ user?: {
501
+ __platform: string;
502
+ id: string;
503
+ } | undefined;
504
+ name?: {
505
+ formatted?: string | undefined;
506
+ first?: string | undefined;
507
+ last?: string | undefined;
508
+ middle?: string | undefined;
509
+ prefix?: string | undefined;
510
+ suffix?: string | undefined;
511
+ } | undefined;
512
+ phones?: {
513
+ value: string;
514
+ type?: "mobile" | "home" | "work" | "other" | undefined;
515
+ }[] | undefined;
516
+ emails?: {
517
+ value: string;
518
+ type?: "home" | "work" | "other" | undefined;
519
+ }[] | undefined;
520
+ addresses?: {
521
+ street?: string | undefined;
522
+ city?: string | undefined;
523
+ region?: string | undefined;
524
+ postalCode?: string | undefined;
525
+ country?: string | undefined;
526
+ type?: "home" | "work" | "other" | undefined;
527
+ }[] | undefined;
528
+ org?: {
529
+ name?: string | undefined;
530
+ title?: string | undefined;
531
+ department?: string | undefined;
532
+ } | undefined;
533
+ urls?: string[] | undefined;
534
+ birthday?: string | undefined;
535
+ note?: string | undefined;
536
+ photo?: {
537
+ mimeType: string;
538
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
539
+ } | undefined;
540
+ raw?: unknown;
541
+ } | {
542
+ type: "text";
543
+ text: string;
544
+ } | {
545
+ type: "attachment";
546
+ name: string;
547
+ mimeType: string;
548
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
549
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
550
+ size?: number | undefined;
551
+ } | {
552
+ type: "custom";
553
+ raw: unknown;
554
+ } | {
555
+ type: "voice";
556
+ mimeType: string;
557
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
558
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
559
+ name?: string | undefined;
560
+ duration?: number | undefined;
561
+ size?: number | undefined;
562
+ } | {
563
+ type: "richlink";
564
+ url: string;
565
+ title: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
566
+ summary: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
567
+ cover: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodObject<{
568
+ mimeType: z__default.ZodOptional<z__default.ZodString>;
569
+ read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
570
+ stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
571
+ }, z__default.core.$strip>>>>;
572
+ } | {
573
+ type: "reaction";
574
+ emoji: string;
575
+ target: Message;
576
+ } | {
577
+ type: "group";
578
+ items: Message[];
579
+ } | {
580
+ type: "poll";
581
+ title: string;
582
+ options: {
583
+ title: string;
584
+ }[];
585
+ } | {
586
+ type: "poll_option";
587
+ option: {
588
+ title: string;
589
+ };
590
+ poll: {
591
+ type: "poll";
592
+ title: string;
593
+ options: {
594
+ title: string;
595
+ }[];
596
+ };
597
+ selected: boolean;
598
+ title: string;
599
+ } | {
600
+ type: "effect";
601
+ content: {
602
+ type: "text";
603
+ text: string;
604
+ } | {
605
+ type: "attachment";
606
+ name: string;
607
+ mimeType: string;
608
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
609
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
610
+ size?: number | undefined;
611
+ };
612
+ effect: string;
613
+ } | {
614
+ type: "typing";
615
+ state: "start" | "stop";
616
+ }>;
617
+ target: z__default.ZodCustom<Message, Message>;
618
+ }, z__default.core.$strip>], "type">;
619
+ type Content = z__default.infer<typeof contentSchema>;
620
+ interface ContentBuilder {
621
+ build(): Promise<Content>;
622
+ }
623
+ type ContentInput = string | ContentBuilder;
624
+
625
+ interface User {
626
+ readonly __platform: string;
627
+ readonly id: string;
628
+ }
629
+
630
+ interface Space<_Def = unknown> {
631
+ readonly __platform: string;
632
+ edit(message: OutboundMessage, newContent: ContentInput): Promise<void>;
633
+ /**
634
+ * Look up a message in this space by its id. Returns `undefined` if the
635
+ * platform has no way to resolve the id (e.g. cache miss with no by-id
636
+ * SDK fallback). Used to materialize a `Message` for APIs that require one,
637
+ * such as `reaction()`.
638
+ */
639
+ getMessage(id: string): Promise<Message | undefined>;
640
+ readonly id: string;
641
+ responding<T>(fn: () => T | Promise<T>): Promise<T>;
642
+ send(content: ContentInput): Promise<OutboundMessage | undefined>;
643
+ send(...content: [ContentInput, ContentInput, ...ContentInput[]]): Promise<OutboundMessage[]>;
644
+ startTyping(): Promise<void>;
645
+ stopTyping(): Promise<void>;
646
+ }
647
+
648
+ interface BaseMessage<TPlatform extends string = string, TSender extends User = User, TSpace extends Space = Space> {
649
+ content: Content;
650
+ readonly id: string;
651
+ platform: TPlatform;
652
+ react(reaction: string): Promise<void>;
653
+ reply(content: ContentInput): Promise<OutboundMessage<TPlatform, TSender, TSpace> | undefined>;
654
+ reply(...content: [ContentInput, ContentInput, ...ContentInput[]]): Promise<OutboundMessage<TPlatform, TSender, TSpace>[]>;
655
+ space: TSpace;
656
+ timestamp: Date;
657
+ }
658
+ interface InboundMessage<TPlatform extends string = string, TSender extends User = User, TSpace extends Space = Space> extends BaseMessage<TPlatform, TSender, TSpace> {
659
+ direction: "inbound";
660
+ sender: TSender;
661
+ }
662
+ interface OutboundMessage<TPlatform extends string = string, TSender extends User = User, TSpace extends Space = Space> extends BaseMessage<TPlatform, TSender, TSpace> {
663
+ direction: "outbound";
664
+ edit(newContent: ContentInput): Promise<void>;
665
+ sender: TSender | undefined;
666
+ }
667
+ type Message<TPlatform extends string = string, TSender extends User = User, TSpace extends Space = Space> = InboundMessage<TPlatform, TSender, TSpace> | OutboundMessage<TPlatform, TSender, TSpace>;
668
+
669
+ /**
670
+ * A small per-platform key-value bag, modeled after Swift's `UserDefaults`.
671
+ * Untyped writes; typed reads return `undefined` on missing key OR type
672
+ * mismatch (no throws). In-memory only.
673
+ *
674
+ * SDK-internal: reachable from inside `definePlatform` callbacks via the
675
+ * `store` field on lifecycle/action/event ctx. Not exposed on the public
676
+ * SpectrumInstance or platform narrower.
677
+ */
678
+ interface Store {
679
+ array<T = unknown>(key: string): T[] | undefined;
680
+ bool(key: string): boolean | undefined;
681
+ clear(): void;
682
+ delete(key: string): boolean;
683
+ get(key: string): unknown;
684
+ has(key: string): boolean;
685
+ keys(): string[];
686
+ number(key: string): number | undefined;
687
+ object<T = Record<string, unknown>>(key: string): T | undefined;
688
+ set(key: string, value: unknown): void;
689
+ string(key: string): string | undefined;
690
+ }
691
+
692
+ interface ManagedStream<T> extends AsyncIterable<T> {
693
+ close(): Promise<void>;
694
+ }
695
+ type StreamCleanup = void | (() => void | Promise<void>);
696
+ declare function stream<T>(setup: (emit: (value: T) => Promise<void>, end: (error?: unknown) => void) => StreamCleanup | Promise<StreamCleanup>): ManagedStream<T>;
697
+ declare function mergeStreams<T>(streams: readonly ManagedStream<T>[]): ManagedStream<T>;
698
+ interface Broadcaster<T> {
699
+ close(): Promise<void>;
700
+ subscribe(): ManagedStream<T>;
701
+ }
702
+ declare function broadcast<T>(source: ManagedStream<T>): Broadcaster<T>;
703
+
704
+ /**
705
+ * A platform-defined sugar method on `Space`. Each entry is a content-builder
706
+ * factory; the runtime injects a thin wrapper that calls
707
+ * `space.send(factory(...args))` and returns the result.
708
+ *
709
+ * Names that collide with reserved `Space` keys (`send`, `edit`,
710
+ * `getMessage`, `startTyping`, `stopTyping`, `responding`, `id`,
711
+ * `__platform`) are skipped at runtime with a warning and excluded at the
712
+ * type level via `Exclude<…, keyof Space>`.
713
+ */
714
+ type SpaceActionFactory = (...args: never[]) => ContentBuilder;
715
+ type ResolvedSpace = Pick<Space, "id">;
716
+ type SpaceRef = Pick<Space, "id" | "__platform">;
717
+ type ResolvedUser = Pick<User, "id">;
718
+ type AwaitedReturn<T> = T extends (...args: never[]) => infer R ? Awaited<R> : never;
719
+ type NoInferClient<T> = [T][T extends unknown ? 0 : never];
720
+ type SchemaInfer<T> = T extends {
721
+ schema?: infer S extends z__default.ZodType<object>;
722
+ } ? z__default.infer<S> : Record<never, never>;
723
+ type InferSchema<TSchema> = TSchema extends z__default.ZodType<object> ? z__default.infer<TSchema> : Record<never, never>;
724
+ type InferOptionalSchema<TSchema> = TSchema extends z__default.ZodType<object> ? z__default.infer<TSchema> : never;
725
+ type InputSchema<TSchema> = TSchema extends z__default.ZodType<object> ? z__default.input<TSchema> : never;
726
+ type EventProducer<TPayload = unknown, TClient = unknown, TConfig = unknown> = (ctx: {
727
+ client: NoInferClient<TClient>;
728
+ config: TConfig;
729
+ store: Store;
730
+ }) => AsyncIterable<TPayload>;
731
+ type ProviderMessage<TSender extends ResolvedUser = ResolvedUser, TSpace extends ResolvedSpace = ResolvedSpace, TExtra extends object = Record<never, never>> = {
732
+ id: string;
733
+ content: Content;
734
+ sender: TSender;
735
+ space: TSpace;
736
+ timestamp?: Date;
737
+ } & TExtra;
738
+ /**
739
+ * A message a provider produced — used for both inbound (`messages`,
740
+ * `actions.getMessage`) and outbound (`send`) flows. Providers return their native
741
+ * record shape (including platform extras like `partIndex`/`parentId` for
742
+ * iMessage) and the platform `wrapProviderMessage` pipeline turns it into a
743
+ * fully-built Message.
744
+ *
745
+ * `sender` is optional because outbound sends often can't synthesize one
746
+ * (the SDK doesn't surface the bot's own handle); inbound providers are
747
+ * expected to populate it.
748
+ */
749
+ type ProviderMessageRecord = {
750
+ id: string;
751
+ content: Content;
752
+ sender?: {
753
+ id: string;
754
+ } & Record<string, unknown>;
755
+ space: {
756
+ id: string;
757
+ } & Record<string, unknown>;
758
+ timestamp?: Date;
759
+ } & Record<string, unknown>;
760
+ type MergeSchema<TSchema extends z__default.ZodType | undefined, TBase extends object> = TSchema extends z__default.ZodType ? string extends keyof z__default.infer<TSchema> ? TBase : Omit<z__default.infer<TSchema>, keyof TBase> & TBase : TBase;
761
+ type SchemaMessage<TUserSchema extends z__default.ZodType | undefined = undefined, TSpaceSchema extends z__default.ZodType | undefined = undefined> = ProviderMessage<MergeSchema<TUserSchema, ResolvedUser>, MergeSchema<TSpaceSchema, ResolvedSpace>>;
762
+ type InferEventPayload<T> = T extends (ctx: never) => AsyncIterable<infer P> ? P : never;
763
+ type ReservedNames = "stop" | "send" | "__internal" | "__providers";
764
+ interface CreateClientContext<_ConfigSchema extends z__default.ZodType<object>> {
765
+ config: z__default.infer<_ConfigSchema>;
766
+ projectId: string | undefined;
767
+ projectSecret: string | undefined;
768
+ store: Store;
769
+ }
770
+ /**
771
+ * The full definition of a platform adapter.
772
+ *
773
+ * Spectrum's platform API is shaped around the universal messaging contract:
774
+ * **`messages` (inbound stream) + `send` (outbound dispatcher)**. Together
775
+ * they handle 99% of what any platform integration needs to do — every
776
+ * higher-level affordance (`message.reply`, `message.react`, `space.edit`,
777
+ * `space.startTyping`, etc.) is sugar that routes through `send`.
778
+ *
779
+ * Everything beyond those two is optional: `getMessage` is a known capability
780
+ * that lives inside `actions?`; platform-specific event streams live inside
781
+ * `events?` and surface as flat properties on the platform instance.
782
+ *
783
+ * Minimum viable platform integration:
784
+ * `name`, `config`, `lifecycle`, `user`, `space`, `messages`, `send`.
785
+ */
786
+ interface PlatformDef<_Name extends string = string, _ConfigSchema extends z__default.ZodType<object> = z__default.ZodType<object>, _UserSchema extends z__default.ZodType<object> | undefined = undefined, _SpaceSchema extends z__default.ZodType<object> | undefined = undefined, _SpaceParamsSchema extends z__default.ZodType<object> | undefined = undefined, _Client = unknown, _ResolvedUser extends ResolvedUser = ResolvedUser, _ResolvedSpace extends ResolvedSpace = ResolvedSpace, _MessageSchema extends z__default.ZodType<object> | undefined = undefined, _MessageType extends ProviderMessage<_ResolvedUser, _ResolvedSpace, InferSchema<_MessageSchema>> = ProviderMessage<_ResolvedUser, _ResolvedSpace, InferSchema<_MessageSchema>>, _Events extends (Record<string, EventProducer<unknown, _Client, z__default.infer<_ConfigSchema>>> & {
787
+ messages?: never;
788
+ }) | undefined = undefined> {
789
+ /**
790
+ * Optional escape hatch: platform actions beyond `send`. Currently the
791
+ * framework recognizes one slot:
792
+ *
793
+ * - **`getMessage?`** — fetch a message by id from a space. Powers
794
+ * `space.getMessage(id)`. When omitted, `space.getMessage()` warns and
795
+ * returns `undefined`.
796
+ *
797
+ * 99% of integrations don't need this — `messages` + `send` is the
798
+ * universal contract.
799
+ */
800
+ actions?: {
801
+ getMessage?: (_: {
802
+ space: _ResolvedSpace & SpaceRef;
803
+ messageId: string;
804
+ client: NoInferClient<_Client>;
805
+ config: z__default.infer<_ConfigSchema>;
806
+ store: Store;
807
+ }) => Promise<_MessageType | undefined>;
808
+ };
809
+ config: _ConfigSchema;
810
+ /**
811
+ * Optional escape hatch: platform-specific event streams beyond the core
812
+ * `messages` stream (e.g. presence updates, read receipts). Each producer
813
+ * is surfaced as a flat property on both `spectrum` and the platform
814
+ * instance (e.g. `spectrum.presence`, `slack.readReceipt`).
815
+ *
816
+ * The key `messages` is reserved — the core inbound stream lives at the
817
+ * top level, not inside `events?`.
818
+ *
819
+ * 99% of integrations don't need this — `messages` + `send` is the
820
+ * universal contract.
821
+ */
822
+ events?: _Events;
823
+ lifecycle: {
824
+ createClient: (ctx: CreateClientContext<_ConfigSchema>) => Promise<_Client>;
825
+ destroyClient?: (ctx: {
826
+ client: NoInferClient<_Client>;
827
+ store: Store;
828
+ }) => Promise<void>;
829
+ };
830
+ message?: {
831
+ schema?: _MessageSchema;
832
+ };
833
+ /**
834
+ * Inbound message stream. Returns an `AsyncIterable<ProviderMessageRecord>`
835
+ * — Spectrum wraps each emitted record into a fully-built `Message` and
836
+ * fans it out via `spectrum.messages`.
837
+ *
838
+ * One of the two universal platform contracts (along with `send`). 99% of
839
+ * integrations only need to implement `messages` + `send`.
840
+ */
841
+ messages: EventProducer<_MessageType, _Client, z__default.infer<_ConfigSchema>>;
842
+ name: _Name;
843
+ /**
844
+ * Send a piece of `Content` to a space. The provider inspects
845
+ * `content.type` and dispatches accordingly — text, attachments, reactions,
846
+ * replies, edits, typing indicators, and any other content type all flow
847
+ * through this single action.
848
+ *
849
+ * Returns a `ProviderMessageRecord` (id + timestamp) for content that
850
+ * produces a message; returns `undefined` for fire-and-forget control
851
+ * signals (reactions, typing, edits) on platforms that don't return ids.
852
+ *
853
+ * One of the two universal platform contracts (along with `messages`).
854
+ */
855
+ send: (_: {
856
+ space: _ResolvedSpace & SpaceRef;
857
+ content: Content;
858
+ client: NoInferClient<_Client>;
859
+ config: z__default.infer<_ConfigSchema>;
860
+ store: Store;
861
+ }) => Promise<ProviderMessageRecord | undefined>;
862
+ space: {
863
+ schema?: _SpaceSchema;
864
+ params?: _SpaceParamsSchema;
865
+ resolve: (_: {
866
+ input: {
867
+ users: (_ResolvedUser & {
868
+ __platform: _Name;
869
+ })[];
870
+ params?: _SpaceParamsSchema extends z__default.ZodType<object> ? z__default.infer<_SpaceParamsSchema> : undefined;
871
+ };
872
+ client: NoInferClient<_Client>;
873
+ config: z__default.infer<_ConfigSchema>;
874
+ store: Store;
875
+ }) => Promise<_ResolvedSpace>;
876
+ /**
877
+ * Optional platform-specific sugar methods bound to `PlatformSpace<Def>`.
878
+ *
879
+ * Each entry is a `ContentBuilder` factory; `buildSpace` injects a thin
880
+ * wrapper that calls `space.send(factory(...args))`. The wrapper is
881
+ * typed as `(...args) => Promise<OutboundMessage | undefined>` on
882
+ * `PlatformSpace<Def>` via `SpaceActionMethods<Def>`.
883
+ *
884
+ * Mirrors the top-level `PlatformDef.actions` slot — `actions` lives at
885
+ * the platform level for capabilities (e.g. `getMessage`); `space.actions`
886
+ * lives here for sugar that delegates through `send`.
887
+ *
888
+ * Names that collide with reserved `Space` keys (`send`, `edit`,
889
+ * `getMessage`, `startTyping`, `stopTyping`, `responding`, `id`,
890
+ * `__platform`) are skipped at runtime with a warning and excluded at
891
+ * the type level.
892
+ */
893
+ actions?: Record<string, SpaceActionFactory>;
894
+ };
895
+ user: {
896
+ schema?: _UserSchema;
897
+ resolve: (_: {
898
+ input: {
899
+ userID: string;
900
+ };
901
+ client: NoInferClient<_Client>;
902
+ config: z__default.infer<_ConfigSchema>;
903
+ store: Store;
904
+ }) => Promise<_ResolvedUser>;
905
+ };
906
+ }
907
+ interface AnyPlatformDef {
908
+ actions?: {
909
+ getMessage?: (_: any) => Promise<any>;
910
+ };
911
+ config: z__default.ZodType<object>;
912
+ events?: {
913
+ [key: string]: (ctx: any) => AsyncIterable<any>;
914
+ };
915
+ lifecycle: {
916
+ createClient: (ctx: any) => Promise<any>;
917
+ destroyClient?: (ctx: any) => Promise<void>;
918
+ };
919
+ message?: {
920
+ schema?: z__default.ZodType<object>;
921
+ };
922
+ messages: (ctx: any) => AsyncIterable<any>;
923
+ name: string;
924
+ send: (_: any) => Promise<ProviderMessageRecord | undefined>;
925
+ space: {
926
+ schema?: z__default.ZodType<object>;
927
+ params?: z__default.ZodType<object>;
928
+ resolve: (_: any) => Promise<any>;
929
+ actions?: Record<string, SpaceActionFactory>;
930
+ };
931
+ user: {
932
+ schema?: z__default.ZodType<object>;
933
+ resolve: (_: any) => Promise<any>;
934
+ };
935
+ }
936
+ interface PlatformProviderConfig<Def extends AnyPlatformDef = AnyPlatformDef> {
937
+ readonly __def: Def;
938
+ readonly __definition: AnyPlatformDef;
939
+ readonly __name: Def["name"];
940
+ readonly __tag: "PlatformProviderConfig";
941
+ readonly config: unknown;
942
+ }
943
+ interface MatchesPlatformName<Name extends string> extends Fn {
944
+ return: this["arg0"] extends PlatformProviderConfig<infer Def> ? Def["name"] extends Name ? true : false : false;
945
+ }
946
+ interface ExtractDef extends Fn {
947
+ return: this["arg0"] extends PlatformProviderConfig<infer Def> ? Def : never;
948
+ }
949
+ interface ExtractCustomEventNames extends Fn {
950
+ return: this["arg0"] extends AnyPlatformDef ? this["arg0"]["events"] extends Record<string, unknown> ? Exclude<keyof this["arg0"]["events"], symbol | number> : never : never;
951
+ }
952
+ interface ToCustomEventVariant<EventName extends string> extends Fn {
953
+ return: this["arg0"] extends PlatformProviderConfig<infer Def> ? Def["events"] extends Record<string, unknown> ? EventName extends keyof Def["events"] ? InferEventPayload<Def["events"][EventName]> & {
954
+ platform: Def["name"];
955
+ } : never : never : never;
956
+ }
957
+ type HasProvider<Providers extends PlatformProviderConfig[], Name extends string> = Pipe<Providers, [Tuples.Some<MatchesPlatformName<Name>>]>;
958
+ type AllCustomEventNames<Providers extends PlatformProviderConfig[]> = Pipe<Providers, [
959
+ Tuples.Map<ExtractDef>,
960
+ Tuples.Map<ExtractCustomEventNames>,
961
+ Tuples.ToUnion
962
+ ]>;
963
+ type UnifiedCustomEvent<Providers extends PlatformProviderConfig[], EventName extends string> = Pipe<Providers, [
964
+ Tuples.Map<ToCustomEventVariant<EventName>>,
965
+ Tuples.ToUnion
966
+ ]>;
967
+ type CustomEventStreams<Providers extends PlatformProviderConfig[]> = {
968
+ [K in Exclude<AllCustomEventNames<Providers>, ReservedNames> & string]: AsyncIterable<UnifiedCustomEvent<Providers, K>>;
969
+ };
970
+ type ResolvedSpaceOf<Def extends AnyPlatformDef> = AwaitedReturn<Def["space"]["resolve"]>;
971
+ type SchemaSpaceOf<Def extends AnyPlatformDef> = InferOptionalSchema<Def["space"]["schema"]>;
972
+ type ResolvedUserOf<Def extends AnyPlatformDef> = AwaitedReturn<Def["user"]["resolve"]>;
973
+ type SpaceShapeOf<Def extends AnyPlatformDef> = [SchemaSpaceOf<Def>] extends [
974
+ never
975
+ ] ? ResolvedSpaceOf<Def> : SchemaSpaceOf<Def>;
976
+ type SpaceParamsInputOf<Def extends AnyPlatformDef> = InputSchema<Def["space"]["params"]>;
977
+ type SpaceUserLike<Def extends AnyPlatformDef> = PlatformUser<Def> | string;
978
+ type SpaceArrayArgs<Def extends AnyPlatformDef> = [
979
+ SpaceParamsInputOf<Def>
980
+ ] extends [never] ? [users: SpaceUserLike<Def>[]] : [users: SpaceUserLike<Def>[]] | [users: SpaceUserLike<Def>[], params: SpaceParamsInputOf<Def>] | [params: SpaceParamsInputOf<Def>];
981
+ type SpaceVarargArgs<Def extends AnyPlatformDef> = [
982
+ SpaceParamsInputOf<Def>
983
+ ] extends [never] ? SpaceUserLike<Def>[] : SpaceUserLike<Def>[] | [...SpaceUserLike<Def>[], SpaceParamsInputOf<Def>];
984
+ type SpaceArgs<Def extends AnyPlatformDef> = SpaceArrayArgs<Def> | SpaceVarargArgs<Def>;
985
+ type SpaceActionFactories<Def extends AnyPlatformDef> = Def["space"] extends {
986
+ actions?: infer A;
987
+ } ? A extends Record<string, SpaceActionFactory> ? A : Record<string, never> : Record<string, never>;
988
+ type SpaceActionMethods<Def extends AnyPlatformDef> = {
989
+ [K in Exclude<keyof SpaceActionFactories<Def>, keyof Space>]: (...args: Parameters<SpaceActionFactories<Def>[K]>) => Promise<OutboundMessage | undefined>;
990
+ };
991
+ type PlatformSpace<Def extends AnyPlatformDef> = Omit<SpaceShapeOf<Def>, keyof Space | keyof SpaceActionMethods<Def>> & Space & SpaceActionMethods<Def>;
992
+ type PlatformMessage<Def extends AnyPlatformDef> = Omit<SchemaInfer<Def["message"]>, keyof Message> & Message<Def["name"], PlatformUser<Def>, PlatformSpace<Def>>;
993
+ type InboundPlatformMessage<Def extends AnyPlatformDef> = Omit<SchemaInfer<Def["message"]>, keyof InboundMessage> & InboundMessage<Def["name"], PlatformUser<Def>, PlatformSpace<Def>>;
994
+ type PlatformUser<Def extends AnyPlatformDef> = Omit<ResolvedUserOf<Def>, keyof User> & User;
995
+ type PlatformInstance<Def extends AnyPlatformDef> = {
996
+ readonly messages: AsyncIterable<[
997
+ PlatformSpace<Def>,
998
+ InboundPlatformMessage<Def>
999
+ ]>;
1000
+ space(...args: SpaceArgs<Def>): Promise<PlatformSpace<Def>>;
1001
+ user(userID: string): Promise<PlatformUser<Def>>;
1002
+ } & CustomEventInstanceProperties<Def>;
1003
+ type CustomEventInstanceProperties<Def extends AnyPlatformDef> = Def["events"] extends Record<string, unknown> ? {
1004
+ [K in Exclude<keyof Def["events"], symbol | number> as K extends ReservedNames ? never : K]: AsyncIterable<InferEventPayload<NonNullable<Def["events"]>[K]>>;
1005
+ } : Record<never, never>;
1006
+ interface PlatformRuntime {
1007
+ client: unknown;
1008
+ config: unknown;
1009
+ definition: AnyPlatformDef;
1010
+ store: Store;
1011
+ subscribeMessages: () => ManagedStream<[Space, InboundMessage]>;
1012
+ }
1013
+ interface SpectrumLike<Providers extends PlatformProviderConfig[] = PlatformProviderConfig[]> {
1014
+ readonly __internal: {
1015
+ platforms: Map<string, PlatformRuntime>;
1016
+ };
1017
+ readonly __providers: Providers;
1018
+ }
1019
+ interface Platform<Def extends AnyPlatformDef> {
1020
+ config(...args: Record<string, never> extends z__default.input<Def["config"]> ? [config?: z__default.input<Def["config"]>] : [config: z__default.input<Def["config"]>]): PlatformProviderConfig<Def>;
1021
+ is(input: Message): input is PlatformMessage<Def>;
1022
+ is(input: Space): input is PlatformSpace<Def>;
1023
+ is(input: unknown): input is PlatformMessage<Def> | PlatformSpace<Def>;
1024
+ <Providers extends PlatformProviderConfig[]>(spectrum: SpectrumLike<Providers>): HasProvider<Providers, Def["name"]> extends true ? PlatformInstance<Def> : never;
1025
+ (space: Space): PlatformSpace<Def>;
1026
+ (message: Message): PlatformMessage<Def>;
1027
+ }
1028
+
1029
+ export { type AnyPlatformDef as A, type Broadcaster as B, type ContentBuilder as C, type EventProducer as E, type InboundMessage as I, type Message as M, type OutboundMessage as O, type Platform as P, type SchemaMessage as S, type User as U, type PlatformDef as a, type ContentInput as b, type Content as c, type ProviderMessage as d, type CreateClientContext as e, type Store as f, type PlatformProviderConfig as g, type SpectrumLike as h, type CustomEventStreams as i, type Space as j, type InboundPlatformMessage as k, type ManagedStream as l, type PlatformInstance as m, type PlatformMessage as n, type PlatformRuntime as o, type PlatformSpace as p, type PlatformUser as q, broadcast as r, mergeStreams as s, stream as t };