@distilled.cloud/axiom 1.0.0-rc.11 → 1.0.0-rc.13

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/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # @distilled.cloud/axiom
2
+
3
+ Effect-native SDK for [axiom](https://www.npmjs.com/package/@distilled.cloud/axiom).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @distilled.cloud/axiom effect
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ ```ts
14
+ import { Effect, Layer } from "effect";
15
+ import * as FetchHttpClient from "effect/http/FetchHttpClient";
16
+ import * as Axiom from "@distilled.cloud/axiom";
17
+
18
+ const program = Effect.gen(function* () {
19
+ const result = yield* Axiom.v2.getDatasets({});
20
+ return result;
21
+ });
22
+
23
+ const Live = Layer.mergeAll(
24
+ FetchHttpClient.layer,
25
+ Axiom.CredentialsFromEnv,
26
+ Axiom.AxiomProtocol,
27
+ );
28
+
29
+ program.pipe(Effect.provide(Live), Effect.runPromise);
30
+ ```
31
+
32
+ ## Auth
33
+
34
+ Required: `AXIOM_API_KEY`, `AXIOM_ORG_ID`, `AXIOM_TOKEN`. Optional: `AXIOM_URL`.
package/lib/index.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * OpenAPI specs in specs/docs/restapi/versions). Everything else in this
7
7
  * folder is hand-written.
8
8
  *
9
- * The v2 control-plane API lives under `Services.v2`; the v1 edge APIs are
9
+ * The v2 control-plane API lives under `v2`; the v1 edge APIs are
10
10
  * also available under their own subpath imports:
11
11
  *
12
12
  * @example
@@ -15,7 +15,7 @@
15
15
  * import * as EdgeIngest from "@distilled.cloud/axiom/edge-ingest";
16
16
  * import * as EdgeQuery from "@distilled.cloud/axiom/edge-query";
17
17
  *
18
- * const datasets = yield* Axiom.Services.v2.getDatasets({});
18
+ * const datasets = yield* Axiom.v2.getDatasets({});
19
19
  * ```
20
20
  */
21
21
  export * from "./credentials.ts";
@@ -23,7 +23,7 @@ export * from "./errors.ts";
23
23
  export * as T from "./traits.ts";
24
24
  export { AxiomProtocol, stripNulls, type AxiomOpError, type AxiomOpContext, } from "./protocol.ts";
25
25
  export * as Retry from "./retry.ts";
26
- export * as Services from "./services/index.ts";
26
+ export * from "./services/index.ts";
27
27
  export * from "./services/v2.ts";
28
28
  export { BadRequest, Conflict, Forbidden, NotFound, UnprocessableEntity, } from "./services/v2.ts";
29
29
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,aAAa,EACb,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAKhD,cAAc,kBAAkB,CAAC;AACjC,OAAO,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,mBAAmB,GACpB,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,aAAa,EACb,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,cAAc,qBAAqB,CAAC;AAKpC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,mBAAmB,GACpB,MAAM,kBAAkB,CAAC"}
package/lib/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * OpenAPI specs in specs/docs/restapi/versions). Everything else in this
7
7
  * folder is hand-written.
8
8
  *
9
- * The v2 control-plane API lives under `Services.v2`; the v1 edge APIs are
9
+ * The v2 control-plane API lives under `v2`; the v1 edge APIs are
10
10
  * also available under their own subpath imports:
11
11
  *
12
12
  * @example
@@ -15,7 +15,7 @@
15
15
  * import * as EdgeIngest from "@distilled.cloud/axiom/edge-ingest";
16
16
  * import * as EdgeQuery from "@distilled.cloud/axiom/edge-query";
17
17
  *
18
- * const datasets = yield* Axiom.Services.v2.getDatasets({});
18
+ * const datasets = yield* Axiom.v2.getDatasets({});
19
19
  * ```
20
20
  */
21
21
  export * from "./credentials.js";
@@ -23,7 +23,7 @@ export * from "./errors.js";
23
23
  export * as T from "./traits.js";
24
24
  export { AxiomProtocol, stripNulls, } from "./protocol.js";
25
25
  export * as Retry from "./retry.js";
26
- export * as Services from "./services/index.js";
26
+ export * from "./services/index.js";
27
27
  // v0-parity surface: the v2 control-plane operations live on the package
28
28
  // root (edge-ingest / edge-query stay behind their subpath exports).
29
29
  // The service-local typed error classes shadow the same-named shared ones
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,aAAa,EACb,UAAU,GAGX,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,yEAAyE;AACzE,qEAAqE;AACrE,0EAA0E;AAC1E,uEAAuE;AACvE,cAAc,kBAAkB,CAAC;AACjC,OAAO,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,mBAAmB,GACpB,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,aAAa,EACb,UAAU,GAGX,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,yEAAyE;AACzE,qEAAqE;AACrE,0EAA0E;AAC1E,uEAAuE;AACvE,cAAc,kBAAkB,CAAC;AACjC,OAAO,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,mBAAmB,GACpB,MAAM,kBAAkB,CAAC"}
package/lib/protocol.d.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  import type * as Layer from "effect/Layer";
2
- import type * as HttpClient from "effect/unstable/http/HttpClient";
3
- import type * as HttpClientError from "effect/unstable/http/HttpClientError";
2
+ import type * as HttpClient from "effect/http/HttpClient";
3
+ import type * as HttpClientError from "effect/http/HttpClientError";
4
4
  import type * as API from "@distilled.cloud/core/api";
5
5
  import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
6
6
  import { Credentials } from "./credentials.ts";
7
- import { UnknownAxiomError } from "./errors.ts";
7
+ import { UnknownAxiomError, AxiomParseError } from "./errors.ts";
8
8
  /**
9
9
  * Error channel shared by every generated Axiom operation. Generated service
10
10
  * files annotate operations with `API.OperationMethod<I, O, AxiomOpError,
11
11
  * AxiomOpContext>` explicitly so the compiler never infers these back out of
12
12
  * the schema generics.
13
13
  */
14
- export type AxiomOpError = InstanceType<(typeof API_ERRORS)[number]> | UnknownAxiomError | ConfigError | HttpClientError.HttpClientError;
14
+ export type AxiomOpError = InstanceType<(typeof API_ERRORS)[number]> | UnknownAxiomError | ConfigError | HttpClientError.HttpClientError | AxiomParseError;
15
15
  /** Context (requirements) shared by every generated Axiom operation. */
16
16
  export type AxiomOpContext = Credentials | HttpClient.HttpClient;
17
17
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,KAAK,UAAU,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,KAAK,eAAe,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,KAAK,GAAG,MAAM,2BAA2B,CAAC;AAKtD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GACpB,YAAY,CAAC,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GACzC,iBAAiB,GACjB,WAAW,GACX,eAAe,CAAC,eAAe,CAAC;AAEpC,wEAAwE;AACxE,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAEjE;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,UAAW,OAAO,KAAG,OAW3C,CAAC;AAkBF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAqBhD,CAAC"}
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,KAAK,eAAe,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,KAAK,GAAG,MAAM,2BAA2B,CAAC;AAKtD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GACpB,YAAY,CAAC,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GACzC,iBAAiB,GACjB,WAAW,GACX,eAAe,CAAC,eAAe,GAC/B,eAAe,CAAC;AAEpB,wEAAwE;AACxE,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAEjE;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,UAAW,OAAO,KAAG,OAW3C,CAAC;AAkBF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAsBhD,CAAC"}
package/lib/protocol.js CHANGED
@@ -24,7 +24,7 @@ import * as Effect from "effect/Effect";
24
24
  import * as Redacted from "effect/Redacted";
25
25
  import { makeRestProtocol, } from "@distilled.cloud/core/protocol-rest";
26
26
  import { Credentials } from "./credentials.js";
27
- import { UnknownAxiomError } from "./errors.js";
27
+ import { UnknownAxiomError, AxiomParseError } from "./errors.js";
28
28
  /**
29
29
  * Axiom's backend (Go) serializes nil slices and omitted optional fields as
30
30
  * JSON `null`. The generated output schemas model these as optional members
@@ -82,5 +82,6 @@ export const AxiomProtocol = makeRestProtocol({
82
82
  message,
83
83
  body,
84
84
  }),
85
+ parseError: ({ body, cause }) => new AxiomParseError({ body, cause }),
85
86
  });
86
87
  //# sourceMappingURL=protocol.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":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;KACL,CAAC;IACJ,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;CACtE,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { AxiomParseError } from "./errors.ts";
2
+ import type { AxiomOpError } from "./protocol.ts";
3
+ export declare const parseErrorIsDeclared: [AxiomParseError] extends [AxiomOpError] ? true : false;
4
+ //# sourceMappingURL=response-validation.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-validation.test.d.ts","sourceRoot":"","sources":["../src/response-validation.test.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAoClD,eAAO,MAAM,oBAAoB,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,YAAY,CAAC,GACvE,IAAI,GACJ,KAAY,CAAC"}
@@ -0,0 +1,32 @@
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 { AxiomParseError } from "./errors.js";
6
+ import * as Retry from "./retry.js";
7
+ import { getCurrentUser } from "./services/v2.js";
8
+ // getCurrentUser declares `{ email: string; id: string; name: string; role?: … }`.
9
+ const run = (body) => runValidationModes(getCurrentUser({}).pipe(Retry.none, Effect.provide(fromApiKey({ apiKey: "test" }))), { body });
10
+ describe("Axiom response validation", () => {
11
+ test("a matching body succeeds unchanged in both modes", async () => {
12
+ const body = { email: "a@example.com", id: "u1", name: "Ada" };
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 body = { id: "u1" };
19
+ const { lenient, strict } = await run(JSON.stringify(body));
20
+ expect(lenient).toMatchObject({ _tag: "Success", success: body });
21
+ expect(strict._tag).toBe("Failure");
22
+ expect(strict.failure).toBeInstanceOf(AxiomParseError);
23
+ });
24
+ test("a non-JSON body: lenient returns the text, strict fails", async () => {
25
+ const { lenient, strict } = await run("not json");
26
+ expect(lenient).toMatchObject({ _tag: "Success", success: "not json" });
27
+ expect(strict.failure).toBeInstanceOf(AxiomParseError);
28
+ });
29
+ });
30
+ // AxiomParseError is part of every operation's declared error type.
31
+ export const parseErrorIsDeclared = true;
32
+ //# sourceMappingURL=response-validation.test.js.map
@@ -0,0 +1 @@
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,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,mFAAmF;AACnF,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAC3B,kBAAkB,CAChB,cAAc,CAAC,EAAE,CAAC,CAAC,IAAI,CACrB,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,2BAA2B,EAAE,GAAG,EAAE;IACzC,IAAI,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAClE,MAAM,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AAC;QACxE,MAAM,CAAE,MAAc,CAAC,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/axiom",
3
- "version": "1.0.0-rc.11",
3
+ "version": "1.0.0-rc.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/alchemy-run/distilled",
@@ -70,15 +70,15 @@
70
70
  }
71
71
  },
72
72
  "dependencies": {
73
- "@distilled.cloud/core": "1.0.0-rc.11"
73
+ "@distilled.cloud/core": "1.0.0-rc.13"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/bun": "1.3.14",
77
77
  "@types/node": "26.2.0",
78
- "@effect/platform-bun": ">=4.0.0-rc.115 || >=4.0.0"
78
+ "@effect/platform-bun": "^4.0.0"
79
79
  },
80
80
  "peerDependencies": {
81
- "effect": ">=4.0.0-rc.115 || >=4.0.0"
81
+ "effect": "^4.0.0"
82
82
  },
83
83
  "scripts": {
84
84
  "build": "tsc -b",
package/src/index.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * OpenAPI specs in specs/docs/restapi/versions). Everything else in this
7
7
  * folder is hand-written.
8
8
  *
9
- * The v2 control-plane API lives under `Services.v2`; the v1 edge APIs are
9
+ * The v2 control-plane API lives under `v2`; the v1 edge APIs are
10
10
  * also available under their own subpath imports:
11
11
  *
12
12
  * @example
@@ -15,7 +15,7 @@
15
15
  * import * as EdgeIngest from "@distilled.cloud/axiom/edge-ingest";
16
16
  * import * as EdgeQuery from "@distilled.cloud/axiom/edge-query";
17
17
  *
18
- * const datasets = yield* Axiom.Services.v2.getDatasets({});
18
+ * const datasets = yield* Axiom.v2.getDatasets({});
19
19
  * ```
20
20
  */
21
21
  export * from "./credentials.ts";
@@ -28,7 +28,7 @@ export {
28
28
  type AxiomOpContext,
29
29
  } from "./protocol.ts";
30
30
  export * as Retry from "./retry.ts";
31
- export * as Services from "./services/index.ts";
31
+ export * from "./services/index.ts";
32
32
  // v0-parity surface: the v2 control-plane operations live on the package
33
33
  // root (edge-ingest / edge-query stay behind their subpath exports).
34
34
  // The service-local typed error classes shadow the same-named shared ones
package/src/protocol.ts CHANGED
@@ -23,8 +23,8 @@
23
23
  import * as Effect from "effect/Effect";
24
24
  import type * as Layer from "effect/Layer";
25
25
  import * as Redacted from "effect/Redacted";
26
- import type * as HttpClient from "effect/unstable/http/HttpClient";
27
- import type * as HttpClientError from "effect/unstable/http/HttpClientError";
26
+ import type * as HttpClient from "effect/http/HttpClient";
27
+ import type * as HttpClientError from "effect/http/HttpClientError";
28
28
  import type * as API from "@distilled.cloud/core/api";
29
29
  import {
30
30
  makeRestProtocol,
@@ -32,7 +32,7 @@ import {
32
32
  } from "@distilled.cloud/core/protocol-rest";
33
33
  import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
34
34
  import { Credentials, type Config } from "./credentials.ts";
35
- import { UnknownAxiomError } from "./errors.ts";
35
+ import { UnknownAxiomError, AxiomParseError } from "./errors.ts";
36
36
 
37
37
  /**
38
38
  * Error channel shared by every generated Axiom operation. Generated service
@@ -44,7 +44,8 @@ export type AxiomOpError =
44
44
  | InstanceType<(typeof API_ERRORS)[number]>
45
45
  | UnknownAxiomError
46
46
  | ConfigError
47
- | HttpClientError.HttpClientError;
47
+ | HttpClientError.HttpClientError
48
+ | AxiomParseError;
48
49
 
49
50
  /** Context (requirements) shared by every generated Axiom operation. */
50
51
  export type AxiomOpContext = Credentials | HttpClient.HttpClient;
@@ -108,4 +109,5 @@ export const AxiomProtocol: Layer.Layer<API.Protocol> =
108
109
  message,
109
110
  body,
110
111
  }),
112
+ parseError: ({ body, cause }) => new AxiomParseError({ body, cause }),
111
113
  });
@@ -0,0 +1,46 @@
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.ts";
5
+ import { AxiomParseError } from "./errors.ts";
6
+ import * as Retry from "./retry.ts";
7
+ import { getCurrentUser } from "./services/v2.ts";
8
+ import type { AxiomOpError } from "./protocol.ts";
9
+
10
+ // getCurrentUser declares `{ email: string; id: string; name: string; role?: … }`.
11
+ const run = (body: string) =>
12
+ runValidationModes(
13
+ getCurrentUser({}).pipe(
14
+ Retry.none,
15
+ Effect.provide(fromApiKey({ apiKey: "test" })),
16
+ ),
17
+ { body },
18
+ );
19
+
20
+ describe("Axiom response validation", () => {
21
+ test("a matching body succeeds unchanged in both modes", async () => {
22
+ const body = { email: "a@example.com", id: "u1", name: "Ada" };
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 body = { id: "u1" };
30
+ const { lenient, strict } = await run(JSON.stringify(body));
31
+ expect(lenient).toMatchObject({ _tag: "Success", success: body });
32
+ expect(strict._tag).toBe("Failure");
33
+ expect((strict as any).failure).toBeInstanceOf(AxiomParseError);
34
+ });
35
+
36
+ test("a non-JSON body: lenient returns the text, strict fails", async () => {
37
+ const { lenient, strict } = await run("not json");
38
+ expect(lenient).toMatchObject({ _tag: "Success", success: "not json" });
39
+ expect((strict as any).failure).toBeInstanceOf(AxiomParseError);
40
+ });
41
+ });
42
+
43
+ // AxiomParseError is part of every operation's declared error type.
44
+ export const parseErrorIsDeclared: [AxiomParseError] extends [AxiomOpError]
45
+ ? true
46
+ : false = true;