@distilled.cloud/axiom 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.
Files changed (45) hide show
  1. package/lib/credentials.d.ts +2 -2
  2. package/lib/credentials.d.ts.map +1 -1
  3. package/lib/credentials.js +4 -7
  4. package/lib/credentials.js.map +1 -1
  5. package/lib/errors.d.ts.map +1 -1
  6. package/lib/errors.js +1 -1
  7. package/lib/errors.js.map +1 -1
  8. package/lib/index.d.ts +2 -2
  9. package/lib/index.d.ts.map +1 -1
  10. package/lib/index.js +2 -2
  11. package/lib/index.js.map +1 -1
  12. package/lib/protocol.d.ts +3 -3
  13. package/lib/protocol.d.ts.map +1 -1
  14. package/lib/protocol.js +1 -1
  15. package/lib/protocol.js.map +1 -1
  16. package/lib/retry.d.ts +1 -1
  17. package/lib/retry.d.ts.map +1 -1
  18. package/lib/retry.js +1 -1
  19. package/lib/retry.js.map +1 -1
  20. package/lib/services/edge_ingest.d.ts +1 -1
  21. package/lib/services/edge_ingest.d.ts.map +1 -1
  22. package/lib/services/edge_ingest.js +5 -11
  23. package/lib/services/edge_ingest.js.map +1 -1
  24. package/lib/services/edge_query.d.ts +1 -1
  25. package/lib/services/edge_query.d.ts.map +1 -1
  26. package/lib/services/edge_query.js +5 -9
  27. package/lib/services/edge_query.js.map +1 -1
  28. package/lib/services/v2.d.ts +25 -1
  29. package/lib/services/v2.d.ts.map +1 -1
  30. package/lib/services/v2.js +187 -453
  31. package/lib/services/v2.js.map +1 -1
  32. package/package.json +12 -10
  33. package/src/credentials.ts +11 -20
  34. package/src/errors.ts +5 -8
  35. package/src/index.ts +2 -13
  36. package/src/protocol.ts +27 -32
  37. package/src/retry.ts +2 -8
  38. package/src/services/edge_ingest.ts +7 -23
  39. package/src/services/edge_query.ts +8 -21
  40. package/src/services/v2.ts +387 -957
  41. package/lib/response-validation.test.d.ts +0 -4
  42. package/lib/response-validation.test.d.ts.map +0 -1
  43. package/lib/response-validation.test.js +0 -32
  44. package/lib/response-validation.test.js.map +0 -1
  45. package/src/response-validation.test.ts +0 -46
@@ -1,4 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,32 +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 { 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
@@ -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,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,IAAI,GAAG,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC/D,MAAM,EAAE,OAA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AAC,CAAC;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAErB,IAAI,CAAC"}
@@ -1,46 +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.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;