dfx 0.0.4 → 0.0.5

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,7 @@
1
+ import * as T from "@effect-ts/core/Effect";
2
+ export declare type RESTError = {
3
+ _tag: "http";
4
+ code: number;
5
+ body?: unknown;
6
+ };
7
+ export declare type Response<T> = T.IO<RESTError, T>;
@@ -0,0 +1,7 @@
1
+ import { GatewayPayload, Heartbeat, Identify, RequestGuildMember, Resume, UpdatePresence, UpdateVoiceState } from "../types";
2
+ export declare const heartbeat: (d: Heartbeat) => GatewayPayload;
3
+ export declare const identify: (d: Identify) => GatewayPayload;
4
+ export declare const resume: (d: Resume) => GatewayPayload;
5
+ export declare const requestGuildMembers: (d: RequestGuildMember) => GatewayPayload;
6
+ export declare const voiceStateUpdate: (d: UpdateVoiceState) => GatewayPayload;
7
+ export declare const presenceUpdate: (d: UpdatePresence) => GatewayPayload;
@@ -0,0 +1,7 @@
1
+ import * as S from "@effect-ts/core/Effect/Experimental/Stream";
2
+ import * as H from "@effect-ts/core/Effect/Hub";
3
+ import * as R from "@effect-ts/core/Effect/Ref";
4
+ import * as O from "@effect-ts/core/Option";
5
+ import * as DWS from "../DiscordWS";
6
+ import { GatewayPayload } from "../types";
7
+ export declare const fromHub: (hub: H.Hub<GatewayPayload<any>>, seqRef: R.Ref<O.Option<number>>) => S.Stream<import("@effect-ts/system/Has").Has<import("@effect-ts/system/Clock").Clock>, never, DWS.Message>;
@@ -0,0 +1,16 @@
1
+ import * as S from "@effect-ts/core/Effect/Experimental/Stream";
2
+ import * as H from "@effect-ts/core/Effect/Hub";
3
+ import * as R from "@effect-ts/core/Effect/Ref";
4
+ import * as O from "@effect-ts/core/Option";
5
+ import { GatewayPayload, ReadyEvent, UpdatePresence } from "../types";
6
+ export interface Options {
7
+ token: string;
8
+ intents: number;
9
+ shard: [number, number];
10
+ presence?: UpdatePresence;
11
+ }
12
+ export interface Requirements {
13
+ latestReady: R.Ref<O.Option<ReadyEvent>>;
14
+ latestSequence: R.Ref<O.Option<number>>;
15
+ }
16
+ export declare const fromHub: (hub: H.Hub<GatewayPayload<any>>, { latestReady, latestSequence, ...opts }: Options & Requirements) => S.Stream<unknown, never, GatewayPayload<any>>;
@@ -0,0 +1,32 @@
1
+ import * as T from "@effect-ts/core/Effect";
2
+ import * as L from "@effect-ts/core/Effect/Layer";
3
+ import * as S from "@effect-ts/core/Effect/Experimental/Stream";
4
+ import * as H from "@effect-ts/core/Effect/Hub";
5
+ import * as M from "@effect-ts/core/Effect/Managed";
6
+ import * as DWS from "../DiscordWS";
7
+ import { GatewayEvent, GatewayPayload } from "../types";
8
+ import * as Identify from "./identify";
9
+ declare const makeService: () => {
10
+ readonly _tag: "DiscordShardService";
11
+ readonly make: (opts: Identify.Options) => M.Managed<unknown, never, {
12
+ readonly run: T.RIO<import("@effect-ts/system/Has").Has<DWS.DiscordWS> & import("@effect-ts/system/Has").Has<import("../WS").WS> & import("@effect-ts/system/Clock").HasClock & import("@effect-ts/system/Has").Has<import("../Log").Log> & import("@effect-ts/system/Has").Has<import("@effect-ts/system/Clock").Clock>, void>;
13
+ readonly raw: H.Hub<GatewayPayload<any>>;
14
+ readonly dispatch: H.Hub<GatewayPayload<GatewayEvent>>;
15
+ readonly fromDispatch: <K extends keyof import("../types").GatewayEvents>(event: K) => S.Stream<unknown, never, import("../types").GatewayEvents[K]>;
16
+ readonly send: (p: GatewayPayload) => T.Effect<unknown, never, boolean>;
17
+ readonly reconnect: () => T.Effect<unknown, never, boolean>;
18
+ }>;
19
+ };
20
+ export interface DiscordShard extends ReturnType<typeof makeService> {
21
+ }
22
+ export declare const DiscordShard: import("@effect-ts/system/Has").Tag<DiscordShard>;
23
+ export declare const LiveDiscordShard: L.Layer<{}, never, import("@effect-ts/system/Has").Has<DiscordShard>>;
24
+ export declare const make: (opts: Identify.Options) => M.Managed<import("@effect-ts/system/Has").Has<DiscordShard>, never, {
25
+ readonly run: T.RIO<import("@effect-ts/system/Has").Has<DWS.DiscordWS> & import("@effect-ts/system/Has").Has<import("../WS").WS> & import("@effect-ts/system/Clock").HasClock & import("@effect-ts/system/Has").Has<import("../Log").Log> & import("@effect-ts/system/Has").Has<import("@effect-ts/system/Clock").Clock>, void>;
26
+ readonly raw: H.Hub<GatewayPayload<any>>;
27
+ readonly dispatch: H.Hub<GatewayPayload<GatewayEvent>>;
28
+ readonly fromDispatch: <K extends keyof import("../types").GatewayEvents>(event: K) => S.Stream<unknown, never, import("../types").GatewayEvents[K]>;
29
+ readonly send: (p: GatewayPayload) => T.Effect<unknown, never, boolean>;
30
+ readonly reconnect: () => T.Effect<unknown, never, boolean>;
31
+ }>;
32
+ export {};
@@ -0,0 +1,7 @@
1
+ import * as S from "@effect-ts/core/Effect/Experimental/Stream";
2
+ import * as H from "@effect-ts/core/Effect/Hub";
3
+ import * as R from "@effect-ts/core/Effect/Ref";
4
+ import * as O from "@effect-ts/core/Option";
5
+ import { Message } from "../DiscordWS";
6
+ import { GatewayPayload, ReadyEvent } from "../types";
7
+ export declare const fromHub: (hub: H.Hub<GatewayPayload<any>>, latestReady: R.Ref<O.Option<ReadyEvent>>) => S.Stream<unknown, never, Message>;
@@ -0,0 +1,9 @@
1
+ import * as T from "@effect-ts/core/Effect";
2
+ import * as S from "@effect-ts/core/Effect/Experimental/Stream";
3
+ import * as H from "@effect-ts/core/Effect/Hub";
4
+ import * as R from "@effect-ts/core/Effect/Ref";
5
+ import * as O from "@effect-ts/core/Option";
6
+ import { GatewayEvent, GatewayEvents, GatewayOpcode, GatewayPayload } from "../types";
7
+ export declare const opCode: (hub: H.Hub<GatewayPayload<any>>) => <T = any>(code: GatewayOpcode) => S.UIO<GatewayPayload<T>>;
8
+ export declare const latest: <T>(f: (p: GatewayPayload) => O.Option<T>) => T.Effect<unknown, never, readonly [R.Ref<O.Option<T>>, <R, E>(self: S.Stream<R, E, GatewayPayload<any>>) => S.Stream<R, E, GatewayPayload<any>>]>;
9
+ export declare const fromDispatch: (hub: H.Hub<GatewayPayload<GatewayEvent>>) => <K extends keyof GatewayEvents>(event: K) => S.Stream<unknown, never, GatewayEvents[K]>;
@@ -0,0 +1,32 @@
1
+ /// <reference types="node" />
2
+ import * as T from "@effect-ts/core/Effect";
3
+ import * as S from "@effect-ts/core/Effect/Experimental/Stream";
4
+ import { RawData } from "ws";
5
+ import { GatewayPayload } from "../types";
6
+ import * as WS from "../WS";
7
+ export declare type Message = GatewayPayload | WS.Reconnect;
8
+ export interface OpenOpts {
9
+ url?: string;
10
+ version?: number;
11
+ encoding?: Encoding;
12
+ outgoing: WS.OutboundStream<Message>;
13
+ }
14
+ export interface Encoding {
15
+ type: "json" | "etf";
16
+ encode: (p: GatewayPayload) => string | Buffer | ArrayBuffer;
17
+ decode: (p: RawData) => GatewayPayload;
18
+ }
19
+ export declare const jsonEncoding: Encoding;
20
+ declare const openImpl: ({ url, version, encoding, outgoing, }: OpenOpts) => S.Stream<import("@effect-ts/system/Has").Has<WS.WS> & import("@effect-ts/system/Clock").HasClock & import("@effect-ts/system/Has").Has<import("../Log").Log>, unknown, GatewayPayload<any>>;
21
+ export declare type Connection = ReturnType<typeof openImpl>;
22
+ declare const service: {
23
+ readonly _tag: "DiscordWSService";
24
+ readonly open: ({ url, version, encoding, outgoing, }: OpenOpts) => S.Stream<import("@effect-ts/system/Has").Has<WS.WS> & import("@effect-ts/system/Clock").HasClock & import("@effect-ts/system/Has").Has<import("../Log").Log>, unknown, GatewayPayload<any>>;
25
+ };
26
+ declare type Service = typeof service;
27
+ export interface DiscordWS extends Service {
28
+ }
29
+ export declare const DiscordWS: import("@effect-ts/system/Has").Tag<DiscordWS>;
30
+ export declare const LiveDiscordWS: import("@effect-ts/system/Layer").Layer<unknown, never, import("@effect-ts/system/Has").Has<DiscordWS>>;
31
+ export declare const open: (opts: OpenOpts) => T.Effect<import("@effect-ts/system/Has").Has<DiscordWS>, never, S.Stream<import("@effect-ts/system/Has").Has<WS.WS> & import("@effect-ts/system/Clock").HasClock & import("@effect-ts/system/Has").Has<import("../Log").Log>, unknown, GatewayPayload<any>>>;
32
+ export {};
package/Log/index.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import * as T from "@effect-ts/core/Effect";
2
+ declare const service: {
3
+ readonly _tag: "LogService";
4
+ readonly log: (...args: any[]) => T.UIO<void>;
5
+ };
6
+ declare type Service = typeof service;
7
+ export interface Log extends Service {
8
+ }
9
+ export declare const Log: import("@effect-ts/system/Has").Tag<Log>;
10
+ export declare const LiveLog: import("@effect-ts/system/Layer").Layer<unknown, never, import("@effect-ts/system/Has").Has<Log>>;
11
+ export declare const log: (...args: any[]) => T.Effect<import("@effect-ts/system/Has").Has<Log>, never, void>;
12
+ export {};
package/WS/index.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ /// <reference types="node" />
2
+ import * as T from "@effect-ts/core/Effect";
3
+ import * as S from "@effect-ts/core/Effect/Experimental/Stream";
4
+ import type { _A } from "@effect-ts/core/Utils";
5
+ import { HasClock } from "@effect-ts/system/Clock";
6
+ import * as Ws from "ws";
7
+ export declare type WsError = {
8
+ _tag: "close";
9
+ code: number;
10
+ reason: string;
11
+ } | {
12
+ _tag: "error";
13
+ cause: unknown;
14
+ } | {
15
+ _tag: "write";
16
+ cause: unknown;
17
+ };
18
+ export declare type WebSocketStream<T = Ws.RawData> = S.Stream<HasClock, WsError, T>;
19
+ export declare const Reconnect: unique symbol;
20
+ export declare type Reconnect = typeof Reconnect;
21
+ export declare type Message = string | Buffer | ArrayBuffer | Reconnect;
22
+ export declare type OutboundStream<T = Message> = S.UIO<T>;
23
+ declare const makeWS: T.Effect<unknown, never, {
24
+ readonly _tag: "WSService";
25
+ readonly open: (url: string, out: OutboundStream<Message>, options?: Ws.ClientOptions | undefined) => WebSocketStream<Ws.RawData>;
26
+ }>;
27
+ export interface WS extends _A<typeof makeWS> {
28
+ }
29
+ export declare const WS: import("@effect-ts/system/Has").Tag<WS>;
30
+ export declare const LiveWS: import("@effect-ts/system/Layer").Layer<unknown, never, import("@effect-ts/system/Has").Has<WS>>;
31
+ export declare const open: (url: string, out: OutboundStream<Message>, options?: Ws.ClientOptions | undefined) => T.Effect<import("@effect-ts/system/Has").Has<WS>, never, WebSocketStream<Ws.RawData>>;
32
+ export {};
package/bot.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/mod.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import * as Shard from "./DiscordShard";
2
+ import * as WS from "./WS";
3
+ export declare const DefaultEnv: import("@effect-ts/system/Layer").Layer<unknown, never, import("@effect-ts/system/Has").Has<WS.WS> & import("@effect-ts/system/Has").Has<import("./DiscordWS").DiscordWS> & import("@effect-ts/system/Has").Has<Shard.DiscordShard> & import("@effect-ts/system/Has").Has<import("./Log").Log>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dfx",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Effect-TS discord library",
5
5
  "main": "mod.js",
6
6
  "author": "Tim Smart <tim.smart@arisechurch.com>",
@@ -13,6 +13,7 @@
13
13
  },
14
14
  "files": [
15
15
  "**/*.ts",
16
+ "**/*.d.ts",
16
17
  "**/*.js",
17
18
  "**/*.js.map",
18
19
  "!discord-api-docs/**/*"