spectrum-ts 1.2.1 → 1.4.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/dist/{chunk-K3CTEGCZ.js → chunk-66GJ45ZZ.js} +1 -1
- package/dist/{chunk-I7EKZS5C.js → chunk-B4MHPWPZ.js} +1 -1
- package/dist/{chunk-UQPIWAHH.js → chunk-LH4YEBG3.js} +30 -17
- package/dist/index.d.ts +16 -12
- package/dist/index.js +79 -15
- package/dist/providers/imessage/index.d.ts +20 -3
- package/dist/providers/imessage/index.js +263 -156
- package/dist/providers/terminal/index.d.ts +89 -4
- package/dist/providers/terminal/index.js +30 -40
- package/dist/providers/whatsapp-business/index.d.ts +2 -1
- package/dist/providers/whatsapp-business/index.js +26 -36
- package/dist/{types-Dvp0I86h.d.ts → types-BcCLW2VO.d.ts} +58 -20
- package/package.json +1 -1
|
@@ -1,7 +1,91 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e as Platform, d as PlatformDef, P as ProviderMessage, S as Store, M as Message } from '../../types-BcCLW2VO.js';
|
|
2
|
+
import { ChildProcess } from 'node:child_process';
|
|
2
3
|
import z__default from 'zod';
|
|
4
|
+
import { Socket } from 'node:net';
|
|
3
5
|
import 'hotscript';
|
|
4
6
|
|
|
7
|
+
type ProtocolContent = {
|
|
8
|
+
type: "text";
|
|
9
|
+
text: string;
|
|
10
|
+
} | {
|
|
11
|
+
type: "attachment";
|
|
12
|
+
name: string;
|
|
13
|
+
mimeType: string;
|
|
14
|
+
size?: number;
|
|
15
|
+
bytes?: string;
|
|
16
|
+
path?: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: "voice";
|
|
19
|
+
name?: string;
|
|
20
|
+
mimeType: string;
|
|
21
|
+
size?: number;
|
|
22
|
+
bytes?: string;
|
|
23
|
+
path?: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: "contact";
|
|
26
|
+
name?: {
|
|
27
|
+
formatted?: string;
|
|
28
|
+
first?: string;
|
|
29
|
+
last?: string;
|
|
30
|
+
};
|
|
31
|
+
vcard?: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: "custom";
|
|
34
|
+
raw: unknown;
|
|
35
|
+
};
|
|
36
|
+
interface ProtocolMessageNotification {
|
|
37
|
+
content: ProtocolContent;
|
|
38
|
+
id: string;
|
|
39
|
+
replyTo?: {
|
|
40
|
+
messageId: string;
|
|
41
|
+
};
|
|
42
|
+
senderId: string;
|
|
43
|
+
spaceId: string;
|
|
44
|
+
timestamp: string;
|
|
45
|
+
}
|
|
46
|
+
interface ProtocolReactionNotification {
|
|
47
|
+
messageId: string;
|
|
48
|
+
reaction: string;
|
|
49
|
+
senderId: string;
|
|
50
|
+
spaceId: string;
|
|
51
|
+
timestamp: string;
|
|
52
|
+
}
|
|
53
|
+
declare class RpcSession {
|
|
54
|
+
private readonly decoder;
|
|
55
|
+
private nextId;
|
|
56
|
+
private readonly pending;
|
|
57
|
+
private onNotify;
|
|
58
|
+
private onClose;
|
|
59
|
+
private closed;
|
|
60
|
+
private readonly socket;
|
|
61
|
+
constructor(socket: Socket);
|
|
62
|
+
handleNotifications(h: (method: string, params: unknown) => void): void;
|
|
63
|
+
onClosed(h: () => void): void;
|
|
64
|
+
request<T = unknown>(method: string, params?: unknown, timeoutMs?: number): Promise<T>;
|
|
65
|
+
notify(method: string, params?: unknown): void;
|
|
66
|
+
close(): void;
|
|
67
|
+
private handle;
|
|
68
|
+
private shutdown;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface ConsoleHijack {
|
|
72
|
+
restore: () => void;
|
|
73
|
+
}
|
|
74
|
+
type InboundEvent = {
|
|
75
|
+
kind: "message";
|
|
76
|
+
value: ProtocolMessageNotification;
|
|
77
|
+
} | {
|
|
78
|
+
kind: "reaction";
|
|
79
|
+
value: ProtocolReactionNotification;
|
|
80
|
+
};
|
|
81
|
+
interface TerminalClient {
|
|
82
|
+
events: AsyncIterable<InboundEvent>;
|
|
83
|
+
hijack: ConsoleHijack;
|
|
84
|
+
knownChats: Set<string>;
|
|
85
|
+
nextChatIndex: number;
|
|
86
|
+
proc: ChildProcess;
|
|
87
|
+
session: RpcSession;
|
|
88
|
+
}
|
|
5
89
|
declare const terminal: Platform<PlatformDef<"terminal", z__default.ZodObject<{
|
|
6
90
|
commands: z__default.ZodOptional<z__default.ZodArray<z__default.ZodObject<{
|
|
7
91
|
name: z__default.ZodString;
|
|
@@ -9,7 +93,7 @@ declare const terminal: Platform<PlatformDef<"terminal", z__default.ZodObject<{
|
|
|
9
93
|
}, z__default.core.$strip>>>;
|
|
10
94
|
}, z__default.core.$strip>, z__default.ZodType<object, unknown, z__default.core.$ZodTypeInternals<object, unknown>> | undefined, z__default.ZodType<object, unknown, z__default.core.$ZodTypeInternals<object, unknown>> | undefined, z__default.ZodObject<{
|
|
11
95
|
id: z__default.ZodOptional<z__default.ZodString>;
|
|
12
|
-
}, z__default.core.$strip>,
|
|
96
|
+
}, z__default.core.$strip>, TerminalClient, {
|
|
13
97
|
id: string;
|
|
14
98
|
}, {
|
|
15
99
|
id: string;
|
|
@@ -26,14 +110,15 @@ declare const terminal: Platform<PlatformDef<"terminal", z__default.ZodObject<{
|
|
|
26
110
|
messageId: string;
|
|
27
111
|
} | undefined;
|
|
28
112
|
}>, {
|
|
29
|
-
messages(
|
|
30
|
-
client:
|
|
113
|
+
messages({ client }: {
|
|
114
|
+
client: TerminalClient;
|
|
31
115
|
config: {
|
|
32
116
|
commands?: {
|
|
33
117
|
name: string;
|
|
34
118
|
description?: string | undefined;
|
|
35
119
|
}[] | undefined;
|
|
36
120
|
};
|
|
121
|
+
store: Store;
|
|
37
122
|
}): AsyncGenerator<{
|
|
38
123
|
replyTo?: {
|
|
39
124
|
messageId: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
asVoice
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-B4MHPWPZ.js";
|
|
4
4
|
import {
|
|
5
5
|
UnsupportedError,
|
|
6
6
|
asAttachment,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
fromVCard,
|
|
11
11
|
reactionSchema,
|
|
12
12
|
toVCard
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-LH4YEBG3.js";
|
|
14
14
|
|
|
15
15
|
// src/providers/terminal/index.ts
|
|
16
16
|
import { spawn } from "child_process";
|
|
@@ -746,42 +746,43 @@ var terminal = definePlatform("terminal", {
|
|
|
746
746
|
replyTo: z.object({ messageId: z.string() }).optional()
|
|
747
747
|
})
|
|
748
748
|
},
|
|
749
|
-
user: {
|
|
750
|
-
resolve: async ({ input }) => ({
|
|
751
|
-
id: input.userID
|
|
752
|
-
})
|
|
753
|
-
},
|
|
754
|
-
space: {
|
|
755
|
-
params: z.object({ id: z.string().optional() }),
|
|
756
|
-
resolve: async (ctx) => {
|
|
757
|
-
const client = ctx.client;
|
|
758
|
-
const id = ctx.input.params?.id ?? generateChatId(client);
|
|
759
|
-
client.knownChats.add(id);
|
|
760
|
-
await client.session.request("ensureSpace", { id });
|
|
761
|
-
return { id };
|
|
762
|
-
}
|
|
763
|
-
},
|
|
764
749
|
lifecycle: {
|
|
765
750
|
createClient: async ({ config }) => {
|
|
766
751
|
return await spawnClient({ commands: config.commands });
|
|
767
752
|
},
|
|
768
753
|
destroyClient: async ({ client }) => {
|
|
769
|
-
|
|
770
|
-
c.hijack.restore();
|
|
754
|
+
client.hijack.restore();
|
|
771
755
|
try {
|
|
772
|
-
await
|
|
756
|
+
await client.session.request(
|
|
757
|
+
"shutdown",
|
|
758
|
+
void 0,
|
|
759
|
+
SHUTDOWN_TIMEOUT_MS
|
|
760
|
+
);
|
|
773
761
|
} catch {
|
|
774
762
|
}
|
|
775
|
-
|
|
763
|
+
client.session.close();
|
|
776
764
|
try {
|
|
777
|
-
|
|
765
|
+
client.proc.kill("SIGTERM");
|
|
778
766
|
} catch {
|
|
779
767
|
}
|
|
780
768
|
}
|
|
781
769
|
},
|
|
770
|
+
user: {
|
|
771
|
+
resolve: async ({ input }) => ({
|
|
772
|
+
id: input.userID
|
|
773
|
+
})
|
|
774
|
+
},
|
|
775
|
+
space: {
|
|
776
|
+
params: z.object({ id: z.string().optional() }),
|
|
777
|
+
resolve: async ({ client, input }) => {
|
|
778
|
+
const id = input.params?.id ?? generateChatId(client);
|
|
779
|
+
client.knownChats.add(id);
|
|
780
|
+
await client.session.request("ensureSpace", { id });
|
|
781
|
+
return { id };
|
|
782
|
+
}
|
|
783
|
+
},
|
|
782
784
|
events: {
|
|
783
|
-
async *messages(
|
|
784
|
-
const client = ctx.client;
|
|
785
|
+
async *messages({ client }) {
|
|
785
786
|
for await (const evt of client.events) {
|
|
786
787
|
if (evt.kind === "message") {
|
|
787
788
|
const msg = evt.value;
|
|
@@ -812,37 +813,26 @@ var terminal = definePlatform("terminal", {
|
|
|
812
813
|
},
|
|
813
814
|
actions: {
|
|
814
815
|
send: async ({ client, content, space }) => {
|
|
815
|
-
const c = client;
|
|
816
816
|
const proto = await spectrumToProtocol(content);
|
|
817
|
-
const result = await
|
|
818
|
-
"send",
|
|
819
|
-
{ spaceId: space.id, content: proto }
|
|
820
|
-
);
|
|
817
|
+
const result = await client.session.request("send", { spaceId: space.id, content: proto });
|
|
821
818
|
return buildOutboundRecord(result, content, space.id);
|
|
822
819
|
},
|
|
823
820
|
startTyping: async ({ client, space }) => {
|
|
824
|
-
|
|
825
|
-
await c.session.request("startTyping", { spaceId: space.id });
|
|
821
|
+
await client.session.request("startTyping", { spaceId: space.id });
|
|
826
822
|
},
|
|
827
823
|
stopTyping: async ({ client, space }) => {
|
|
828
|
-
|
|
829
|
-
await c.session.request("stopTyping", { spaceId: space.id });
|
|
824
|
+
await client.session.request("stopTyping", { spaceId: space.id });
|
|
830
825
|
},
|
|
831
826
|
reactToMessage: async ({ client, space, target, reaction }) => {
|
|
832
|
-
|
|
833
|
-
await c.session.request("reactToMessage", {
|
|
827
|
+
await client.session.request("reactToMessage", {
|
|
834
828
|
spaceId: space.id,
|
|
835
829
|
messageId: target.id,
|
|
836
830
|
reaction
|
|
837
831
|
});
|
|
838
832
|
},
|
|
839
833
|
replyToMessage: async ({ client, space, messageId, content }) => {
|
|
840
|
-
const c = client;
|
|
841
834
|
const proto = await spectrumToProtocol(content);
|
|
842
|
-
const result = await
|
|
843
|
-
"replyToMessage",
|
|
844
|
-
{ spaceId: space.id, messageId, content: proto }
|
|
845
|
-
);
|
|
835
|
+
const result = await client.session.request("replyToMessage", { spaceId: space.id, messageId, content: proto });
|
|
846
836
|
return buildOutboundRecord(result, content, space.id);
|
|
847
837
|
}
|
|
848
838
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as SchemaMessage, e as Platform, d as PlatformDef, P as ProviderMessage, S as Store, k as ManagedStream } from '../../types-BcCLW2VO.js';
|
|
2
2
|
import { WhatsAppClient } from '@photon-ai/whatsapp-business';
|
|
3
3
|
import * as z from 'zod';
|
|
4
4
|
import z__default from 'zod';
|
|
@@ -34,6 +34,7 @@ declare const whatsappBusiness: Platform<PlatformDef<"WhatsApp Business", z.ZodU
|
|
|
34
34
|
phoneNumberId: string;
|
|
35
35
|
appSecret?: string | undefined;
|
|
36
36
|
} | Record<string, never>;
|
|
37
|
+
store: Store;
|
|
37
38
|
}) => ManagedStream<WhatsAppMessage>;
|
|
38
39
|
}>> & Readonly<Record<never, never>>;
|
|
39
40
|
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
asReaction,
|
|
13
13
|
asText,
|
|
14
14
|
definePlatform
|
|
15
|
-
} from "../../chunk-
|
|
15
|
+
} from "../../chunk-LH4YEBG3.js";
|
|
16
16
|
|
|
17
17
|
// src/providers/whatsapp-business/index.ts
|
|
18
18
|
import { createClient as createClient2 } from "@photon-ai/whatsapp-business";
|
|
@@ -778,29 +778,6 @@ var spaceSchema = z.object({
|
|
|
778
778
|
// src/providers/whatsapp-business/index.ts
|
|
779
779
|
var whatsappBusiness = definePlatform("WhatsApp Business", {
|
|
780
780
|
config: configSchema,
|
|
781
|
-
user: {
|
|
782
|
-
resolve: async ({ input }) => ({ id: input.userID })
|
|
783
|
-
},
|
|
784
|
-
space: {
|
|
785
|
-
schema: spaceSchema,
|
|
786
|
-
resolve: async ({ input }) => {
|
|
787
|
-
if (input.users.length === 0) {
|
|
788
|
-
throw new Error("WhatsApp space creation requires at least one user");
|
|
789
|
-
}
|
|
790
|
-
if (input.users.length > 1) {
|
|
791
|
-
throw UnsupportedError.action(
|
|
792
|
-
"createSpace",
|
|
793
|
-
"WhatsApp Business",
|
|
794
|
-
"only 1:1 conversations are supported"
|
|
795
|
-
);
|
|
796
|
-
}
|
|
797
|
-
const user = input.users[0];
|
|
798
|
-
if (!user) {
|
|
799
|
-
throw new Error("WhatsApp space creation requires a user");
|
|
800
|
-
}
|
|
801
|
-
return { id: user.id };
|
|
802
|
-
}
|
|
803
|
-
},
|
|
804
781
|
lifecycle: {
|
|
805
782
|
createClient: async ({
|
|
806
783
|
config,
|
|
@@ -828,6 +805,29 @@ var whatsappBusiness = definePlatform("WhatsApp Business", {
|
|
|
828
805
|
await Promise.all(client.map((c) => c.close()));
|
|
829
806
|
}
|
|
830
807
|
},
|
|
808
|
+
user: {
|
|
809
|
+
resolve: async ({ input }) => ({ id: input.userID })
|
|
810
|
+
},
|
|
811
|
+
space: {
|
|
812
|
+
schema: spaceSchema,
|
|
813
|
+
resolve: async ({ input }) => {
|
|
814
|
+
if (input.users.length === 0) {
|
|
815
|
+
throw new Error("WhatsApp space creation requires at least one user");
|
|
816
|
+
}
|
|
817
|
+
if (input.users.length > 1) {
|
|
818
|
+
throw UnsupportedError.action(
|
|
819
|
+
"createSpace",
|
|
820
|
+
"WhatsApp Business",
|
|
821
|
+
"only 1:1 conversations are supported"
|
|
822
|
+
);
|
|
823
|
+
}
|
|
824
|
+
const user = input.users[0];
|
|
825
|
+
if (!user) {
|
|
826
|
+
throw new Error("WhatsApp space creation requires a user");
|
|
827
|
+
}
|
|
828
|
+
return { id: user.id };
|
|
829
|
+
}
|
|
830
|
+
},
|
|
831
831
|
events: {
|
|
832
832
|
messages: ({ client }) => messages(client)
|
|
833
833
|
},
|
|
@@ -836,20 +836,10 @@ var whatsappBusiness = definePlatform("WhatsApp Business", {
|
|
|
836
836
|
return await send(client, space.id, content);
|
|
837
837
|
},
|
|
838
838
|
reactToMessage: async ({ space, target, reaction, client }) => {
|
|
839
|
-
await reactToMessage(
|
|
840
|
-
client,
|
|
841
|
-
space.id,
|
|
842
|
-
target.id,
|
|
843
|
-
reaction
|
|
844
|
-
);
|
|
839
|
+
await reactToMessage(client, space.id, target.id, reaction);
|
|
845
840
|
},
|
|
846
841
|
replyToMessage: async ({ space, messageId, content, client }) => {
|
|
847
|
-
return await replyToMessage(
|
|
848
|
-
client,
|
|
849
|
-
space.id,
|
|
850
|
-
messageId,
|
|
851
|
-
content
|
|
852
|
-
);
|
|
842
|
+
return await replyToMessage(client, space.id, messageId, content);
|
|
853
843
|
}
|
|
854
844
|
}
|
|
855
845
|
});
|
|
@@ -180,6 +180,29 @@ interface OutboundMessage<TPlatform extends string = string, TSender extends Use
|
|
|
180
180
|
}
|
|
181
181
|
type Message<TPlatform extends string = string, TSender extends User = User, TSpace extends Space = Space> = InboundMessage<TPlatform, TSender, TSpace> | OutboundMessage<TPlatform, TSender, TSpace>;
|
|
182
182
|
|
|
183
|
+
/**
|
|
184
|
+
* A small per-platform key-value bag, modeled after Swift's `UserDefaults`.
|
|
185
|
+
* Untyped writes; typed reads return `undefined` on missing key OR type
|
|
186
|
+
* mismatch (no throws). In-memory only.
|
|
187
|
+
*
|
|
188
|
+
* SDK-internal: reachable from inside `definePlatform` callbacks via the
|
|
189
|
+
* `store` field on lifecycle/action/event ctx. Not exposed on the public
|
|
190
|
+
* SpectrumInstance or platform narrower.
|
|
191
|
+
*/
|
|
192
|
+
interface Store {
|
|
193
|
+
array<T = unknown>(key: string): T[] | undefined;
|
|
194
|
+
bool(key: string): boolean | undefined;
|
|
195
|
+
clear(): void;
|
|
196
|
+
delete(key: string): boolean;
|
|
197
|
+
get(key: string): unknown;
|
|
198
|
+
has(key: string): boolean;
|
|
199
|
+
keys(): string[];
|
|
200
|
+
number(key: string): number | undefined;
|
|
201
|
+
object<T = Record<string, unknown>>(key: string): T | undefined;
|
|
202
|
+
set(key: string, value: unknown): void;
|
|
203
|
+
string(key: string): string | undefined;
|
|
204
|
+
}
|
|
205
|
+
|
|
183
206
|
interface ManagedStream<T> extends AsyncIterable<T> {
|
|
184
207
|
close(): Promise<void>;
|
|
185
208
|
}
|
|
@@ -195,7 +218,8 @@ declare function broadcast<T>(source: ManagedStream<T>): Broadcaster<T>;
|
|
|
195
218
|
type ResolvedSpace = Pick<Space, "id">;
|
|
196
219
|
type SpaceRef = Pick<Space, "id" | "__platform">;
|
|
197
220
|
type ResolvedUser = Pick<User, "id">;
|
|
198
|
-
type AwaitedReturn<T> = T extends (...args: never[]) =>
|
|
221
|
+
type AwaitedReturn<T> = T extends (...args: never[]) => infer R ? Awaited<R> : never;
|
|
222
|
+
type NoInferClient<T> = [T][T extends unknown ? 0 : never];
|
|
199
223
|
type SchemaInfer<T> = T extends {
|
|
200
224
|
schema?: infer S extends z__default.ZodType<object>;
|
|
201
225
|
} ? z__default.infer<S> : Record<never, never>;
|
|
@@ -203,8 +227,9 @@ type InferSchema<TSchema> = TSchema extends z__default.ZodType<object> ? z__defa
|
|
|
203
227
|
type InferOptionalSchema<TSchema> = TSchema extends z__default.ZodType<object> ? z__default.infer<TSchema> : never;
|
|
204
228
|
type InputSchema<TSchema> = TSchema extends z__default.ZodType<object> ? z__default.input<TSchema> : never;
|
|
205
229
|
type EventProducer<TPayload = unknown, TClient = unknown, TConfig = unknown> = (ctx: {
|
|
206
|
-
client: TClient
|
|
230
|
+
client: NoInferClient<TClient>;
|
|
207
231
|
config: TConfig;
|
|
232
|
+
store: Store;
|
|
208
233
|
}) => AsyncIterable<TPayload>;
|
|
209
234
|
type ProviderMessage<TSender extends ResolvedUser = ResolvedUser, TSpace extends ResolvedSpace = ResolvedSpace, TExtra extends object = Record<never, never>> = {
|
|
210
235
|
id: string;
|
|
@@ -239,6 +264,12 @@ type MergeSchema<TSchema extends z__default.ZodType | undefined, TBase extends o
|
|
|
239
264
|
type SchemaMessage<TUserSchema extends z__default.ZodType | undefined = undefined, TSpaceSchema extends z__default.ZodType | undefined = undefined> = ProviderMessage<MergeSchema<TUserSchema, ResolvedUser>, MergeSchema<TSpaceSchema, ResolvedSpace>>;
|
|
240
265
|
type InferEventPayload<T> = T extends (ctx: never) => AsyncIterable<infer P> ? P : never;
|
|
241
266
|
type ReservedNames = "stop" | "send" | "__internal" | "__providers";
|
|
267
|
+
interface CreateClientContext<_ConfigSchema extends z__default.ZodType<object>> {
|
|
268
|
+
config: z__default.infer<_ConfigSchema>;
|
|
269
|
+
projectId: string | undefined;
|
|
270
|
+
projectSecret: string | undefined;
|
|
271
|
+
store: Store;
|
|
272
|
+
}
|
|
242
273
|
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 {
|
|
243
274
|
messages: EventProducer<_MessageType, _Client, z__default.infer<_ConfigSchema>>;
|
|
244
275
|
} = {
|
|
@@ -248,58 +279,62 @@ interface PlatformDef<_Name extends string = string, _ConfigSchema extends z__de
|
|
|
248
279
|
send: (_: {
|
|
249
280
|
space: _ResolvedSpace & SpaceRef;
|
|
250
281
|
content: Content;
|
|
251
|
-
client: _Client
|
|
282
|
+
client: NoInferClient<_Client>;
|
|
252
283
|
config: z__default.infer<_ConfigSchema>;
|
|
284
|
+
store: Store;
|
|
253
285
|
}) => Promise<ProviderMessageRecord>;
|
|
254
286
|
startTyping?: (_: {
|
|
255
287
|
space: _ResolvedSpace & SpaceRef;
|
|
256
|
-
client: _Client
|
|
288
|
+
client: NoInferClient<_Client>;
|
|
257
289
|
config: z__default.infer<_ConfigSchema>;
|
|
290
|
+
store: Store;
|
|
258
291
|
}) => Promise<void>;
|
|
259
292
|
stopTyping?: (_: {
|
|
260
293
|
space: _ResolvedSpace & SpaceRef;
|
|
261
|
-
client: _Client
|
|
294
|
+
client: NoInferClient<_Client>;
|
|
262
295
|
config: z__default.infer<_ConfigSchema>;
|
|
296
|
+
store: Store;
|
|
263
297
|
}) => Promise<void>;
|
|
264
298
|
reactToMessage?: (_: {
|
|
265
299
|
space: _ResolvedSpace & SpaceRef;
|
|
266
300
|
target: _MessageType;
|
|
267
301
|
reaction: string;
|
|
268
|
-
client: _Client
|
|
302
|
+
client: NoInferClient<_Client>;
|
|
269
303
|
config: z__default.infer<_ConfigSchema>;
|
|
304
|
+
store: Store;
|
|
270
305
|
}) => Promise<void>;
|
|
271
306
|
replyToMessage?: (_: {
|
|
272
307
|
space: _ResolvedSpace & SpaceRef;
|
|
273
308
|
messageId: string;
|
|
274
309
|
target: _MessageType;
|
|
275
310
|
content: Content;
|
|
276
|
-
client: _Client
|
|
311
|
+
client: NoInferClient<_Client>;
|
|
277
312
|
config: z__default.infer<_ConfigSchema>;
|
|
313
|
+
store: Store;
|
|
278
314
|
}) => Promise<ProviderMessageRecord>;
|
|
279
315
|
editMessage?: (_: {
|
|
280
316
|
space: _ResolvedSpace & SpaceRef;
|
|
281
317
|
messageId: string;
|
|
282
318
|
content: Content;
|
|
283
|
-
client: _Client
|
|
319
|
+
client: NoInferClient<_Client>;
|
|
284
320
|
config: z__default.infer<_ConfigSchema>;
|
|
321
|
+
store: Store;
|
|
285
322
|
}) => Promise<void>;
|
|
286
323
|
getMessage?: (_: {
|
|
287
324
|
space: _ResolvedSpace & SpaceRef;
|
|
288
325
|
messageId: string;
|
|
289
|
-
client: _Client
|
|
326
|
+
client: NoInferClient<_Client>;
|
|
290
327
|
config: z__default.infer<_ConfigSchema>;
|
|
328
|
+
store: Store;
|
|
291
329
|
}) => Promise<_MessageType | undefined>;
|
|
292
330
|
};
|
|
293
331
|
config: _ConfigSchema;
|
|
294
332
|
events: _Events;
|
|
295
333
|
lifecycle: {
|
|
296
|
-
createClient: (ctx:
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}) => Promise<_Client>;
|
|
301
|
-
destroyClient: (ctx: {
|
|
302
|
-
client: _Client;
|
|
334
|
+
createClient: (ctx: CreateClientContext<_ConfigSchema>) => Promise<_Client>;
|
|
335
|
+
destroyClient?: (ctx: {
|
|
336
|
+
client: NoInferClient<_Client>;
|
|
337
|
+
store: Store;
|
|
303
338
|
}) => Promise<void>;
|
|
304
339
|
};
|
|
305
340
|
message?: {
|
|
@@ -316,8 +351,9 @@ interface PlatformDef<_Name extends string = string, _ConfigSchema extends z__de
|
|
|
316
351
|
})[];
|
|
317
352
|
params?: _SpaceParamsSchema extends z__default.ZodType<object> ? z__default.infer<_SpaceParamsSchema> : undefined;
|
|
318
353
|
};
|
|
319
|
-
client: _Client
|
|
354
|
+
client: NoInferClient<_Client>;
|
|
320
355
|
config: z__default.infer<_ConfigSchema>;
|
|
356
|
+
store: Store;
|
|
321
357
|
}) => Promise<_ResolvedSpace>;
|
|
322
358
|
};
|
|
323
359
|
user: {
|
|
@@ -326,8 +362,9 @@ interface PlatformDef<_Name extends string = string, _ConfigSchema extends z__de
|
|
|
326
362
|
input: {
|
|
327
363
|
userID: string;
|
|
328
364
|
};
|
|
329
|
-
client: _Client
|
|
365
|
+
client: NoInferClient<_Client>;
|
|
330
366
|
config: z__default.infer<_ConfigSchema>;
|
|
367
|
+
store: Store;
|
|
331
368
|
}) => Promise<_ResolvedUser>;
|
|
332
369
|
};
|
|
333
370
|
}
|
|
@@ -348,7 +385,7 @@ interface AnyPlatformDef {
|
|
|
348
385
|
};
|
|
349
386
|
lifecycle: {
|
|
350
387
|
createClient: (ctx: any) => Promise<any>;
|
|
351
|
-
destroyClient
|
|
388
|
+
destroyClient?: (ctx: any) => Promise<void>;
|
|
352
389
|
};
|
|
353
390
|
message?: {
|
|
354
391
|
schema?: z__default.ZodType<object>;
|
|
@@ -431,6 +468,7 @@ interface PlatformRuntime {
|
|
|
431
468
|
client: unknown;
|
|
432
469
|
config: unknown;
|
|
433
470
|
definition: AnyPlatformDef;
|
|
471
|
+
store: Store;
|
|
434
472
|
subscribeMessages: () => ManagedStream<[Space, InboundMessage]>;
|
|
435
473
|
}
|
|
436
474
|
interface SpectrumLike<Providers extends PlatformProviderConfig[] = PlatformProviderConfig[]> {
|
|
@@ -449,4 +487,4 @@ interface Platform<Def extends AnyPlatformDef> {
|
|
|
449
487
|
(message: Message): PlatformMessage<Def>;
|
|
450
488
|
}
|
|
451
489
|
|
|
452
|
-
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 ProviderMessage as P, type
|
|
490
|
+
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 ProviderMessage as P, type Store as S, type User as U, type ContentInput as a, type Content as b, type CreateClientContext as c, type PlatformDef as d, type Platform as e, type PlatformProviderConfig as f, type SpectrumLike as g, type CustomEventStreams as h, type Space as i, type InboundPlatformMessage as j, type ManagedStream as k, type PlatformInstance as l, type PlatformMessage as m, type PlatformRuntime as n, type PlatformSpace as o, type PlatformUser as p, type SchemaMessage as q, broadcast as r, mergeStreams as s, stream as t };
|