@distilled.cloud/xata 1.0.0-rc.13 → 1.0.0-rc.15

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.
@@ -1,4 +0,0 @@
1
- import { XataParseError } from "./errors.ts";
2
- import type { XataOpError } from "./protocol.ts";
3
- export declare const parseErrorIsDeclared: [XataParseError] extends [XataOpError] ? true : false;
4
- //# sourceMappingURL=response-validation.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"response-validation.test.d.ts","sourceRoot":"","sources":["../src/response-validation.test.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAmCjD,eAAO,MAAM,oBAAoB,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,WAAW,CAAC,GACrE,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 { fromApiKey } from "./credentials.js";
5
- import { XataParseError } from "./errors.js";
6
- import * as Retry from "./retry.js";
7
- import { listRegions } from "./services/xata.js";
8
- // listRegions declares `{ regions: Region[] }`.
9
- const run = (body) => runValidationModes(listRegions({ organizationID: "org-1" }).pipe(Retry.none, Effect.provide(fromApiKey({ apiKey: "test" }))), { body });
10
- describe("Xata response validation", () => {
11
- test("a matching body succeeds unchanged in both modes", async () => {
12
- const body = { regions: [] };
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(XataParseError);
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(XataParseError);
27
- });
28
- });
29
- // XataParseError 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","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,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,gDAAgD;AAChD,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAC3B,kBAAkB,CAChB,WAAW,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,CAC3C,KAAK,CAAC,IAAI,EACV,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAC/C,EACD,EAAE,IAAI,EAAE,CACT,CAAC;AAEJ,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,IAAI,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAClE,MAAM,IAAI,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QAC7B,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC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loud/core/testing";
3
- import * as Effect from "effect/Effect";
4
- import { fromApiKey } from "./credentials.ts";
5
- import { XataParseError } from "./errors.ts";
6
- import * as Retry from "./retry.ts";
7
- import { listRegions } from "./services/xata.ts";
8
- import type { XataOpError } from "./protocol.ts";
9
-
10
- // listRegions declares `{ regions: Region[] }`.
11
- const run = (body: string) =>
12
- runValidationModes(
13
- listRegions({ organizationID: "org-1" }).pipe(
14
- Retry.none,
15
- Effect.provide(fromApiKey({ apiKey: "test" })),
16
- ),
17
- { body },
18
- );
19
-
20
- describe("Xata response validation", () => {
21
- test("a matching body succeeds unchanged in both modes", async () => {
22
- const body = { regions: [] };
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(XataParseError);
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(XataParseError);
39
- });
40
- });
41
-
42
- // XataParseError is part of every operation's declared error type.
43
- export const parseErrorIsDeclared: [XataParseError] extends [XataOpError]
44
- ? true
45
- : false = true;