@theholocron/holocron-plugin-axiom 5.0.0-alpha.116 → 5.0.0-alpha.118

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/dist/index.d.mts CHANGED
@@ -1,38 +1,8 @@
1
1
  import { AuthError, Logs, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
2
+ import { AxiomClient, AxiomClientOptions, AxiomDataset, AxiomUser, CreateAxiomDatasetInput, createAxiomClient } from "@theholocron/axiom-client";
2
3
  //#region src/auth.d.ts
3
4
  declare const resolveToken: (input?: ResolveTokenInput) => string;
4
5
  //#endregion
5
- //#region src/rest.d.ts
6
- /** Axiom dataset — the subset of fields Holocron reads. */
7
- interface AxiomDataset {
8
- id: string;
9
- name: string;
10
- description?: string;
11
- }
12
- /** Axiom user — the subset returned by `GET /v2/user`. */
13
- interface AxiomUser {
14
- id: string;
15
- name?: string;
16
- email?: string;
17
- emails?: string[];
18
- }
19
- interface AxiomClientOptions {
20
- token: string;
21
- /** Override the API base URL (default `https://api.axiom.co`). */
22
- baseUrl?: string;
23
- /** Override `fetch` for tests. */
24
- fetch?: typeof fetch;
25
- }
26
- interface AxiomRestClient {
27
- getDataset(name: string): Promise<AxiomDataset>;
28
- createDataset(input: {
29
- name: string;
30
- description?: string;
31
- }): Promise<AxiomDataset>;
32
- getCurrentUser(): Promise<AxiomUser>;
33
- }
34
- declare function createAxiomClient(opts: AxiomClientOptions): AxiomRestClient;
35
- //#endregion
36
6
  //#region src/capabilities/logs.d.ts
37
7
  interface AxiomLogsOptions {
38
8
  /**
@@ -51,7 +21,7 @@ declare class AxiomLogs implements Logs {
51
21
  * `client` is a thunk — the token is resolved on first call, so
52
22
  * `describe()` (which needs no auth) works without one.
53
23
  */
54
- constructor(client: () => AxiomRestClient, opts: AxiomLogsOptions);
24
+ constructor(client: () => AxiomClient, opts: AxiomLogsOptions);
55
25
  describe(): Promise<{
56
26
  provider: string;
57
27
  envKeys: string[];
@@ -89,7 +59,7 @@ interface PluginContext {
89
59
  * no auth (`describe`) works without a token, and the loader never
90
60
  * aborts on a plugin whose token happens to be absent.
91
61
  */
92
- client: () => AxiomRestClient;
62
+ client: () => AxiomClient;
93
63
  }
94
64
  declare function createContext(options: AxiomPluginOptions): PluginContext;
95
65
  declare function logs(ctx: PluginContext): Logs;
@@ -105,4 +75,4 @@ declare function createPlugin(options: AxiomPluginOptions): {
105
75
  */
106
76
  declare const AUTH_HINT: string;
107
77
  //#endregion
108
- export { AUTH_HINT, AuthError, type AxiomClientOptions, type AxiomDataset, AxiomLogs, type AxiomLogsOptions, AxiomPluginOptions, type AxiomRestClient, type AxiomUser, PluginContext, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createAxiomClient, createContext, createPlugin, logs, resolveToken, verifyToken };
78
+ export { AUTH_HINT, AuthError, type AxiomClient, type AxiomClientOptions, type AxiomDataset, AxiomLogs, type AxiomLogsOptions, AxiomPluginOptions, type AxiomUser, type CreateAxiomDatasetInput, PluginContext, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createAxiomClient, createContext, createPlugin, logs, resolveToken, verifyToken };
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { AuthError, ProviderApiError, createResolveToken, createRestClient } from "@theholocron/cli";
1
+ import { AuthError, ProviderApiError, createResolveToken } from "@theholocron/cli";
2
+ import { createAxiomClient } from "@theholocron/axiom-client";
2
3
  import { errorMessage } from "@theholocron/misc-utils";
3
4
  //#region src/auth.ts
4
5
  const resolveToken = createResolveToken({
@@ -31,7 +32,7 @@ var AxiomLogs = class {
31
32
  async whoami() {
32
33
  const dataset = this.opts.dataset;
33
34
  if (!dataset) throw new Error("@theholocron/holocron-plugin-axiom needs a dataset (HOLOCRON_AXIOM_DATASET / AXIOM_DATASET) for whoami");
34
- await this.client().getDataset(dataset);
35
+ await this.client().datasets.get(dataset);
35
36
  return {
36
37
  ok: true,
37
38
  dataset
@@ -39,34 +40,18 @@ var AxiomLogs = class {
39
40
  }
40
41
  async ensureDataset(name) {
41
42
  try {
42
- await this.client().getDataset(name);
43
+ await this.client().datasets.get(name);
43
44
  return { alreadyExists: true };
44
45
  } catch (err) {
45
46
  if (!(err instanceof ProviderApiError) || err.status !== 404) throw err;
46
47
  }
47
- await this.client().createDataset({
48
+ await this.client().datasets.create({
48
49
  name,
49
50
  description: "Managed by holocron"
50
51
  });
51
52
  return { alreadyExists: false };
52
53
  }
53
54
  };
54
- function createAxiomClient(opts) {
55
- const rest = createRestClient({
56
- baseUrl: opts.baseUrl ?? "https://api.axiom.co",
57
- token: opts.token,
58
- vendor: "Axiom",
59
- fetch: opts.fetch
60
- });
61
- return {
62
- getDataset: (name) => rest.request(`/v2/datasets/${encodeURIComponent(name)}`),
63
- createDataset: (input) => rest.request("/v2/datasets", {
64
- method: "POST",
65
- body: input
66
- }),
67
- getCurrentUser: () => rest.request("/v2/user")
68
- };
69
- }
70
55
  //#endregion
71
56
  //#region src/verify-token.ts
72
57
  async function verifyToken(token, opts = {}) {
@@ -76,7 +61,7 @@ async function verifyToken(token, opts = {}) {
76
61
  fetch: opts.fetch
77
62
  });
78
63
  try {
79
- const me = await client.getCurrentUser();
64
+ const me = await client.user.me();
80
65
  return {
81
66
  ok: true,
82
67
  subject: `user @ ${me.email ?? me.emails?.[0] ?? me.name ?? me.id ?? "unknown"}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-axiom",
3
- "version": "5.0.0-alpha.116",
3
+ "version": "5.0.0-alpha.118",
4
4
  "description": "Holocron plugin for Axiom. Implements the logs capability against Axiom's REST API — dataset provisioning and connectivity checks, plus verifyToken + AUTH_HINT for `holocron auth`.",
5
5
  "keywords": [
6
6
  "axiom",
@@ -30,8 +30,9 @@
30
30
  "dist"
31
31
  ],
32
32
  "devDependencies": {
33
+ "@theholocron/axiom-client": "^1.38.0",
33
34
  "@theholocron/eslint-config": "^8.7.0",
34
- "@theholocron/http-client": "^1.37.1",
35
+ "@theholocron/http-client": "^1.38.0",
35
36
  "@theholocron/misc-utils": "^1.9.2",
36
37
  "@theholocron/tsconfig": "^8.7.0",
37
38
  "@theholocron/tsdown-config": "^8.7.0",
@@ -46,11 +47,12 @@
46
47
  "tsx": "4.23.12",
47
48
  "typescript": "^5.9.3",
48
49
  "vitest": "^4.1.11",
49
- "@theholocron/cli": "5.0.0-alpha.116"
50
+ "@theholocron/cli": "5.0.0-alpha.118"
50
51
  },
51
52
  "peerDependencies": {
53
+ "@theholocron/axiom-client": "^1.38.0",
52
54
  "@theholocron/misc-utils": "^1.9.2",
53
- "@theholocron/cli": "5.0.0-alpha.116"
55
+ "@theholocron/cli": "5.0.0-alpha.118"
54
56
  },
55
57
  "engines": {
56
58
  "node": ">=22"