@distilled.cloud/discord 1.0.0-rc.13 → 1.0.0-rc.14
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/lib/credentials.d.ts +2 -2
- package/lib/credentials.d.ts.map +1 -1
- package/lib/credentials.js +6 -8
- package/lib/credentials.js.map +1 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/protocol.d.ts +3 -3
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +3 -5
- package/lib/protocol.js.map +1 -1
- package/lib/retry.d.ts +1 -1
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -1
- package/lib/retry.js.map +1 -1
- package/lib/services/discord.d.ts +74 -12
- package/lib/services/discord.d.ts.map +1 -1
- package/lib/services/discord.js +770 -2414
- package/lib/services/discord.js.map +1 -1
- package/package.json +12 -10
- package/src/credentials.ts +13 -19
- package/src/errors.ts +1 -2
- package/src/index.ts +1 -5
- package/src/protocol.ts +29 -43
- package/src/retry.ts +4 -9
- package/src/services/discord.ts +4816 -7347
- package/lib/response-validation.test.d.ts +0 -4
- package/lib/response-validation.test.d.ts.map +0 -1
- package/lib/response-validation.test.js +0 -31
- package/lib/response-validation.test.js.map +0 -1
- package/src/response-validation.test.ts +0 -45
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"response-validation.test.d.ts","sourceRoot":"","sources":["../src/response-validation.test.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAmCpD,eAAO,MAAM,oBAAoB,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,cAAc,CAAC,GAC3E,IAAI,GACJ,KAAY,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { runValidationModes } from "@distilled.cloud/core/testing";
|
|
3
|
-
import * as Effect from "effect/Effect";
|
|
4
|
-
import { credentials } from "./credentials.js";
|
|
5
|
-
import { DiscordParseError } from "./errors.js";
|
|
6
|
-
import * as Retry from "./retry.js";
|
|
7
|
-
import { getGateway } from "./services/discord.js";
|
|
8
|
-
// getGateway declares `{ url: string }`.
|
|
9
|
-
const run = (body) => runValidationModes(getGateway({}).pipe(Retry.none, Effect.provide(credentials({ token: "test" }))), { body });
|
|
10
|
-
describe("Discord response validation", () => {
|
|
11
|
-
test("a matching body succeeds unchanged in both modes", async () => {
|
|
12
|
-
const body = { url: "wss://gateway.discord.gg" };
|
|
13
|
-
const { lenient, strict } = await run(JSON.stringify(body));
|
|
14
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: body });
|
|
15
|
-
expect(strict).toMatchObject({ _tag: "Success", success: body });
|
|
16
|
-
});
|
|
17
|
-
test("a body missing required members: lenient returns it, strict fails", async () => {
|
|
18
|
-
const { lenient, strict } = await run("{}");
|
|
19
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: {} });
|
|
20
|
-
expect(strict._tag).toBe("Failure");
|
|
21
|
-
expect(strict.failure).toBeInstanceOf(DiscordParseError);
|
|
22
|
-
});
|
|
23
|
-
test("a non-JSON body: lenient returns the text, strict fails", async () => {
|
|
24
|
-
const { lenient, strict } = await run("not json");
|
|
25
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: "not json" });
|
|
26
|
-
expect(strict.failure).toBeInstanceOf(DiscordParseError);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
// DiscordParseError is part of every operation's declared error type.
|
|
30
|
-
export const parseErrorIsDeclared = true;
|
|
31
|
-
//# sourceMappingURL=response-validation.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"response-validation.test.js","sour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EAAE,KAAK,IAAI,EAAE;QACnF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;QAChE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACpC,MAAM,CAAE,MAAc,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,yDAAyD,EAAE,KAAK,IAAI,EAAE;QACzE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,CAAC;QAClD,MAAM,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;QACxE,MAAM,CAAE,MAAc,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,sEAAsE;AACtE,MAAM,CAAC,MAAM,oBAAoB,GAErB,IAAI,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { runValidationModes } from "@distilled.cloud/core/testing";
|
|
3
|
-
import * as Effect from "effect/Effect";
|
|
4
|
-
import { credentials } from "./credentials.ts";
|
|
5
|
-
import { DiscordParseError } from "./errors.ts";
|
|
6
|
-
import * as Retry from "./retry.ts";
|
|
7
|
-
import { getGateway } from "./services/discord.ts";
|
|
8
|
-
import type { DiscordOpError } from "./protocol.ts";
|
|
9
|
-
|
|
10
|
-
// getGateway declares `{ url: string }`.
|
|
11
|
-
const run = (body: string) =>
|
|
12
|
-
runValidationModes(
|
|
13
|
-
getGateway({}).pipe(
|
|
14
|
-
Retry.none,
|
|
15
|
-
Effect.provide(credentials({ token: "test" })),
|
|
16
|
-
),
|
|
17
|
-
{ body },
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
describe("Discord response validation", () => {
|
|
21
|
-
test("a matching body succeeds unchanged in both modes", async () => {
|
|
22
|
-
const body = { url: "wss://gateway.discord.gg" };
|
|
23
|
-
const { lenient, strict } = await run(JSON.stringify(body));
|
|
24
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: body });
|
|
25
|
-
expect(strict).toMatchObject({ _tag: "Success", success: body });
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test("a body missing required members: lenient returns it, strict fails", async () => {
|
|
29
|
-
const { lenient, strict } = await run("{}");
|
|
30
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: {} });
|
|
31
|
-
expect(strict._tag).toBe("Failure");
|
|
32
|
-
expect((strict as any).failure).toBeInstanceOf(DiscordParseError);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test("a non-JSON body: lenient returns the text, strict fails", async () => {
|
|
36
|
-
const { lenient, strict } = await run("not json");
|
|
37
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: "not json" });
|
|
38
|
-
expect((strict as any).failure).toBeInstanceOf(DiscordParseError);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// DiscordParseError is part of every operation's declared error type.
|
|
43
|
-
export const parseErrorIsDeclared: [DiscordParseError] extends [DiscordOpError]
|
|
44
|
-
? true
|
|
45
|
-
: false = true;
|