@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
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@distilled.cloud/axiom",
3
- "version": "1.0.0-rc.13",
3
+ "version": "1.0.0-rc.14",
4
+ "license": "Apache-2.0",
4
5
  "repository": {
5
6
  "type": "git",
6
7
  "url": "https://github.com/alchemy-run/distilled",
7
8
  "directory": "packages/axiom"
8
9
  },
9
- "license": "Apache-2.0",
10
- "type": "module",
11
- "sideEffects": false,
12
10
  "files": [
13
11
  "lib",
14
12
  "src"
15
13
  ],
14
+ "type": "module",
15
+ "sideEffects": false,
16
16
  "exports": {
17
17
  ".": {
18
18
  "types": "./lib/index.d.ts",
@@ -70,20 +70,22 @@
70
70
  }
71
71
  },
72
72
  "dependencies": {
73
- "@distilled.cloud/core": "1.0.0-rc.13"
73
+ "@distilled.cloud/core": "1.0.0-rc.14"
74
74
  },
75
75
  "devDependencies": {
76
- "@types/bun": "1.3.14",
77
- "@types/node": "26.2.0",
78
- "@effect/platform-bun": "^4.0.0"
76
+ "@types/node": "26.2.0"
79
77
  },
80
78
  "peerDependencies": {
81
79
  "effect": "^4.0.0"
82
80
  },
81
+ "distilled": {
82
+ "generatedAt": "2026-10-05",
83
+ "specUpdatedAt": "2026-09-24"
84
+ },
83
85
  "scripts": {
84
86
  "build": "tsc -b",
85
- "convert": "bun scripts/convert.ts",
86
- "generate": "bun scripts/convert.ts && bun scripts/generate.ts",
87
+ "convert": "node --conditions=bun scripts/convert.ts",
88
+ "generate": "node --conditions=bun scripts/convert.ts && node --conditions=bun scripts/generate.ts",
87
89
  "typecheck": "tsc -p tsconfig.json",
88
90
  "specs:fetch": "git submodule update --force --init --depth=1 specs/spec-mirror-axiom",
89
91
  "specs:update": "git submodule update --remote --force --depth=1 specs/spec-mirror-axiom"
@@ -1,3 +1,4 @@
1
+ import { ConfigError } from "@distilled.cloud/core/errors";
1
2
  /**
2
3
  * Axiom credentials — hand-written.
3
4
  *
@@ -12,7 +13,6 @@ import * as Effect from "effect/Effect";
12
13
  import * as Layer from "effect/Layer";
13
14
  import * as Option from "effect/Option";
14
15
  import * as Redacted from "effect/Redacted";
15
- import { ConfigError } from "@distilled.cloud/core/errors";
16
16
 
17
17
  /** Default base URL for Axiom Cloud. Self-hosted users can override via AXIOM_URL. */
18
18
  export const DEFAULT_API_BASE_URL = "https://api.axiom.co";
@@ -28,23 +28,20 @@ export interface Config {
28
28
  readonly orgId?: string;
29
29
  }
30
30
 
31
- export class Credentials extends Context.Service<
32
- Credentials,
33
- Effect.Effect<Config>
34
- >()("AxiomCredentials") {}
31
+ export class Credentials extends Context.Service<Credentials, Effect.Effect<Config>>()(
32
+ "AxiomCredentials",
33
+ ) {}
35
34
 
36
- /** Layer from a plain API token + optional base URL / org ID. */
35
+ /** Layer from a redacted API token + optional base URL / org ID. */
37
36
  export const fromApiKey = (config: {
38
- readonly apiKey: string | Redacted.Redacted<string>;
37
+ readonly apiKey: Redacted.Redacted<string>;
39
38
  readonly apiBaseUrl?: string;
40
39
  readonly orgId?: string;
41
40
  }): Layer.Layer<Credentials> =>
42
41
  Layer.succeed(
43
42
  Credentials,
44
43
  Effect.succeed({
45
- apiKey: Redacted.isRedacted(config.apiKey)
46
- ? config.apiKey
47
- : Redacted.make(config.apiKey),
44
+ apiKey: config.apiKey,
48
45
  apiBaseUrl: config.apiBaseUrl ?? DEFAULT_API_BASE_URL,
49
46
  orgId: config.orgId,
50
47
  }),
@@ -53,9 +50,7 @@ export const fromApiKey = (config: {
53
50
  const envConfig = EffectConfig.all({
54
51
  apiToken: EffectConfig.option(EffectConfig.String("AXIOM_TOKEN")),
55
52
  apiKey: EffectConfig.option(EffectConfig.String("AXIOM_API_KEY")),
56
- apiBaseUrl: EffectConfig.String("AXIOM_URL").pipe(
57
- EffectConfig.withDefault(DEFAULT_API_BASE_URL),
58
- ),
53
+ apiBaseUrl: EffectConfig.String("AXIOM_URL").pipe(EffectConfig.withDefault(DEFAULT_API_BASE_URL)),
59
54
  orgId: EffectConfig.option(EffectConfig.String("AXIOM_ORG_ID")),
60
55
  });
61
56
 
@@ -74,19 +69,15 @@ export const CredentialsFromEnv: Layer.Layer<Credentials> = Layer.succeed(
74
69
  Effect.mapError(
75
70
  () =>
76
71
  new ConfigError({
77
- message:
78
- "AXIOM_TOKEN (or AXIOM_API_KEY) environment variable is required",
72
+ message: "AXIOM_TOKEN (or AXIOM_API_KEY) environment variable is required",
79
73
  }),
80
74
  ),
81
75
  );
82
- const apiKey =
83
- Option.getOrUndefined(config.apiToken) ??
84
- Option.getOrUndefined(config.apiKey);
76
+ const apiKey = Option.getOrUndefined(config.apiToken) ?? Option.getOrUndefined(config.apiKey);
85
77
 
86
78
  if (!apiKey) {
87
79
  return yield* new ConfigError({
88
- message:
89
- "AXIOM_TOKEN (or AXIOM_API_KEY) environment variable is required",
80
+ message: "AXIOM_TOKEN (or AXIOM_API_KEY) environment variable is required",
90
81
  });
91
82
  }
92
83
 
package/src/errors.ts CHANGED
@@ -27,8 +27,8 @@ export {
27
27
  } from "@distilled.cloud/core/errors";
28
28
  export type { DefaultErrors } from "@distilled.cloud/core/errors";
29
29
 
30
- import * as Schema from "effect/Schema";
31
30
  import * as Category from "@distilled.cloud/core/category";
31
+ import * as Schema from "effect/Schema";
32
32
 
33
33
  /** Unknown Axiom error — returned when nothing else matches the failure. */
34
34
  export class UnknownAxiomError extends Schema.TaggedError<UnknownAxiomError>()(
@@ -41,10 +41,7 @@ export class UnknownAxiomError extends Schema.TaggedError<UnknownAxiomError>()(
41
41
  ).pipe(Category.withServerError) {}
42
42
 
43
43
  /** Schema parse error wrapper (kept for v0 surface parity). */
44
- export class AxiomParseError extends Schema.TaggedError<AxiomParseError>()(
45
- "AxiomParseError",
46
- {
47
- body: Schema.Unknown,
48
- cause: Schema.Unknown,
49
- },
50
- ).pipe(Category.withParseError) {}
44
+ export class AxiomParseError extends Schema.TaggedError<AxiomParseError>()("AxiomParseError", {
45
+ body: Schema.Unknown,
46
+ cause: Schema.Unknown,
47
+ }).pipe(Category.withParseError) {}
package/src/index.ts CHANGED
@@ -21,12 +21,7 @@
21
21
  export * from "./credentials.ts";
22
22
  export * from "./errors.ts";
23
23
  export * as T from "./traits.ts";
24
- export {
25
- AxiomProtocol,
26
- stripNulls,
27
- type AxiomOpError,
28
- type AxiomOpContext,
29
- } from "./protocol.ts";
24
+ export { AxiomProtocol, stripNulls, type AxiomOpError, type AxiomOpContext } from "./protocol.ts";
30
25
  export * as Retry from "./retry.ts";
31
26
  export * from "./services/index.ts";
32
27
  // v0-parity surface: the v2 control-plane operations live on the package
@@ -34,10 +29,4 @@ export * from "./services/index.ts";
34
29
  // The service-local typed error classes shadow the same-named shared ones
35
30
  // from ./errors.ts — the ops actually raise the service-local classes.
36
31
  export * from "./services/v2.ts";
37
- export {
38
- BadRequest,
39
- Conflict,
40
- Forbidden,
41
- NotFound,
42
- UnprocessableEntity,
43
- } from "./services/v2.ts";
32
+ export { BadRequest, Conflict, Forbidden, NotFound, UnprocessableEntity } from "./services/v2.ts";
package/src/protocol.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import type * as API from "@distilled.cloud/core/api";
2
+ import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
3
+ import { makeRestProtocol, type RestErrorEnvelope } from "@distilled.cloud/core/protocol-rest";
1
4
  /**
2
5
  * AxiomProtocol — hand-written.
3
6
  *
@@ -21,16 +24,10 @@
21
24
  * extractor; the HTTP status stays the authoritative signal.
22
25
  */
23
26
  import * as Effect from "effect/Effect";
24
- import type * as Layer from "effect/Layer";
25
- import * as Redacted from "effect/Redacted";
26
27
  import type * as HttpClient from "effect/http/HttpClient";
27
28
  import type * as HttpClientError from "effect/http/HttpClientError";
28
- import type * as API from "@distilled.cloud/core/api";
29
- import {
30
- makeRestProtocol,
31
- type RestErrorEnvelope,
32
- } from "@distilled.cloud/core/protocol-rest";
33
- import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
29
+ import type * as Layer from "effect/Layer";
30
+ import * as Redacted from "effect/Redacted";
34
31
  import { Credentials, type Config } from "./credentials.ts";
35
32
  import { UnknownAxiomError, AxiomParseError } from "./errors.ts";
36
33
 
@@ -82,32 +79,30 @@ const errorEnvelope = (body: unknown): RestErrorEnvelope | undefined => {
82
79
  if (body === null || typeof body !== "object") return undefined;
83
80
  const b = body as Record<string, unknown>;
84
81
  const error = typeof b.error === "string" ? b.error : undefined;
85
- const code =
86
- typeof b.code === "string" || typeof b.code === "number" ? b.code : error;
82
+ const code = typeof b.code === "string" || typeof b.code === "number" ? b.code : error;
87
83
  const message = typeof b.message === "string" ? b.message : error;
88
84
  return { code, message };
89
85
  };
90
86
 
91
- export const AxiomProtocol: Layer.Layer<API.Protocol> =
92
- makeRestProtocol<Config>({
93
- // The Credentials service holds an effect — resolving it here (per
94
- // request, on the calling fiber) picks up context-provided credentials.
95
- credentials: Effect.gen(function* () {
96
- const resolve = yield* Credentials;
97
- return yield* resolve;
98
- }),
99
- baseUrl: (creds) => creds.apiBaseUrl,
100
- headers: (creds) => ({
101
- Authorization: `Bearer ${Redacted.value(creds.apiKey)}`,
102
- ...(creds.orgId ? { "X-Axiom-Org-ID": creds.orgId } : {}),
87
+ export const AxiomProtocol: Layer.Layer<API.Protocol> = makeRestProtocol<Config>({
88
+ // The Credentials service holds an effect — resolving it here (per
89
+ // request, on the calling fiber) picks up context-provided credentials.
90
+ credentials: Effect.gen(function* () {
91
+ const resolve = yield* Credentials;
92
+ return yield* resolve;
93
+ }),
94
+ baseUrl: (creds) => creds.apiBaseUrl,
95
+ headers: (creds) => ({
96
+ Authorization: `Bearer ${Redacted.value(creds.apiKey)}`,
97
+ ...(creds.orgId ? { "X-Axiom-Org-ID": creds.orgId } : {}),
98
+ }),
99
+ errorEnvelope,
100
+ transformResponse: stripNulls,
101
+ unknownError: ({ code, message, body }) =>
102
+ new UnknownAxiomError({
103
+ code: typeof code === "number" ? String(code) : code,
104
+ message,
105
+ body,
103
106
  }),
104
- errorEnvelope,
105
- transformResponse: stripNulls,
106
- unknownError: ({ code, message, body }) =>
107
- new UnknownAxiomError({
108
- code: typeof code === "number" ? String(code) : code,
109
- message,
110
- body,
111
- }),
112
- parseError: ({ body, cause }) => new AxiomParseError({ body, cause }),
113
- });
107
+ parseError: ({ body, cause }) => new AxiomParseError({ body, cause }),
108
+ });
package/src/retry.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type Policy, throttlingFactory, transientFactory } from "@distilled.cloud/core/retry";
1
2
  /**
2
3
  * Axiom retry configuration.
3
4
  *
@@ -16,11 +17,6 @@
16
17
  import * as Context from "effect/Context";
17
18
  import * as Effect from "effect/Effect";
18
19
  import * as Layer from "effect/Layer";
19
- import {
20
- type Policy,
21
- throttlingFactory,
22
- transientFactory,
23
- } from "@distilled.cloud/core/retry";
24
20
 
25
21
  export {
26
22
  type Options,
@@ -43,9 +39,7 @@ export const policy = (optionsOrFactory: Policy) =>
43
39
  Effect.provide(Layer.succeed(Retry, optionsOrFactory));
44
40
 
45
41
  /** Disables all automatic retries. */
46
- export const none = Effect.provide(
47
- Layer.succeed(Retry, { while: () => false }),
48
- );
42
+ export const none = Effect.provide(Layer.succeed(Retry, { while: () => false }));
49
43
 
50
44
  /** Apply the throttling retry policy (retries throttling errors indefinitely). */
51
45
  export const throttling = policy(throttlingFactory);
@@ -1,15 +1,11 @@
1
- // AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/docs restapi/versions). Do not edit.
2
- import * as S from "@distilled.cloud/core/schema";
3
1
  import * as API from "@distilled.cloud/core/api";
4
2
  import * as C from "@distilled.cloud/core/category";
5
- import * as T from "../traits.ts";
6
- import {
7
- AxiomProtocol,
8
- type AxiomOpError,
9
- type AxiomOpContext,
10
- } from "../protocol.ts";
3
+ // AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/docs restapi/versions). Do not edit.
4
+ import * as S from "@distilled.cloud/core/schema";
11
5
  import { UnknownAxiomError } from "../errors.ts";
6
+ import { AxiomProtocol, type AxiomOpError, type AxiomOpContext } from "../protocol.ts";
12
7
  import * as Retry from "../retry.ts";
8
+ import * as T from "../traits.ts";
13
9
 
14
10
  export type { AxiomOpError, AxiomOpContext };
15
11
 
@@ -57,16 +53,8 @@ export const IngestToDatasetRequest = /*@__PURE__*/ S.suspend(() =>
57
53
  timestamp_format: S.optional(S.String.pipe(T.Query("timestamp-format"))),
58
54
  csv_delimiter: S.optional(S.String.pipe(T.Query("csv-delimiter"))),
59
55
  body: S.String.pipe(T.HttpBody()),
60
- }).pipe(
61
- T.Http({
62
- method: "POST",
63
- uri: "/v1/datasets/{dataset_id}/ingest",
64
- code: 200,
65
- }),
66
- ),
67
- ).annotate({
68
- identifier: "IngestToDatasetRequest",
69
- }) as any as S.Schema<IngestToDatasetRequest>;
56
+ }).pipe(T.Http({ method: "POST", uri: "/v1/datasets/{dataset_id}/ingest", code: 200 })),
57
+ ).annotate({ identifier: "IngestToDatasetRequest" }) as any as S.Schema<IngestToDatasetRequest>;
70
58
 
71
59
  export interface IngestFailure {
72
60
  error: string;
@@ -103,11 +91,7 @@ export const IngestStatus = /*@__PURE__*/ S.suspend(() =>
103
91
  }),
104
92
  ).annotate({ identifier: "IngestStatus" }) as any as S.Schema<IngestStatus>;
105
93
 
106
- export type IngestToDatasetError =
107
- | BadRequest
108
- | NotFound
109
- | UnprocessableEntity
110
- | AxiomOpError;
94
+ export type IngestToDatasetError = BadRequest | NotFound | UnprocessableEntity | AxiomOpError;
111
95
  export const ingestToDataset: API.OperationMethod<
112
96
  IngestToDatasetRequest,
113
97
  IngestStatus,
@@ -1,14 +1,10 @@
1
+ import * as API from "@distilled.cloud/core/api";
1
2
  // AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/docs restapi/versions). Do not edit.
2
3
  import * as S from "@distilled.cloud/core/schema";
3
- import * as API from "@distilled.cloud/core/api";
4
- import * as T from "../traits.ts";
5
- import {
6
- AxiomProtocol,
7
- type AxiomOpError,
8
- type AxiomOpContext,
9
- } from "../protocol.ts";
10
4
  import { UnknownAxiomError } from "../errors.ts";
5
+ import { AxiomProtocol, type AxiomOpError, type AxiomOpContext } from "../protocol.ts";
11
6
  import * as Retry from "../retry.ts";
7
+ import * as T from "../traits.ts";
12
8
 
13
9
  export type { AxiomOpError, AxiomOpContext };
14
10
 
@@ -29,8 +25,7 @@ export const QueryAplRequestDefaultOrderItem = /*@__PURE__*/ S.suspend(() =>
29
25
  }) as any as S.Schema<QueryAplRequestDefaultOrderItem>;
30
26
 
31
27
  /** The default order to use when no order is specified in the query. */
32
- export type QueryAplRequestDefaultOrderList =
33
- Array<QueryAplRequestDefaultOrderItem>;
28
+ export type QueryAplRequestDefaultOrderList = Array<QueryAplRequestDefaultOrderItem>;
34
29
  export const QueryAplRequestDefaultOrderList = /*@__PURE__*/ S.Array(
35
30
  QueryAplRequestDefaultOrderItem,
36
31
  ) as any as S.Schema<QueryAplRequestDefaultOrderList>;
@@ -102,9 +97,7 @@ export const QueryOptions = /*@__PURE__*/ S.suspend(() =>
102
97
  ).annotate({ identifier: "QueryOptions" }) as any as S.Schema<QueryOptions>;
103
98
 
104
99
  /** Variables is an optional set of additional variables that are inserted into the APL */
105
- export type QueryAplRequestVariablesMap = {
106
- [key: string]: unknown | undefined;
107
- };
100
+ export type QueryAplRequestVariablesMap = { [key: string]: unknown | undefined };
108
101
  export const QueryAplRequestVariablesMap = /*@__PURE__*/ S.Record(
109
102
  S.String,
110
103
  S.Unknown,
@@ -152,9 +145,7 @@ export const QueryAplRequest = /*@__PURE__*/ S.suspend(() =>
152
145
  nocache: S.optional(S.Boolean.pipe(T.Query())),
153
146
  saveAsKind: S.optional(S.String.pipe(T.Query())),
154
147
  id: S.optional(S.String.pipe(T.Query())),
155
- streaming_duration: S.optional(
156
- S.String.pipe(T.Query("streaming-duration")),
157
- ),
148
+ streaming_duration: S.optional(S.String.pipe(T.Query("streaming-duration"))),
158
149
  apl_source: S.optional(S.String.pipe(T.Query("apl-source"))),
159
150
  apl_source_id: S.optional(S.String.pipe(T.Query("apl-source-id"))),
160
151
  totals: S.optional(S.Boolean.pipe(T.Query())),
@@ -171,16 +162,12 @@ export const QueryAplRequest = /*@__PURE__*/ S.suspend(() =>
171
162
  startTime: S.optional(S.String),
172
163
  variables: S.optional(QueryAplRequestVariablesMap),
173
164
  }).pipe(T.Http({ method: "POST", uri: "/v1/datasets/_apl", code: 200 })),
174
- ).annotate({
175
- identifier: "QueryAplRequest",
176
- }) as any as S.Schema<QueryAplRequest>;
165
+ ).annotate({ identifier: "QueryAplRequest" }) as any as S.Schema<QueryAplRequest>;
177
166
 
178
167
  export type QueryAplResponse = unknown;
179
168
  export const QueryAplResponse = /*@__PURE__*/ S.suspend(() =>
180
169
  S.Unknown.pipe(T.RawResponseRoot()),
181
- ).annotate({
182
- identifier: "QueryAplResponse",
183
- }) as any as S.Schema<QueryAplResponse>;
170
+ ).annotate({ identifier: "QueryAplResponse" }) as any as S.Schema<QueryAplResponse>;
184
171
 
185
172
  export type QueryAplError = AxiomOpError;
186
173
  export const queryApl: API.OperationMethod<