alchemy 2.0.0-beta.17 → 2.0.0-beta.19
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/bin/alchemy.js +428 -80
- package/bin/alchemy.js.map +1 -1
- package/bin/alchemy.ts +2 -0
- package/bin/commands/_shared.ts +34 -0
- package/bin/commands/bootstrap.ts +10 -3
- package/bin/commands/deploy.ts +23 -3
- package/bin/commands/login.ts +18 -3
- package/bin/commands/logs.ts +11 -2
- package/bin/commands/profile.ts +11 -5
- package/bin/commands/state.ts +21 -13
- package/bin/commands/tail.ts +10 -2
- package/lib/AWS/CloudFront/CachePolicy.d.ts +106 -0
- package/lib/AWS/CloudFront/CachePolicy.d.ts.map +1 -0
- package/lib/AWS/CloudFront/CachePolicy.js +147 -0
- package/lib/AWS/CloudFront/CachePolicy.js.map +1 -0
- package/lib/AWS/CloudFront/KeyGroup.d.ts +72 -0
- package/lib/AWS/CloudFront/KeyGroup.d.ts.map +1 -0
- package/lib/AWS/CloudFront/KeyGroup.js +136 -0
- package/lib/AWS/CloudFront/KeyGroup.js.map +1 -0
- package/lib/AWS/CloudFront/OriginRequestPolicy.d.ts +84 -0
- package/lib/AWS/CloudFront/OriginRequestPolicy.d.ts.map +1 -0
- package/lib/AWS/CloudFront/OriginRequestPolicy.js +139 -0
- package/lib/AWS/CloudFront/OriginRequestPolicy.js.map +1 -0
- package/lib/AWS/CloudFront/PublicKey.d.ts +72 -0
- package/lib/AWS/CloudFront/PublicKey.d.ts.map +1 -0
- package/lib/AWS/CloudFront/PublicKey.js +137 -0
- package/lib/AWS/CloudFront/PublicKey.js.map +1 -0
- package/lib/AWS/CloudFront/ResponseHeadersPolicy.d.ts +114 -0
- package/lib/AWS/CloudFront/ResponseHeadersPolicy.d.ts.map +1 -0
- package/lib/AWS/CloudFront/ResponseHeadersPolicy.js +162 -0
- package/lib/AWS/CloudFront/ResponseHeadersPolicy.js.map +1 -0
- package/lib/AWS/CloudFront/index.d.ts +5 -0
- package/lib/AWS/CloudFront/index.d.ts.map +1 -1
- package/lib/AWS/CloudFront/index.js +5 -0
- package/lib/AWS/CloudFront/index.js.map +1 -1
- package/lib/AWS/ECS/CapacityProvider.d.ts +102 -0
- package/lib/AWS/ECS/CapacityProvider.d.ts.map +1 -0
- package/lib/AWS/ECS/CapacityProvider.js +217 -0
- package/lib/AWS/ECS/CapacityProvider.js.map +1 -0
- package/lib/AWS/ECS/index.d.ts +1 -0
- package/lib/AWS/ECS/index.d.ts.map +1 -1
- package/lib/AWS/ECS/index.js +1 -0
- package/lib/AWS/ECS/index.js.map +1 -1
- package/lib/AWS/Providers.d.ts.map +1 -1
- package/lib/AWS/Providers.js +7 -1
- package/lib/AWS/Providers.js.map +1 -1
- package/lib/Agent/lsp/client.d.ts +2 -2
- package/lib/Apply.d.ts.map +1 -1
- package/lib/Apply.js +41 -9
- package/lib/Apply.js.map +1 -1
- package/lib/Axiom/Annotation.d.ts +49 -0
- package/lib/Axiom/Annotation.d.ts.map +1 -0
- package/lib/Axiom/Annotation.js +74 -0
- package/lib/Axiom/Annotation.js.map +1 -0
- package/lib/Axiom/ApiToken.d.ts +62 -0
- package/lib/Axiom/ApiToken.d.ts.map +1 -0
- package/lib/Axiom/ApiToken.js +98 -0
- package/lib/Axiom/ApiToken.js.map +1 -0
- package/lib/Axiom/AuthProvider.d.ts +48 -0
- package/lib/Axiom/AuthProvider.d.ts.map +1 -0
- package/lib/Axiom/AuthProvider.js +177 -0
- package/lib/Axiom/AuthProvider.js.map +1 -0
- package/lib/Axiom/Chart.d.ts +72 -0
- package/lib/Axiom/Chart.d.ts.map +1 -0
- package/lib/Axiom/Chart.js +14 -0
- package/lib/Axiom/Chart.js.map +1 -0
- package/lib/Axiom/Credentials.d.ts +12 -0
- package/lib/Axiom/Credentials.d.ts.map +1 -0
- package/lib/Axiom/Credentials.js +34 -0
- package/lib/Axiom/Credentials.js.map +1 -0
- package/lib/Axiom/Dashboard.d.ts +124 -0
- package/lib/Axiom/Dashboard.d.ts.map +1 -0
- package/lib/Axiom/Dashboard.js +140 -0
- package/lib/Axiom/Dashboard.js.map +1 -0
- package/lib/Axiom/Dataset.d.ts +101 -0
- package/lib/Axiom/Dataset.d.ts.map +1 -0
- package/lib/Axiom/Dataset.js +183 -0
- package/lib/Axiom/Dataset.js.map +1 -0
- package/lib/Axiom/Monitor.d.ts +74 -0
- package/lib/Axiom/Monitor.d.ts.map +1 -0
- package/lib/Axiom/Monitor.js +103 -0
- package/lib/Axiom/Monitor.js.map +1 -0
- package/lib/Axiom/Notifier.d.ts +63 -0
- package/lib/Axiom/Notifier.d.ts.map +1 -0
- package/lib/Axiom/Notifier.js +83 -0
- package/lib/Axiom/Notifier.js.map +1 -0
- package/lib/Axiom/Providers.d.ts +15 -0
- package/lib/Axiom/Providers.d.ts.map +1 -0
- package/lib/Axiom/Providers.js +32 -0
- package/lib/Axiom/Providers.js.map +1 -0
- package/lib/Axiom/View.d.ts +55 -0
- package/lib/Axiom/View.d.ts.map +1 -0
- package/lib/Axiom/View.js +79 -0
- package/lib/Axiom/View.js.map +1 -0
- package/lib/Axiom/VirtualField.d.ts +42 -0
- package/lib/Axiom/VirtualField.d.ts.map +1 -0
- package/lib/Axiom/VirtualField.js +71 -0
- package/lib/Axiom/VirtualField.js.map +1 -0
- package/lib/Axiom/index.d.ts +13 -0
- package/lib/Axiom/index.d.ts.map +1 -0
- package/lib/Axiom/index.js +13 -0
- package/lib/Axiom/index.js.map +1 -0
- package/lib/Bundle/Bundle.d.ts +20 -2
- package/lib/Bundle/Bundle.d.ts.map +1 -1
- package/lib/Bundle/Bundle.js +18 -3
- package/lib/Bundle/Bundle.js.map +1 -1
- package/lib/Bundle/PurePlugin.d.ts +109 -0
- package/lib/Bundle/PurePlugin.d.ts.map +1 -0
- package/lib/Bundle/PurePlugin.js +469 -0
- package/lib/Bundle/PurePlugin.js.map +1 -0
- package/lib/Bundle/index.d.ts +1 -0
- package/lib/Bundle/index.d.ts.map +1 -1
- package/lib/Bundle/index.js +1 -0
- package/lib/Bundle/index.js.map +1 -1
- package/lib/Cloudflare/Workers/Worker.d.ts +12 -0
- package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Worker.js +19 -4
- package/lib/Cloudflare/Workers/Worker.js.map +1 -1
- package/lib/GitHub/Secrets.d.ts +45 -0
- package/lib/GitHub/Secrets.d.ts.map +1 -0
- package/lib/GitHub/Secrets.js +30 -0
- package/lib/GitHub/Secrets.js.map +1 -0
- package/lib/GitHub/index.d.ts +1 -0
- package/lib/GitHub/index.d.ts.map +1 -1
- package/lib/GitHub/index.js +1 -0
- package/lib/GitHub/index.js.map +1 -1
- package/lib/Output.d.ts.map +1 -1
- package/lib/Output.js +1 -1
- package/lib/Output.js.map +1 -1
- package/lib/Plan.d.ts.map +1 -1
- package/lib/Plan.js +10 -4
- package/lib/Plan.js.map +1 -1
- package/lib/Resource.d.ts +2 -2
- package/lib/Resource.d.ts.map +1 -1
- package/lib/Telemetry/Attributes.d.ts +43 -0
- package/lib/Telemetry/Attributes.d.ts.map +1 -0
- package/lib/Telemetry/Attributes.js +144 -0
- package/lib/Telemetry/Attributes.js.map +1 -0
- package/lib/Telemetry/Layer.d.ts +14 -0
- package/lib/Telemetry/Layer.d.ts.map +1 -0
- package/lib/Telemetry/Layer.js +50 -0
- package/lib/Telemetry/Layer.js.map +1 -0
- package/lib/Telemetry/Metrics.d.ts +34 -0
- package/lib/Telemetry/Metrics.d.ts.map +1 -0
- package/lib/Telemetry/Metrics.js +57 -0
- package/lib/Telemetry/Metrics.js.map +1 -0
- package/package.json +12 -1
- package/src/AWS/CloudFront/CachePolicy.ts +271 -0
- package/src/AWS/CloudFront/KeyGroup.ts +233 -0
- package/src/AWS/CloudFront/OriginRequestPolicy.ts +256 -0
- package/src/AWS/CloudFront/PublicKey.ts +245 -0
- package/src/AWS/CloudFront/ResponseHeadersPolicy.ts +308 -0
- package/src/AWS/CloudFront/index.ts +11 -0
- package/src/AWS/ECS/CapacityProvider.ts +336 -0
- package/src/AWS/ECS/index.ts +4 -0
- package/src/AWS/Providers.ts +12 -0
- package/src/Apply.ts +118 -9
- package/src/Axiom/Annotation.ts +95 -0
- package/src/Axiom/ApiToken.ts +125 -0
- package/src/Axiom/AuthProvider.ts +341 -0
- package/src/Axiom/Chart.ts +94 -0
- package/src/Axiom/Credentials.ts +70 -0
- package/src/Axiom/Dashboard.ts +192 -0
- package/src/Axiom/Dataset.ts +291 -0
- package/src/Axiom/Monitor.ts +122 -0
- package/src/Axiom/Notifier.ts +104 -0
- package/src/Axiom/Providers.ts +58 -0
- package/src/Axiom/View.ts +106 -0
- package/src/Axiom/VirtualField.ts +90 -0
- package/src/Axiom/index.ts +12 -0
- package/src/Bundle/Bundle.ts +39 -1
- package/src/Bundle/PurePlugin.ts +556 -0
- package/src/Bundle/index.ts +1 -0
- package/src/Cloudflare/Workers/Worker.ts +37 -6
- package/src/GitHub/Secrets.ts +66 -0
- package/src/GitHub/index.ts +1 -0
- package/src/Output.ts +2 -1
- package/src/Plan.ts +13 -4
- package/src/Resource.ts +2 -2
- package/src/Telemetry/Attributes.ts +216 -0
- package/src/Telemetry/Layer.ts +65 -0
- package/src/Telemetry/Metrics.ts +101 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import * as Console from "effect/Console";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as FileSystem from "effect/FileSystem";
|
|
4
|
+
import * as Match from "effect/Match";
|
|
5
|
+
import * as Redacted from "effect/Redacted";
|
|
6
|
+
import { AuthError, AuthProviderLayer, } from "../Auth/AuthProvider.js";
|
|
7
|
+
import { deleteCredentials, displayRedacted, readCredentials, writeCredentials, } from "../Auth/Credentials.js";
|
|
8
|
+
import { getEnv, getEnvRedacted, retryOnce } from "../Auth/Env.js";
|
|
9
|
+
import * as Clank from "../Util/Clank.js";
|
|
10
|
+
import { DEFAULT_API_BASE_URL } from "@distilled.cloud/axiom/Credentials";
|
|
11
|
+
const STORAGE_KEY = "axiom-stored";
|
|
12
|
+
const options = [
|
|
13
|
+
{
|
|
14
|
+
value: "env",
|
|
15
|
+
label: "Environment Variables",
|
|
16
|
+
hint: "AXIOM_TOKEN (or AXIOM_API_KEY) + optional AXIOM_ORG_ID, AXIOM_URL",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
value: "stored",
|
|
20
|
+
label: "API Token or Personal Access Token",
|
|
21
|
+
hint: "enter credentials interactively, stored in ~/.alchemy/credentials",
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
export const AXIOM_AUTH_PROVIDER_NAME = "Axiom";
|
|
25
|
+
/**
|
|
26
|
+
* Layer that registers the Axiom {@link AuthProvider} into the
|
|
27
|
+
* {@link AuthProviders} registry when built. Include this in the Axiom
|
|
28
|
+
* `providers()` layer so `alchemy login` can discover it.
|
|
29
|
+
*/
|
|
30
|
+
export const AxiomAuth = AuthProviderLayer()(AXIOM_AUTH_PROVIDER_NAME, {
|
|
31
|
+
configure: (profileName, ctx) => configureCredentials(profileName, ctx),
|
|
32
|
+
logout: (profileName, config) => logout(profileName, config),
|
|
33
|
+
login: (profileName, config) => login(profileName, config),
|
|
34
|
+
prettyPrint: (profileName, config) => prettyPrint(profileName, config),
|
|
35
|
+
read: (profileName, config) => resolveCredentials(profileName, config),
|
|
36
|
+
});
|
|
37
|
+
const resolveCredentials = (profileName, config) => Match.value(config).pipe(Match.when({ method: "env" }, Effect.fnUntraced(function* () {
|
|
38
|
+
const apiToken = (yield* getEnvRedacted("AXIOM_TOKEN")) ??
|
|
39
|
+
(yield* getEnvRedacted("AXIOM_API_KEY"));
|
|
40
|
+
if (!apiToken) {
|
|
41
|
+
return yield* new AuthError({
|
|
42
|
+
message: "Axiom env credentials not found. Set AXIOM_TOKEN (or AXIOM_API_KEY).",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const apiBaseUrl = (yield* getEnv("AXIOM_URL")) ?? DEFAULT_API_BASE_URL;
|
|
46
|
+
const orgId = yield* getEnv("AXIOM_ORG_ID");
|
|
47
|
+
if (orgId) {
|
|
48
|
+
return {
|
|
49
|
+
type: "pat",
|
|
50
|
+
apiToken,
|
|
51
|
+
apiBaseUrl,
|
|
52
|
+
orgId,
|
|
53
|
+
source: { type: "env" },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
type: "apiToken",
|
|
58
|
+
apiToken,
|
|
59
|
+
apiBaseUrl,
|
|
60
|
+
source: { type: "env" },
|
|
61
|
+
};
|
|
62
|
+
})), Match.when({ method: "stored" }, () => readCredentials(profileName, STORAGE_KEY).pipe(Effect.flatMap((creds) => creds == null
|
|
63
|
+
? Effect.fail(new AuthError({
|
|
64
|
+
message: "Axiom stored credentials not found. Run: alchemy login --configure",
|
|
65
|
+
}))
|
|
66
|
+
: Effect.succeed(Match.value(creds).pipe(Match.when({ type: "apiToken" }, (c) => ({
|
|
67
|
+
type: "apiToken",
|
|
68
|
+
apiToken: Redacted.make(c.apiToken),
|
|
69
|
+
apiBaseUrl: c.apiBaseUrl ?? DEFAULT_API_BASE_URL,
|
|
70
|
+
orgId: c.orgId,
|
|
71
|
+
source: { type: "stored" },
|
|
72
|
+
})), Match.when({ type: "pat" }, (c) => ({
|
|
73
|
+
type: "pat",
|
|
74
|
+
apiToken: Redacted.make(c.apiToken),
|
|
75
|
+
apiBaseUrl: c.apiBaseUrl ?? DEFAULT_API_BASE_URL,
|
|
76
|
+
orgId: c.orgId,
|
|
77
|
+
source: { type: "stored" },
|
|
78
|
+
})), Match.exhaustive))))), Match.exhaustive);
|
|
79
|
+
const logout = (profileName, config) => Match.value(config).pipe(Match.when({ method: "env" }, () => Effect.void), Match.when({ method: "stored" }, () => deleteCredentials(profileName, STORAGE_KEY).pipe(Effect.andThen(Clank.success("Axiom: stored credentials removed")))), Match.exhaustive);
|
|
80
|
+
const login = (profileName, config) => Match.value(config)
|
|
81
|
+
.pipe(Match.when({ method: "env" }, () => Effect.void), Match.when({ method: "stored" }, () => readCredentials(profileName, STORAGE_KEY).pipe(Effect.flatMap((creds) => creds == null ? loginStored(profileName) : Effect.void))), Match.exhaustive)
|
|
82
|
+
.pipe(Effect.mapError((e) => new AuthError({ message: "login failed", cause: e })));
|
|
83
|
+
const configureCredentials = (profileName, ctx) => Effect.gen(function* () {
|
|
84
|
+
if (ctx.ci) {
|
|
85
|
+
return { method: "env" };
|
|
86
|
+
}
|
|
87
|
+
return yield* configureInteractive(profileName);
|
|
88
|
+
}).pipe(Effect.mapError((e) => new AuthError({
|
|
89
|
+
message: "failed to configure credentials",
|
|
90
|
+
cause: e,
|
|
91
|
+
})));
|
|
92
|
+
const configureInteractive = (profileName) => Clank.select({
|
|
93
|
+
message: "Axiom authentication method",
|
|
94
|
+
options,
|
|
95
|
+
}).pipe(Effect.flatMap((method) => Match.value(method).pipe(Match.when("env", () => Effect.succeed({ method: "env" })), Match.when("stored", () => loginStored(profileName)), Match.exhaustive)));
|
|
96
|
+
const loginStored = Effect.fnUntraced(function* (profileName) {
|
|
97
|
+
const credentialType = yield* Clank.select({
|
|
98
|
+
message: "Axiom credential type",
|
|
99
|
+
options: [
|
|
100
|
+
{
|
|
101
|
+
value: "apiToken",
|
|
102
|
+
label: "API Token",
|
|
103
|
+
hint: "recommended — scoped to specific datasets/actions",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
value: "pat",
|
|
107
|
+
label: "Personal Access Token",
|
|
108
|
+
hint: "full account control, requires Org ID",
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
}).pipe(retryOnce);
|
|
112
|
+
const apiBaseUrlPrompt = yield* Clank.text({
|
|
113
|
+
message: "Axiom API Base URL (Enter for default)",
|
|
114
|
+
placeholder: DEFAULT_API_BASE_URL,
|
|
115
|
+
defaultValue: DEFAULT_API_BASE_URL,
|
|
116
|
+
}).pipe(retryOnce);
|
|
117
|
+
const apiBaseUrl = apiBaseUrlPrompt && apiBaseUrlPrompt.length > 0
|
|
118
|
+
? apiBaseUrlPrompt
|
|
119
|
+
: undefined;
|
|
120
|
+
return yield* Match.value(credentialType).pipe(Match.when("apiToken", () => Effect.gen(function* () {
|
|
121
|
+
const apiToken = yield* Clank.password({
|
|
122
|
+
message: "Axiom API Token",
|
|
123
|
+
validate: (v) => (v.length === 0 ? "Required" : undefined),
|
|
124
|
+
}).pipe(retryOnce);
|
|
125
|
+
const orgId = yield* promptOrgId(false);
|
|
126
|
+
yield* writeCredentials(profileName, STORAGE_KEY, {
|
|
127
|
+
type: "apiToken",
|
|
128
|
+
apiToken,
|
|
129
|
+
apiBaseUrl,
|
|
130
|
+
orgId: orgId && orgId.length > 0 ? orgId : undefined,
|
|
131
|
+
});
|
|
132
|
+
yield* Clank.success("Axiom: credentials saved.");
|
|
133
|
+
return {
|
|
134
|
+
method: "stored",
|
|
135
|
+
credentialType: "apiToken",
|
|
136
|
+
};
|
|
137
|
+
})), Match.when("pat", () => Effect.gen(function* () {
|
|
138
|
+
const apiToken = yield* Clank.password({
|
|
139
|
+
message: "Axiom Personal Access Token",
|
|
140
|
+
validate: (v) => (v.length === 0 ? "Required" : undefined),
|
|
141
|
+
}).pipe(retryOnce);
|
|
142
|
+
const orgId = yield* promptOrgId(true);
|
|
143
|
+
yield* writeCredentials(profileName, STORAGE_KEY, { type: "pat", apiToken, apiBaseUrl, orgId });
|
|
144
|
+
yield* Clank.success("Axiom: credentials saved.");
|
|
145
|
+
return {
|
|
146
|
+
method: "stored",
|
|
147
|
+
credentialType: "pat",
|
|
148
|
+
};
|
|
149
|
+
})), Match.exhaustive);
|
|
150
|
+
});
|
|
151
|
+
const promptOrgId = (required) => getEnv("AXIOM_ORG_ID").pipe(Effect.flatMap((envOrgId) => Clank.text({
|
|
152
|
+
message: required
|
|
153
|
+
? "Axiom Org ID (required for PAT)"
|
|
154
|
+
: "Axiom Org ID (Enter to skip)",
|
|
155
|
+
placeholder: envOrgId ?? "",
|
|
156
|
+
defaultValue: envOrgId ?? "",
|
|
157
|
+
validate: required
|
|
158
|
+
? (v) => (v.length === 0 ? "Required" : undefined)
|
|
159
|
+
: undefined,
|
|
160
|
+
}).pipe(retryOnce)));
|
|
161
|
+
const prettyPrint = (profileName, config) => resolveCredentials(profileName, config).pipe(Effect.tap((creds) => {
|
|
162
|
+
const sourceStr = creds.source.details
|
|
163
|
+
? `${creds.source.type} - ${creds.source.details}`
|
|
164
|
+
: creds.source.type;
|
|
165
|
+
return Match.value(creds).pipe(Match.when({ type: "apiToken" }, (c) => Effect.all([
|
|
166
|
+
Console.log(` apiToken: ${displayRedacted(c.apiToken, 9)}`),
|
|
167
|
+
Console.log(` apiBaseUrl: ${c.apiBaseUrl}`),
|
|
168
|
+
Console.log(` orgId: ${c.orgId ?? "(none)"}`),
|
|
169
|
+
Console.log(` source: ${sourceStr}`),
|
|
170
|
+
])), Match.when({ type: "pat" }, (c) => Effect.all([
|
|
171
|
+
Console.log(` apiToken: ${displayRedacted(c.apiToken, 9)}`),
|
|
172
|
+
Console.log(` apiBaseUrl: ${c.apiBaseUrl}`),
|
|
173
|
+
Console.log(` orgId: ${c.orgId}`),
|
|
174
|
+
Console.log(` source: ${sourceStr}`),
|
|
175
|
+
])), Match.exhaustive);
|
|
176
|
+
}), Effect.catch((e) => Console.error(` Failed to retrieve credentials: ${e}`)));
|
|
177
|
+
//# sourceMappingURL=AuthProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthProvider.js","sourceRoot":"","sources":["../../src/Axiom/AuthProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,SAAS,EACT,iBAAiB,GAElB,MAAM,yBAAyB,CAAC;A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AS,EAAE,CAAC;KACtC,CAAC,CACH,EACD,KAAK,CAAC,UAAU,CACjB,CAAC;AACJ,CAAC,CAAC,EACF,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CACjB,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,EAAE,CAAC,CACxD,CACF,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed view of the Axiom dashboard chart-JSON subset.
|
|
3
|
+
*
|
|
4
|
+
* Axiom's `CreateDashboardInput` declares
|
|
5
|
+
* `dashboard.charts: ReadonlyArray<unknown>` (see
|
|
6
|
+
* `@distilled.cloud/axiom/.../v2/createDashboard.ts`); these
|
|
7
|
+
* interfaces give callers compile-time safety when building the
|
|
8
|
+
* payload by hand.
|
|
9
|
+
*
|
|
10
|
+
* `chart.id` is a free-form string the author picks — Axiom
|
|
11
|
+
* doesn't validate the format. It joins to the matching
|
|
12
|
+
* `LayoutCell.i` in `dashboard.layout`.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Axiom-validated chart kinds. Discovered by probing
|
|
16
|
+
* `POST /v2/dashboards`: anything else returns
|
|
17
|
+
* `dashboard validation failed at [charts N type]: Invalid input`.
|
|
18
|
+
*/
|
|
19
|
+
export type ChartKind = "TimeSeries" | "Table" | "Pie" | "Statistic" | "Heatmap" | "LogStream" | "Note";
|
|
20
|
+
/**
|
|
21
|
+
* Minimum chart payload Axiom's `POST /v2/dashboards` accepts.
|
|
22
|
+
* Any unknown keys (e.g. `dataset`, `description`) trigger
|
|
23
|
+
* `Unrecognized keys: "<name>"`, so this struct is intentionally
|
|
24
|
+
* narrow. The dataset is implicit via the APL query.
|
|
25
|
+
*/
|
|
26
|
+
export interface BaseChart {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly type: ChartKind;
|
|
30
|
+
readonly query: {
|
|
31
|
+
readonly apl: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface TimeSeriesChart extends BaseChart {
|
|
35
|
+
readonly type: "TimeSeries";
|
|
36
|
+
}
|
|
37
|
+
export interface TableChart extends BaseChart {
|
|
38
|
+
readonly type: "Table";
|
|
39
|
+
}
|
|
40
|
+
export interface PieChart extends BaseChart {
|
|
41
|
+
readonly type: "Pie";
|
|
42
|
+
}
|
|
43
|
+
export interface StatisticChart extends BaseChart {
|
|
44
|
+
readonly type: "Statistic";
|
|
45
|
+
}
|
|
46
|
+
export interface HeatmapChart extends BaseChart {
|
|
47
|
+
readonly type: "Heatmap";
|
|
48
|
+
}
|
|
49
|
+
export interface LogStreamChart extends BaseChart {
|
|
50
|
+
readonly type: "LogStream";
|
|
51
|
+
}
|
|
52
|
+
export interface NoteChart extends BaseChart {
|
|
53
|
+
readonly type: "Note";
|
|
54
|
+
}
|
|
55
|
+
export type Chart = TimeSeriesChart | TableChart | PieChart | StatisticChart | HeatmapChart | LogStreamChart | NoteChart;
|
|
56
|
+
/**
|
|
57
|
+
* Mirrors Axiom's `CreateDashboardInput.dashboard.layout` cell schema.
|
|
58
|
+
* `i` references a chart by its `id`.
|
|
59
|
+
*/
|
|
60
|
+
export interface LayoutCell {
|
|
61
|
+
readonly i: string;
|
|
62
|
+
readonly x: number;
|
|
63
|
+
readonly y: number | null;
|
|
64
|
+
readonly w: number;
|
|
65
|
+
readonly h: number;
|
|
66
|
+
readonly minW?: number;
|
|
67
|
+
readonly minH?: number;
|
|
68
|
+
readonly maxW?: number;
|
|
69
|
+
readonly maxH?: number;
|
|
70
|
+
readonly static?: boolean;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=Chart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../src/Axiom/Chart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,OA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AAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed view of the Axiom dashboard chart-JSON subset.
|
|
3
|
+
*
|
|
4
|
+
* Axiom's `CreateDashboardInput` declares
|
|
5
|
+
* `dashboard.charts: ReadonlyArray<unknown>` (see
|
|
6
|
+
* `@distilled.cloud/axiom/.../v2/createDashboard.ts`); these
|
|
7
|
+
* interfaces give callers compile-time safety when building the
|
|
8
|
+
* payload by hand.
|
|
9
|
+
*
|
|
10
|
+
* `chart.id` is a free-form string the author picks — Axiom
|
|
11
|
+
* doesn't validate the format. It joins to the matching
|
|
12
|
+
* `LayoutCell.i` in `dashboard.layout`.
|
|
13
|
+
*/
|
|
14
|
+
//# sourceMappingURL=Chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chart.js","sourceRoot":"","sources":["../../src/Axiom/Chart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Credentials } from "@distilled.cloud/axiom/Credentials";
|
|
2
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Config from "effect/Config";
|
|
5
|
+
export { Credentials, CredentialsFromEnv, DEFAULT_API_BASE_URL, } from "@distilled.cloud/axiom/Credentials";
|
|
6
|
+
/**
|
|
7
|
+
* Build a `Credentials` layer that resolves Axiom credentials via the Alchemy
|
|
8
|
+
* AuthProvider using the configured profile (defaults to "default", overridable
|
|
9
|
+
* with the `ALCHEMY_PROFILE` env/config value).
|
|
10
|
+
*/
|
|
11
|
+
export declare const fromAuthProvider: () => Layer.Layer<Credentials, Config.ConfigError | import("../Auth/AuthProvider.ts").AuthError | ConfigError, import("effect/FileSystem").FileSystem | import("../Auth/AuthProvider.ts").AuthProviders>;
|
|
12
|
+
//# sourceMappingURL=Credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Credentials.d.ts","sourceRoot":"","sources":["../../src/Axiom/Credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AASxC,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,oCAAoC,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,0MAwC1B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Credentials, DEFAULT_API_BASE_URL, } from "@distilled.cloud/axiom/Credentials";
|
|
2
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import * as Match from "effect/Match";
|
|
6
|
+
import * as Redacted from "effect/Redacted";
|
|
7
|
+
import * as Config from "effect/Config";
|
|
8
|
+
import { getAuthProvider } from "../Auth/AuthProvider.js";
|
|
9
|
+
import { ALCHEMY_PROFILE, loadOrConfigure } from "../Auth/Profile.js";
|
|
10
|
+
import { AXIOM_AUTH_PROVIDER_NAME, } from "./AuthProvider.js";
|
|
11
|
+
export { Credentials, CredentialsFromEnv, DEFAULT_API_BASE_URL, } from "@distilled.cloud/axiom/Credentials";
|
|
12
|
+
/**
|
|
13
|
+
* Build a `Credentials` layer that resolves Axiom credentials via the Alchemy
|
|
14
|
+
* AuthProvider using the configured profile (defaults to "default", overridable
|
|
15
|
+
* with the `ALCHEMY_PROFILE` env/config value).
|
|
16
|
+
*/
|
|
17
|
+
export const fromAuthProvider = () => Layer.effect(Credentials, Effect.gen(function* () {
|
|
18
|
+
const auth = yield* getAuthProvider(AXIOM_AUTH_PROVIDER_NAME);
|
|
19
|
+
const profileName = yield* ALCHEMY_PROFILE;
|
|
20
|
+
const ci = yield* Config.boolean("CI").pipe(Config.withDefault(false));
|
|
21
|
+
const ctx = yield* Effect.context();
|
|
22
|
+
return yield* loadOrConfigure(auth, profileName, { ci }).pipe(Effect.flatMap((config) => auth.read(profileName, config)), Effect.map((creds) => Match.value(creds).pipe(Match.when({ type: "apiToken" }, (c) => ({
|
|
23
|
+
apiKey: c.apiToken,
|
|
24
|
+
apiBaseUrl: c.apiBaseUrl,
|
|
25
|
+
orgId: c.orgId,
|
|
26
|
+
})), Match.when({ type: "pat" }, (c) => ({
|
|
27
|
+
apiKey: c.apiToken,
|
|
28
|
+
apiBaseUrl: c.apiBaseUrl,
|
|
29
|
+
orgId: c.orgId,
|
|
30
|
+
})), Match.exhaustive)), Effect.mapError((e) => new ConfigError({
|
|
31
|
+
message: `Failed to resolve Axiom credentials for profile '${profileName}': ${e.message ?? String(e)}`,
|
|
32
|
+
})), Effect.provide(ctx));
|
|
33
|
+
}));
|
|
34
|
+
//# sourceMappingURL=Credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Credentials.js","sourceRoot":"","sources":["../../src/Axiom/Credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,oBAAoB,GACrB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,MAAM,MAAM,eAAe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,CAAC,IAAI,CACrB,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACvC,MAAM,EAAE,CAAC,CAAC,QAAQ;QAClB,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,KAAK,EAAE,CAAC,CAAC,KAAK;KACf,CAAC,CAAC,EACH,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAClC,MAAM,EAAE,CAAC,CAAC,QAAQ;QAClB,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,KAAK,EAAE,CAAC,CAAC,KAAK;KACf,CAAC,CAAC,EACH,KAAK,CAAC,UAAU,CACjB,CACF,EACD,MAAM,CAAC,QAAQ,CACb,CAAC,CAAC,EAAE,EAAE,CACJ,IAAI,WAAW,CAAC;QACd,OAAO,EAAE,oDAAoD,WAAW,MAAO,CAA0B,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;KACjI,CAAC,CACL,EACD,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CACpB,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import * as Operations from "@distilled.cloud/axiom/Operations";
|
|
2
|
+
import * as Provider from "../Provider.ts";
|
|
3
|
+
import { Resource } from "../Resource.ts";
|
|
4
|
+
import type { Chart, LayoutCell } from "./Chart.ts";
|
|
5
|
+
import type { Providers } from "./Providers.ts";
|
|
6
|
+
type DashboardDoc = Operations.CreateDashboardInput["dashboard"];
|
|
7
|
+
/**
|
|
8
|
+
* Dashboard input. Mirrors `Operations.CreateDashboardInput` but
|
|
9
|
+
* narrows `dashboard.charts` and `dashboard.layout` to the typed
|
|
10
|
+
* {@link Chart} / {@link LayoutCell} shapes (Axiom declares them
|
|
11
|
+
* as `Schema.Array(Schema.Unknown)`, so this is a compile-time-only
|
|
12
|
+
* refinement; runtime validation is unchanged).
|
|
13
|
+
*/
|
|
14
|
+
export type DashboardProps = Omit<Operations.CreateDashboardInput, "dashboard"> & {
|
|
15
|
+
readonly dashboard: Omit<DashboardDoc, "charts" | "layout"> & {
|
|
16
|
+
readonly charts: readonly Chart[];
|
|
17
|
+
readonly layout: readonly LayoutCell[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type Dashboard = Resource<"Axiom.Dashboard", DashboardProps, {
|
|
21
|
+
/** Stable Axiom dashboard `uid` (used as the path identifier). */
|
|
22
|
+
uid: string;
|
|
23
|
+
id: string;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
createdBy: string;
|
|
26
|
+
updatedAt: string;
|
|
27
|
+
updatedBy: string;
|
|
28
|
+
/** The full dashboard document as returned by Axiom. */
|
|
29
|
+
dashboard: Operations.CreateDashboardOutput["dashboard"]["dashboard"];
|
|
30
|
+
}, never, Providers>;
|
|
31
|
+
/**
|
|
32
|
+
* An Axiom dashboard — a named, layout-driven collection of charts. Each
|
|
33
|
+
* dashboard takes a full document (`charts` + `layout` array of grid cells +
|
|
34
|
+
* `timeWindow` + `refreshTime`) at version `schemaVersion: 2`.
|
|
35
|
+
*
|
|
36
|
+
* Charts are typed via {@link Chart} (a discriminated union over the
|
|
37
|
+
* Axiom-validated chart kinds — `TimeSeries`, `Table`, `Pie`, `Statistic`,
|
|
38
|
+
* `Heatmap`, `LogStream`, `Note`). The `id` on each chart is a free-form
|
|
39
|
+
* string the author picks; layout cells join via `LayoutCell.i`.
|
|
40
|
+
*
|
|
41
|
+
* The path identifier is `uid` (auto-assigned by Axiom). `id` is also
|
|
42
|
+
* exposed as an output but the API uses `uid` everywhere.
|
|
43
|
+
*
|
|
44
|
+
* Notes from probing `POST /v2/dashboards`:
|
|
45
|
+
*
|
|
46
|
+
* - Relative time windows must use the `qr-now-{duration}` form (e.g.
|
|
47
|
+
* `"qr-now-7d"` / `"qr-now"`); plain `"now-7d"` is rejected.
|
|
48
|
+
* - When authenticating with an API token, `dashboard.owner` must be `""`
|
|
49
|
+
* (Axiom rewrites this to the org-shared `X-AXIOM-EVERYONE`); per-user
|
|
50
|
+
* "private" dashboards aren't allowed for tokens.
|
|
51
|
+
* - The chart payload is strict: only `id`, `name`, `type`, `query`. Extra
|
|
52
|
+
* keys (e.g. `dataset`, `description`) trigger
|
|
53
|
+
* `Unrecognized keys: "<name>"`.
|
|
54
|
+
*
|
|
55
|
+
* @see https://axiom.co/docs/query-data/dashboards
|
|
56
|
+
*
|
|
57
|
+
* @section Creating a Dashboard
|
|
58
|
+
* @example Minimal empty dashboard
|
|
59
|
+
* ```typescript
|
|
60
|
+
* yield* Axiom.Dashboard("ops", {
|
|
61
|
+
* dashboard: {
|
|
62
|
+
* name: "Ops Overview",
|
|
63
|
+
* owner: "", // org-shared (required for API tokens)
|
|
64
|
+
* description: "Top-level service health",
|
|
65
|
+
* charts: [],
|
|
66
|
+
* layout: [],
|
|
67
|
+
* refreshTime: 60, // seconds: 15 | 60 | 300
|
|
68
|
+
* schemaVersion: 2,
|
|
69
|
+
* timeWindowStart: "qr-now-1h",
|
|
70
|
+
* timeWindowEnd: "qr-now",
|
|
71
|
+
* },
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @example One-chart dashboard
|
|
76
|
+
* ```typescript
|
|
77
|
+
* import type { Chart, LayoutCell } from "alchemy/Axiom";
|
|
78
|
+
*
|
|
79
|
+
* const errors: Chart = {
|
|
80
|
+
* id: "errors-5m",
|
|
81
|
+
* name: "5xx errors / 5m",
|
|
82
|
+
* type: "TimeSeries",
|
|
83
|
+
* query: {
|
|
84
|
+
* apl: `['my-app-traces']
|
|
85
|
+
* | where status >= 500
|
|
86
|
+
* | summarize count() by bin_auto(_time)`,
|
|
87
|
+
* },
|
|
88
|
+
* };
|
|
89
|
+
*
|
|
90
|
+
* yield* Axiom.Dashboard("errors", {
|
|
91
|
+
* dashboard: {
|
|
92
|
+
* name: "Errors",
|
|
93
|
+
* owner: "",
|
|
94
|
+
* refreshTime: 60,
|
|
95
|
+
* schemaVersion: 2,
|
|
96
|
+
* timeWindowStart: "qr-now-24h",
|
|
97
|
+
* timeWindowEnd: "qr-now",
|
|
98
|
+
* charts: [errors],
|
|
99
|
+
* layout: [{ i: errors.id, x: 0, y: 0, w: 12, h: 6 } satisfies LayoutCell],
|
|
100
|
+
* },
|
|
101
|
+
* });
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @example Compare to last 24h
|
|
105
|
+
* ```typescript
|
|
106
|
+
* yield* Axiom.Dashboard("compare", {
|
|
107
|
+
* dashboard: {
|
|
108
|
+
* name: "Compare vs yesterday",
|
|
109
|
+
* owner: "",
|
|
110
|
+
* refreshTime: 300,
|
|
111
|
+
* schemaVersion: 2,
|
|
112
|
+
* timeWindowStart: "qr-now-1h",
|
|
113
|
+
* timeWindowEnd: "qr-now",
|
|
114
|
+
* against: "-1d", // overlay the same window from 24h ago
|
|
115
|
+
* charts: [],
|
|
116
|
+
* layout: [],
|
|
117
|
+
* },
|
|
118
|
+
* });
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare const Dashboard: import("../Resource.ts").ResourceClass<Dashboard>;
|
|
122
|
+
export declare const DashboardProvider: () => import("effect/Layer").Layer<Provider.Provider<Dashboard>, never, any>;
|
|
123
|
+
export {};
|
|
124
|
+
//# sourceMappingURL=Dashboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../src/Axiom/Dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,mCAAmC,CAAC;AAEhE,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,KAAK,YAAY,GAAG,UAAU,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,UAAU,CAAC,oBAAoB,EAC/B,WAAW,CACZ,GAAG;IACF,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,GAAG,QAAQ,CAAC,GAAG;QAC5D,QAAQ,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;QAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;KACxC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,QAAQ,CAC9B,iBAAiB,EACjB,cAAc,EACd;IACE,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,SAAS,EAAE,UAAU,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,CAAC;CACvE,EACD,KAAK,EACL,SAAS,CACV,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFG;AACH,eAAO,MAAM,SAAS,mDAAyC,CAAC;AAEhE,eAAO,MAAM,iBAAiB,8EAuD3B,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import * as Operations from "@distilled.cloud/axiom/Operations";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Provider from "../Provider.js";
|
|
4
|
+
import { Resource } from "../Resource.js";
|
|
5
|
+
/**
|
|
6
|
+
* An Axiom dashboard — a named, layout-driven collection of charts. Each
|
|
7
|
+
* dashboard takes a full document (`charts` + `layout` array of grid cells +
|
|
8
|
+
* `timeWindow` + `refreshTime`) at version `schemaVersion: 2`.
|
|
9
|
+
*
|
|
10
|
+
* Charts are typed via {@link Chart} (a discriminated union over the
|
|
11
|
+
* Axiom-validated chart kinds — `TimeSeries`, `Table`, `Pie`, `Statistic`,
|
|
12
|
+
* `Heatmap`, `LogStream`, `Note`). The `id` on each chart is a free-form
|
|
13
|
+
* string the author picks; layout cells join via `LayoutCell.i`.
|
|
14
|
+
*
|
|
15
|
+
* The path identifier is `uid` (auto-assigned by Axiom). `id` is also
|
|
16
|
+
* exposed as an output but the API uses `uid` everywhere.
|
|
17
|
+
*
|
|
18
|
+
* Notes from probing `POST /v2/dashboards`:
|
|
19
|
+
*
|
|
20
|
+
* - Relative time windows must use the `qr-now-{duration}` form (e.g.
|
|
21
|
+
* `"qr-now-7d"` / `"qr-now"`); plain `"now-7d"` is rejected.
|
|
22
|
+
* - When authenticating with an API token, `dashboard.owner` must be `""`
|
|
23
|
+
* (Axiom rewrites this to the org-shared `X-AXIOM-EVERYONE`); per-user
|
|
24
|
+
* "private" dashboards aren't allowed for tokens.
|
|
25
|
+
* - The chart payload is strict: only `id`, `name`, `type`, `query`. Extra
|
|
26
|
+
* keys (e.g. `dataset`, `description`) trigger
|
|
27
|
+
* `Unrecognized keys: "<name>"`.
|
|
28
|
+
*
|
|
29
|
+
* @see https://axiom.co/docs/query-data/dashboards
|
|
30
|
+
*
|
|
31
|
+
* @section Creating a Dashboard
|
|
32
|
+
* @example Minimal empty dashboard
|
|
33
|
+
* ```typescript
|
|
34
|
+
* yield* Axiom.Dashboard("ops", {
|
|
35
|
+
* dashboard: {
|
|
36
|
+
* name: "Ops Overview",
|
|
37
|
+
* owner: "", // org-shared (required for API tokens)
|
|
38
|
+
* description: "Top-level service health",
|
|
39
|
+
* charts: [],
|
|
40
|
+
* layout: [],
|
|
41
|
+
* refreshTime: 60, // seconds: 15 | 60 | 300
|
|
42
|
+
* schemaVersion: 2,
|
|
43
|
+
* timeWindowStart: "qr-now-1h",
|
|
44
|
+
* timeWindowEnd: "qr-now",
|
|
45
|
+
* },
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example One-chart dashboard
|
|
50
|
+
* ```typescript
|
|
51
|
+
* import type { Chart, LayoutCell } from "alchemy/Axiom";
|
|
52
|
+
*
|
|
53
|
+
* const errors: Chart = {
|
|
54
|
+
* id: "errors-5m",
|
|
55
|
+
* name: "5xx errors / 5m",
|
|
56
|
+
* type: "TimeSeries",
|
|
57
|
+
* query: {
|
|
58
|
+
* apl: `['my-app-traces']
|
|
59
|
+
* | where status >= 500
|
|
60
|
+
* | summarize count() by bin_auto(_time)`,
|
|
61
|
+
* },
|
|
62
|
+
* };
|
|
63
|
+
*
|
|
64
|
+
* yield* Axiom.Dashboard("errors", {
|
|
65
|
+
* dashboard: {
|
|
66
|
+
* name: "Errors",
|
|
67
|
+
* owner: "",
|
|
68
|
+
* refreshTime: 60,
|
|
69
|
+
* schemaVersion: 2,
|
|
70
|
+
* timeWindowStart: "qr-now-24h",
|
|
71
|
+
* timeWindowEnd: "qr-now",
|
|
72
|
+
* charts: [errors],
|
|
73
|
+
* layout: [{ i: errors.id, x: 0, y: 0, w: 12, h: 6 } satisfies LayoutCell],
|
|
74
|
+
* },
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @example Compare to last 24h
|
|
79
|
+
* ```typescript
|
|
80
|
+
* yield* Axiom.Dashboard("compare", {
|
|
81
|
+
* dashboard: {
|
|
82
|
+
* name: "Compare vs yesterday",
|
|
83
|
+
* owner: "",
|
|
84
|
+
* refreshTime: 300,
|
|
85
|
+
* schemaVersion: 2,
|
|
86
|
+
* timeWindowStart: "qr-now-1h",
|
|
87
|
+
* timeWindowEnd: "qr-now",
|
|
88
|
+
* against: "-1d", // overlay the same window from 24h ago
|
|
89
|
+
* charts: [],
|
|
90
|
+
* layout: [],
|
|
91
|
+
* },
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export const Dashboard = Resource("Axiom.Dashboard");
|
|
96
|
+
export const DashboardProvider = () => Provider.effect(Dashboard, Effect.gen(function* () {
|
|
97
|
+
const create = yield* Operations.createDashboard;
|
|
98
|
+
const update = yield* Operations.updateDashboard;
|
|
99
|
+
const get = yield* Operations.getDashboard;
|
|
100
|
+
const del = yield* Operations.deleteDashboard;
|
|
101
|
+
const toAttrsFromCreate = (envelope) => ({
|
|
102
|
+
uid: envelope.dashboard.uid,
|
|
103
|
+
id: envelope.dashboard.id,
|
|
104
|
+
createdAt: envelope.dashboard.createdAt,
|
|
105
|
+
createdBy: envelope.dashboard.createdBy,
|
|
106
|
+
updatedAt: envelope.dashboard.updatedAt,
|
|
107
|
+
updatedBy: envelope.dashboard.updatedBy,
|
|
108
|
+
dashboard: envelope.dashboard.dashboard,
|
|
109
|
+
});
|
|
110
|
+
const toAttrsFromGet = (current) => ({
|
|
111
|
+
uid: current.uid,
|
|
112
|
+
id: current.id,
|
|
113
|
+
createdAt: current.createdAt,
|
|
114
|
+
createdBy: current.createdBy,
|
|
115
|
+
updatedAt: current.updatedAt,
|
|
116
|
+
updatedBy: current.updatedBy,
|
|
117
|
+
dashboard: current.dashboard,
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
stables: ["uid", "id", "createdAt", "createdBy"],
|
|
121
|
+
create: Effect.fn(function* ({ news }) {
|
|
122
|
+
return toAttrsFromCreate(yield* create(news));
|
|
123
|
+
}),
|
|
124
|
+
update: Effect.fn(function* ({ news, output }) {
|
|
125
|
+
// `overwrite: true` short-circuits Axiom's optimistic-concurrency
|
|
126
|
+
// check (otherwise the API requires the caller to echo back the
|
|
127
|
+
// server-side `version`, which the resource state doesn't track).
|
|
128
|
+
return toAttrsFromCreate(yield* update({ ...news, uid: output.uid, overwrite: true }));
|
|
129
|
+
}),
|
|
130
|
+
delete: Effect.fn(function* ({ output }) {
|
|
131
|
+
yield* del({ uid: output.uid }).pipe(Effect.catchTag("NotFound", () => Effect.void));
|
|
132
|
+
}),
|
|
133
|
+
read: Effect.fn(function* ({ output }) {
|
|
134
|
+
if (!output?.uid)
|
|
135
|
+
return undefined;
|
|
136
|
+
return yield* get({ uid: output.uid }).pipe(Effect.map(toAttrsFromGet), Effect.catchTag("NotFound", () => Effect.succeed(undefined)));
|
|
137
|
+
}),
|
|
138
|
+
};
|
|
139
|
+
}));
|
|
140
|
+
//# sourceMappingURL=Dashboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dashboard.js","sourceRoot":"","sources":["../../src/Axiom/Dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,mCAAmC,CAAC;AAChE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAyC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAY,iBAAiB,CAAC,CAAC;AAEhE,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE,CACpC,QAAQ,CAAC,MAAM,CACb,SAAS,EACT,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC;IACjD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC;IACjD,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC;IAC3C,MAAM,GAAG,GAAG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