@theholocron/axiom-client 1.58.0-alpha.63 → 1.58.0-alpha.64
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 +40 -1
- package/dist/index.mjs +14 -0
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -8,6 +8,11 @@ interface AxiomClientOptions {
|
|
|
8
8
|
baseUrl?: string;
|
|
9
9
|
/** Override fetch for testing. Defaults to globalThis.fetch. */
|
|
10
10
|
fetch?: typeof fetch;
|
|
11
|
+
/**
|
|
12
|
+
* The organization id, sent as `X-Axiom-Org-Id`. A personal access token needs it; an API token does not (and when it
|
|
13
|
+
* is sent it must match the token's organization).
|
|
14
|
+
*/
|
|
15
|
+
orgId?: string;
|
|
11
16
|
/** Structured logger for request/response diagnostics. Defaults to a no-op. */
|
|
12
17
|
logger?: Logger;
|
|
13
18
|
/** Reports transport failures and unexpected 5xx. Defaults to a no-op. */
|
|
@@ -45,6 +50,37 @@ interface AxiomQueryInput {
|
|
|
45
50
|
/** The end of the time range, an RFC 3339 time. */
|
|
46
51
|
endTime?: string;
|
|
47
52
|
}
|
|
53
|
+
/** What a token may do with one capability of a dataset: `Access` is always `allow`, `Actions` the verbs. */
|
|
54
|
+
interface AxiomCapability {
|
|
55
|
+
/** Always `allow`: a token is only ever granted capabilities, never denied them. */
|
|
56
|
+
Access: "allow";
|
|
57
|
+
/** The verbs the token may use: `create` for ingest, `read` for query, and so on. */
|
|
58
|
+
Actions: ("create" | "read" | "update" | "delete")[];
|
|
59
|
+
}
|
|
60
|
+
/** What to make an API token with (`POST /v2/tokens`). */
|
|
61
|
+
interface CreateAxiomTokenInput {
|
|
62
|
+
/** The token's name. */
|
|
63
|
+
name: string;
|
|
64
|
+
/** A description for the token. */
|
|
65
|
+
description?: string;
|
|
66
|
+
/** When the token stops working (ISO 8601). Omitted, the token never expires. */
|
|
67
|
+
expiresAt?: string;
|
|
68
|
+
/** Dataset name to capability name (`ingest`, `query`) to what the token may do with it. */
|
|
69
|
+
datasetCapabilities?: Record<string, Record<string, AxiomCapability>>;
|
|
70
|
+
/** Organization capabilities (`dashboards`, `monitors`, ...). Omit to grant none. */
|
|
71
|
+
orgCapabilities?: Record<string, AxiomCapability>;
|
|
72
|
+
}
|
|
73
|
+
/** A token Axiom made. `token` is its secret, returned once. */
|
|
74
|
+
interface AxiomCreatedToken {
|
|
75
|
+
/** The token's id (not its value). */
|
|
76
|
+
id: string;
|
|
77
|
+
/** The token's name. */
|
|
78
|
+
name: string;
|
|
79
|
+
/** When the token stops working, when it has an expiry. */
|
|
80
|
+
expiresAt?: string;
|
|
81
|
+
/** The secret value. Axiom returns it only on creation and cannot show it again. */
|
|
82
|
+
token?: string;
|
|
83
|
+
}
|
|
48
84
|
/** The user the Axiom token belongs to. */
|
|
49
85
|
interface AxiomUser {
|
|
50
86
|
/** The user id. */
|
|
@@ -65,10 +101,13 @@ export declare function createAxiomClient(opts: AxiomClientOptions): {
|
|
|
65
101
|
query: (input: AxiomQueryInput) => Promise<unknown>;
|
|
66
102
|
create: (input: CreateAxiomDatasetInput) => Promise<AxiomDataset>;
|
|
67
103
|
};
|
|
104
|
+
tokens: {
|
|
105
|
+
create: (input: CreateAxiomTokenInput) => Promise<AxiomCreatedToken>;
|
|
106
|
+
};
|
|
68
107
|
user: {
|
|
69
108
|
me: () => Promise<AxiomUser>;
|
|
70
109
|
};
|
|
71
110
|
};
|
|
72
111
|
/** The client `createAxiomClient` returns. */
|
|
73
112
|
export type AxiomClient = ReturnType<typeof createAxiomClient>;
|
|
74
|
-
export type { AxiomClientOptions, AxiomDataset, AxiomQueryInput, AxiomUser, CreateAxiomDatasetInput };
|
|
113
|
+
export type { AxiomCapability, AxiomClientOptions, AxiomCreatedToken, AxiomDataset, AxiomQueryInput, AxiomUser, CreateAxiomDatasetInput, CreateAxiomTokenInput };
|
package/dist/index.mjs
CHANGED
|
@@ -28,6 +28,18 @@ function datasets(rest) {
|
|
|
28
28
|
})
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
+
// src/tokens/tokens.ts
|
|
32
|
+
function tokens(rest) {
|
|
33
|
+
return {
|
|
34
|
+
/**
|
|
35
|
+
* Make an API token (`POST /v2/tokens`). The caller needs a personal access token and the organization id
|
|
36
|
+
* (`orgId` on the client), and can grant only capabilities it holds itself. The secret `token` is in the answer once.
|
|
37
|
+
*/
|
|
38
|
+
create: (input) => rest.request("/v2/tokens", {
|
|
39
|
+
method: "POST",
|
|
40
|
+
body: input
|
|
41
|
+
}) };
|
|
42
|
+
}
|
|
31
43
|
// src/user/user.ts
|
|
32
44
|
function user(rest) {
|
|
33
45
|
return {
|
|
@@ -41,6 +53,7 @@ function createAxiomRestClient(opts) {
|
|
|
41
53
|
token: opts.token,
|
|
42
54
|
vendor: "Axiom",
|
|
43
55
|
fetch: opts.fetch,
|
|
56
|
+
...opts.orgId ? { extraHeaders: { "x-axiom-org-id": opts.orgId } } : {},
|
|
44
57
|
logger: opts.logger,
|
|
45
58
|
errors: opts.errors
|
|
46
59
|
});
|
|
@@ -51,6 +64,7 @@ function createAxiomClient(opts) {
|
|
|
51
64
|
const rest = createAxiomRestClient(opts);
|
|
52
65
|
return {
|
|
53
66
|
datasets: datasets(rest),
|
|
67
|
+
tokens: tokens(rest),
|
|
54
68
|
user: user(rest)
|
|
55
69
|
};
|
|
56
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/axiom-client",
|
|
3
|
-
"version": "1.58.0-alpha.
|
|
3
|
+
"version": "1.58.0-alpha.64",
|
|
4
4
|
"description": "A TypeScript client for the Axiom API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"axiom",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@theholocron/http-client": "^1.58.0-alpha.
|
|
35
|
+
"@theholocron/http-client": "^1.58.0-alpha.64",
|
|
36
36
|
"@theholocron/observability": "^0.7.0-alpha.8"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"tsdown": "^0.23.7",
|
|
46
46
|
"typescript": "^6.0.3",
|
|
47
47
|
"vitest": "^5.1.1",
|
|
48
|
-
"@theholocron/eslint-config": "^8.9.0-alpha.24",
|
|
49
48
|
"@theholocron/tsconfig": "^8.9.0-alpha.24",
|
|
50
49
|
"@theholocron/tsdown-config": "^8.9.0-alpha.24",
|
|
50
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.24",
|
|
51
51
|
"@theholocron/vitest-config": "^8.9.0-alpha.24"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|