@distilled.cloud/turso 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.map +1 -1
- 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 -7
- 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/turso.d.ts +143 -6
- package/lib/services/turso.d.ts.map +1 -1
- package/lib/services/turso.js +202 -279
- package/lib/services/turso.js.map +1 -1
- package/package.json +13 -11
- package/src/credentials.ts +3 -4
- package/src/errors.ts +5 -9
- package/src/index.ts +1 -5
- package/src/protocol.ts +28 -41
- package/src/retry.ts +2 -8
- package/src/services/turso.ts +554 -509
- 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 -38
- package/lib/response-validation.test.js.map +0 -1
- package/src/response-validation.test.ts +0 -53
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"response-validation.test.d.ts","sourceRoot":"","sources":["../src/response-validation.test.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAyClD,eAAO,MAAM,oBAAoB,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,YAAY,CAAC,GACvE,IAAI,GACJ,KAAY,CAAC"}
|
|
@@ -1,38 +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 * as Layer from "effect/Layer";
|
|
5
|
-
import * as Redacted from "effect/Redacted";
|
|
6
|
-
import { Credentials, DEFAULT_API_BASE_URL } from "./credentials.js";
|
|
7
|
-
import { TursoParseError } from "./errors.js";
|
|
8
|
-
import * as Retry from "./retry.js";
|
|
9
|
-
import { validateAPIToken } from "./services/turso.js";
|
|
10
|
-
const TestCredentials = Layer.succeed(Credentials, Effect.succeed({
|
|
11
|
-
apiKey: Redacted.make("test"),
|
|
12
|
-
apiBaseUrl: DEFAULT_API_BASE_URL,
|
|
13
|
-
}));
|
|
14
|
-
// validateAPIToken declares `{ exp?: number }` (all optional).
|
|
15
|
-
const run = (body) => runValidationModes(validateAPIToken({}).pipe(Retry.none, Effect.provide(TestCredentials)), { body });
|
|
16
|
-
describe("Turso response validation", () => {
|
|
17
|
-
test("a matching body succeeds unchanged in both modes", async () => {
|
|
18
|
-
const body = { exp: 1_900_000_000 };
|
|
19
|
-
const { lenient, strict } = await run(JSON.stringify(body));
|
|
20
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: body });
|
|
21
|
-
expect(strict).toMatchObject({ _tag: "Success", success: body });
|
|
22
|
-
});
|
|
23
|
-
test("a member with the wrong type: lenient returns it, strict fails", async () => {
|
|
24
|
-
const body = { exp: "never" };
|
|
25
|
-
const { lenient, strict } = await run(JSON.stringify(body));
|
|
26
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: body });
|
|
27
|
-
expect(strict._tag).toBe("Failure");
|
|
28
|
-
expect(strict.failure).toBeInstanceOf(TursoParseError);
|
|
29
|
-
});
|
|
30
|
-
test("a non-JSON body: lenient returns the text, strict fails", async () => {
|
|
31
|
-
const { lenient, strict } = await run("not json");
|
|
32
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: "not json" });
|
|
33
|
-
expect(strict.failure).toBeInstanceOf(TursoParseError);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
// TursoParseError is part of every operation's declared error type.
|
|
37
|
-
export const parseErrorIsDeclared = true;
|
|
38
|
-
//# sourceMappingURL=response-validation.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"response-validation.test.js","sourceRoot":"","sources":["../src/response-validation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CACnC,WAAW,EACX,MAAM,CAAC,OAAO,CAAC;IACb,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;IAC7B,UAAU,EAAE,oBAAoB;CACjC,CAAC,CACH,CAAC;AAEF,+DAA+D;AAC/D,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAC3B,kBAAkB,CAChB,gBAAgB,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,EACtE,EAAE,IAAI,EAAE,CACT,CAAC;AAEJ,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,IAAI,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAA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OAAO,CAAC,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAErB,IAAI,CAAC"}
|
|
@@ -1,53 +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 * as Layer from "effect/Layer";
|
|
5
|
-
import * as Redacted from "effect/Redacted";
|
|
6
|
-
import { Credentials, DEFAULT_API_BASE_URL } from "./credentials.ts";
|
|
7
|
-
import { TursoParseError } from "./errors.ts";
|
|
8
|
-
import * as Retry from "./retry.ts";
|
|
9
|
-
import { validateAPIToken } from "./services/turso.ts";
|
|
10
|
-
import type { TursoOpError } from "./protocol.ts";
|
|
11
|
-
|
|
12
|
-
const TestCredentials = Layer.succeed(
|
|
13
|
-
Credentials,
|
|
14
|
-
Effect.succeed({
|
|
15
|
-
apiKey: Redacted.make("test"),
|
|
16
|
-
apiBaseUrl: DEFAULT_API_BASE_URL,
|
|
17
|
-
}),
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
// validateAPIToken declares `{ exp?: number }` (all optional).
|
|
21
|
-
const run = (body: string) =>
|
|
22
|
-
runValidationModes(
|
|
23
|
-
validateAPIToken({}).pipe(Retry.none, Effect.provide(TestCredentials)),
|
|
24
|
-
{ body },
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
describe("Turso response validation", () => {
|
|
28
|
-
test("a matching body succeeds unchanged in both modes", async () => {
|
|
29
|
-
const body = { exp: 1_900_000_000 };
|
|
30
|
-
const { lenient, strict } = await run(JSON.stringify(body));
|
|
31
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: body });
|
|
32
|
-
expect(strict).toMatchObject({ _tag: "Success", success: body });
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test("a member with the wrong type: lenient returns it, strict fails", async () => {
|
|
36
|
-
const body = { exp: "never" };
|
|
37
|
-
const { lenient, strict } = await run(JSON.stringify(body));
|
|
38
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: body });
|
|
39
|
-
expect(strict._tag).toBe("Failure");
|
|
40
|
-
expect((strict as any).failure).toBeInstanceOf(TursoParseError);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test("a non-JSON body: lenient returns the text, strict fails", async () => {
|
|
44
|
-
const { lenient, strict } = await run("not json");
|
|
45
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: "not json" });
|
|
46
|
-
expect((strict as any).failure).toBeInstanceOf(TursoParseError);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// TursoParseError is part of every operation's declared error type.
|
|
51
|
-
export const parseErrorIsDeclared: [TursoParseError] extends [TursoOpError]
|
|
52
|
-
? true
|
|
53
|
-
: false = true;
|