@theholocron/holocron-plugin-axiom 5.0.0-alpha.25 → 5.0.0-alpha.250
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 +2 -2
- package/dist/index.d.mts +17 -69
- package/dist/index.mjs +22 -38
- package/package.json +18 -14
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ plus exports `verifyToken` + `AUTH_HINT` for use by `holocron auth`.
|
|
|
9
9
|
> This plugin does **not** ship log lines. `@theholocron/observability/logger`'s
|
|
10
10
|
> Axiom transport reads `HOLOCRON_AXIOM_TOKEN` / `HOLOCRON_AXIOM_DATASET`
|
|
11
11
|
> directly at startup. The `logs` capability exists only for the
|
|
12
|
-
> management surface — `holocron setup` provisions the aggregation
|
|
12
|
+
> management surface — `holocron repo setup` provisions the aggregation
|
|
13
13
|
> datasets and `holocron doctor` checks connectivity.
|
|
14
14
|
|
|
15
15
|
## Install
|
|
@@ -49,7 +49,7 @@ token as `HOLOCRON_AXIOM_TOKEN` (or `AXIOM_TOKEN`) in the workflow env.
|
|
|
49
49
|
}
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
No options are required. `holocron setup` provisions the `holocron-ci`
|
|
52
|
+
No options are required. `holocron repo setup` provisions the `holocron-ci`
|
|
53
53
|
and `holocron-local` datasets; `holocron doctor` checks the dataset
|
|
54
54
|
named by `HOLOCRON_AXIOM_DATASET` / `AXIOM_DATASET`. An explicit
|
|
55
55
|
`logs: ["axiom", { "dataset": "holocron-ci" }]` overrides the env var
|
package/dist/index.d.mts
CHANGED
|
@@ -1,39 +1,6 @@
|
|
|
1
|
-
import { AuthError, Logs, ResolveTokenInput } from "@theholocron/cli";
|
|
2
|
-
|
|
3
|
-
declare const resolveToken: (input?: ResolveTokenInput) => string;
|
|
4
|
-
//#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
|
-
//#region src/capabilities/logs.d.ts
|
|
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";
|
|
3
|
+
export declare const resolveToken: (input?: ResolveTokenInput) => string;
|
|
37
4
|
interface AxiomLogsOptions {
|
|
38
5
|
/**
|
|
39
6
|
* Target dataset, resolved from `HOLOCRON_AXIOM_DATASET` /
|
|
@@ -42,7 +9,7 @@ interface AxiomLogsOptions {
|
|
|
42
9
|
*/
|
|
43
10
|
dataset?: string;
|
|
44
11
|
}
|
|
45
|
-
declare class AxiomLogs implements Logs {
|
|
12
|
+
export declare class AxiomLogs implements Logs {
|
|
46
13
|
private readonly client;
|
|
47
14
|
private readonly opts;
|
|
48
15
|
readonly key: "logs";
|
|
@@ -51,7 +18,7 @@ declare class AxiomLogs implements Logs {
|
|
|
51
18
|
* `client` is a thunk — the token is resolved on first call, so
|
|
52
19
|
* `describe()` (which needs no auth) works without one.
|
|
53
20
|
*/
|
|
54
|
-
constructor(client: () =>
|
|
21
|
+
constructor(client: () => AxiomClient, opts: AxiomLogsOptions);
|
|
55
22
|
describe(): Promise<{
|
|
56
23
|
provider: string;
|
|
57
24
|
envKeys: string[];
|
|
@@ -64,39 +31,18 @@ declare class AxiomLogs implements Logs {
|
|
|
64
31
|
alreadyExists: boolean;
|
|
65
32
|
}>;
|
|
66
33
|
}
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region src/verify-token.d.ts
|
|
69
|
-
/**
|
|
70
|
-
* `verifyToken` — plugin-level export used by `holocron auth set axiom`
|
|
71
|
-
* + `holocron auth check`. Hits `GET /v2/user` and translates the
|
|
72
|
-
* response into the normalized `VerifyTokenResult` shape.
|
|
73
|
-
*
|
|
74
|
-
* Kept as a standalone function (not a capability method) so the auth
|
|
75
|
-
* command can call it without initializing the full plugin.
|
|
76
|
-
*/
|
|
77
|
-
interface VerifyTokenSuccess {
|
|
78
|
-
ok: true;
|
|
79
|
-
subject: string;
|
|
80
|
-
}
|
|
81
|
-
interface VerifyTokenFailure {
|
|
82
|
-
ok: false;
|
|
83
|
-
message: string;
|
|
84
|
-
}
|
|
85
|
-
type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
|
|
86
34
|
interface VerifyTokenOptions {
|
|
87
35
|
baseUrl?: string;
|
|
88
36
|
fetch?: typeof fetch;
|
|
89
37
|
}
|
|
90
|
-
declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult>;
|
|
91
|
-
|
|
92
|
-
//#region src/index.d.ts
|
|
93
|
-
interface AxiomPluginOptions extends ResolveTokenInput, AxiomLogsOptions {
|
|
38
|
+
export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
|
|
39
|
+
export interface AxiomPluginOptions extends ResolveTokenInput, AxiomLogsOptions {
|
|
94
40
|
/** Override base URL for tests. */
|
|
95
41
|
baseUrl?: string;
|
|
96
42
|
/** Override `fetch` for tests. */
|
|
97
43
|
fetch?: typeof fetch;
|
|
98
44
|
}
|
|
99
|
-
interface PluginContext {
|
|
45
|
+
export interface PluginContext {
|
|
100
46
|
options: AxiomPluginOptions & {
|
|
101
47
|
dataset?: string;
|
|
102
48
|
};
|
|
@@ -106,12 +52,15 @@ interface PluginContext {
|
|
|
106
52
|
* no auth (`describe`) works without a token, and the loader never
|
|
107
53
|
* aborts on a plugin whose token happens to be absent.
|
|
108
54
|
*/
|
|
109
|
-
client: () =>
|
|
55
|
+
client: () => AxiomClient;
|
|
110
56
|
}
|
|
111
|
-
declare function createContext(options: AxiomPluginOptions): PluginContext;
|
|
112
|
-
declare function logs(ctx: PluginContext): Logs;
|
|
113
|
-
declare function createPlugin(options: AxiomPluginOptions): {
|
|
57
|
+
export declare function createContext(options: AxiomPluginOptions): PluginContext;
|
|
58
|
+
export declare function logs(ctx: PluginContext): Logs;
|
|
59
|
+
export declare function createPlugin(options: AxiomPluginOptions): {
|
|
114
60
|
name: string;
|
|
61
|
+
probes: {
|
|
62
|
+
connection: import("@theholocron/cli").Probe;
|
|
63
|
+
};
|
|
115
64
|
capabilities: {
|
|
116
65
|
logs: () => Logs;
|
|
117
66
|
};
|
|
@@ -120,6 +69,5 @@ declare function createPlugin(options: AxiomPluginOptions): {
|
|
|
120
69
|
* One-line hint shown by `holocron auth set axiom` when no token is
|
|
121
70
|
* supplied or when the supplied token is rejected.
|
|
122
71
|
*/
|
|
123
|
-
declare const AUTH_HINT: string;
|
|
124
|
-
|
|
125
|
-
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 };
|
|
72
|
+
export declare const AUTH_HINT: string;
|
|
73
|
+
export { AuthError, type AxiomClient, type AxiomClientOptions, type AxiomDataset, type AxiomLogsOptions, type AxiomUser, type CreateAxiomDatasetInput, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createAxiomClient };
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { AuthError, ProviderApiError,
|
|
2
|
-
|
|
1
|
+
import { AuthError, ProviderApiError, connectionProbe, createResolveToken } from "@theholocron/cli";
|
|
2
|
+
import { createAxiomClient } from "@theholocron/axiom-client";
|
|
3
|
+
import { errorMessage } from "@theholocron/misc-utils";
|
|
4
|
+
// src/auth.ts
|
|
3
5
|
const resolveToken = createResolveToken({
|
|
4
6
|
envName: "HOLOCRON_AXIOM_TOKEN",
|
|
5
7
|
vendorEnvName: "AXIOM_TOKEN",
|
|
6
8
|
keyringService: "axiom",
|
|
7
9
|
errorMessage: "no Axiom token found. Pass --token <TOKEN>, set HOLOCRON_AXIOM_TOKEN / AXIOM_TOKEN, or run: holocron auth set axiom <TOKEN>"
|
|
8
10
|
});
|
|
9
|
-
|
|
10
|
-
//#region src/capabilities/logs.ts
|
|
11
|
+
// src/capabilities/logs.ts
|
|
11
12
|
var AxiomLogs = class {
|
|
12
13
|
client;
|
|
13
14
|
opts;
|
|
@@ -30,7 +31,7 @@ var AxiomLogs = class {
|
|
|
30
31
|
async whoami() {
|
|
31
32
|
const dataset = this.opts.dataset;
|
|
32
33
|
if (!dataset) throw new Error("@theholocron/holocron-plugin-axiom needs a dataset (HOLOCRON_AXIOM_DATASET / AXIOM_DATASET) for whoami");
|
|
33
|
-
await this.client().
|
|
34
|
+
await this.client().datasets.get(dataset);
|
|
34
35
|
return {
|
|
35
36
|
ok: true,
|
|
36
37
|
dataset
|
|
@@ -38,44 +39,19 @@ var AxiomLogs = class {
|
|
|
38
39
|
}
|
|
39
40
|
async ensureDataset(name) {
|
|
40
41
|
try {
|
|
41
|
-
await this.client().
|
|
42
|
+
await this.client().datasets.get(name);
|
|
42
43
|
return { alreadyExists: true };
|
|
43
44
|
} catch (err) {
|
|
44
45
|
if (!(err instanceof ProviderApiError) || err.status !== 404) throw err;
|
|
45
46
|
}
|
|
46
|
-
await this.client().
|
|
47
|
+
await this.client().datasets.create({
|
|
47
48
|
name,
|
|
48
49
|
description: "Managed by holocron"
|
|
49
50
|
});
|
|
50
51
|
return { alreadyExists: false };
|
|
51
52
|
}
|
|
52
53
|
};
|
|
53
|
-
|
|
54
|
-
const rest = createRestClient({
|
|
55
|
-
baseUrl: opts.baseUrl ?? "https://api.axiom.co",
|
|
56
|
-
token: opts.token,
|
|
57
|
-
vendor: "Axiom",
|
|
58
|
-
fetch: opts.fetch
|
|
59
|
-
});
|
|
60
|
-
return {
|
|
61
|
-
getDataset: (name) => rest.request(`/v2/datasets/${encodeURIComponent(name)}`),
|
|
62
|
-
createDataset: (input) => rest.request("/v2/datasets", {
|
|
63
|
-
method: "POST",
|
|
64
|
-
body: input
|
|
65
|
-
}),
|
|
66
|
-
getCurrentUser: () => rest.request("/v2/user")
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/verify-token.ts
|
|
71
|
-
/**
|
|
72
|
-
* `verifyToken` — plugin-level export used by `holocron auth set axiom`
|
|
73
|
-
* + `holocron auth check`. Hits `GET /v2/user` and translates the
|
|
74
|
-
* response into the normalized `VerifyTokenResult` shape.
|
|
75
|
-
*
|
|
76
|
-
* Kept as a standalone function (not a capability method) so the auth
|
|
77
|
-
* command can call it without initializing the full plugin.
|
|
78
|
-
*/
|
|
54
|
+
// src/verify-token.ts
|
|
79
55
|
async function verifyToken(token, opts = {}) {
|
|
80
56
|
const client = createAxiomClient({
|
|
81
57
|
token,
|
|
@@ -83,7 +59,7 @@ async function verifyToken(token, opts = {}) {
|
|
|
83
59
|
fetch: opts.fetch
|
|
84
60
|
});
|
|
85
61
|
try {
|
|
86
|
-
const me = await client.
|
|
62
|
+
const me = await client.user.me();
|
|
87
63
|
return {
|
|
88
64
|
ok: true,
|
|
89
65
|
subject: `user @ ${me.email ?? me.emails?.[0] ?? me.name ?? me.id ?? "unknown"}`
|
|
@@ -91,12 +67,11 @@ async function verifyToken(token, opts = {}) {
|
|
|
91
67
|
} catch (err) {
|
|
92
68
|
return {
|
|
93
69
|
ok: false,
|
|
94
|
-
message:
|
|
70
|
+
message: errorMessage(err)
|
|
95
71
|
};
|
|
96
72
|
}
|
|
97
73
|
}
|
|
98
|
-
|
|
99
|
-
//#region src/index.ts
|
|
74
|
+
// src/index.ts
|
|
100
75
|
function createContext(options) {
|
|
101
76
|
const env = options.env ?? process.env;
|
|
102
77
|
const dataset = options.dataset ?? env.HOLOCRON_AXIOM_DATASET ?? env.AXIOM_DATASET;
|
|
@@ -120,6 +95,16 @@ function createPlugin(options) {
|
|
|
120
95
|
const ctx = createContext(options);
|
|
121
96
|
return {
|
|
122
97
|
name: "@theholocron/holocron-plugin-axiom",
|
|
98
|
+
probes: { connection: connectionProbe({
|
|
99
|
+
provider: "Axiom",
|
|
100
|
+
url: options.baseUrl ?? "https://api.axiom.co",
|
|
101
|
+
fetch: options.fetch,
|
|
102
|
+
token: () => resolveToken(options),
|
|
103
|
+
verify: (token) => verifyToken(token, {
|
|
104
|
+
baseUrl: options.baseUrl,
|
|
105
|
+
fetch: options.fetch
|
|
106
|
+
})
|
|
107
|
+
}) },
|
|
123
108
|
capabilities: { logs: () => logs(ctx) }
|
|
124
109
|
};
|
|
125
110
|
}
|
|
@@ -128,5 +113,4 @@ function createPlugin(options) {
|
|
|
128
113
|
* supplied or when the supplied token is rejected.
|
|
129
114
|
*/
|
|
130
115
|
const AUTH_HINT = "generate an Axiom API token at https://app.axiom.co/settings/api-tokens with dataset read + create permissions, then run: holocron auth set axiom <TOKEN>";
|
|
131
|
-
//#endregion
|
|
132
116
|
export { AUTH_HINT, AuthError, AxiomLogs, createAxiomClient, createContext, createPlugin, logs, resolveToken, verifyToken };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-axiom",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.250",
|
|
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",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"logs",
|
|
9
9
|
"plugin"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://github.com/theholocron/holocron/tree/main/
|
|
11
|
+
"homepage": "https://github.com/theholocron/holocron/tree/main/plugins/holocron-plugin-axiom#readme",
|
|
12
12
|
"bugs": "https://github.com/theholocron/holocron/issues",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/theholocron/holocron.git",
|
|
16
|
-
"directory": "
|
|
16
|
+
"directory": "plugins/holocron-plugin-axiom"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"author": "Newton Koumantzelis",
|
|
@@ -30,25 +30,29 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@theholocron/
|
|
34
|
-
"@theholocron/
|
|
35
|
-
"@theholocron/
|
|
36
|
-
"@theholocron/
|
|
37
|
-
"@theholocron/
|
|
33
|
+
"@theholocron/axiom-client": "^1.43.1",
|
|
34
|
+
"@theholocron/eslint-config": "^8.8.2",
|
|
35
|
+
"@theholocron/http-client": "^1.57.0",
|
|
36
|
+
"@theholocron/misc-utils": "^1.16.0",
|
|
37
|
+
"@theholocron/tsconfig": "^8.8.2",
|
|
38
|
+
"@theholocron/tsdown-config": "^8.8.2",
|
|
39
|
+
"@theholocron/vitest-config": "^8.8.2",
|
|
38
40
|
"@types/node": "^26",
|
|
39
|
-
"@vitest/coverage-v8": "^
|
|
41
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
40
42
|
"@vitest/eslint-plugin": "^1.6.27",
|
|
41
43
|
"eslint": "^10.8.1",
|
|
42
44
|
"eslint-plugin-n": "^18.3.0",
|
|
43
45
|
"globals": "^17.11.0",
|
|
44
|
-
"tsdown": "^0.
|
|
45
|
-
"tsx": "4.23.
|
|
46
|
+
"tsdown": "^0.23.3",
|
|
47
|
+
"tsx": "4.23.15",
|
|
46
48
|
"typescript": "^5.9.3",
|
|
47
|
-
"vitest": "^
|
|
48
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
49
|
+
"vitest": "^5.0.5",
|
|
50
|
+
"@theholocron/cli": "5.0.0-alpha.250"
|
|
49
51
|
},
|
|
50
52
|
"peerDependencies": {
|
|
51
|
-
"@theholocron/
|
|
53
|
+
"@theholocron/axiom-client": "^1.43.1",
|
|
54
|
+
"@theholocron/misc-utils": "^1.16.0",
|
|
55
|
+
"@theholocron/cli": "5.0.0-alpha.250"
|
|
52
56
|
},
|
|
53
57
|
"engines": {
|
|
54
58
|
"node": ">=22"
|