@alchemy.run/axiom 0.0.0 → 2.0.0-beta.85

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 (83) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +54 -4
  3. package/lib/Annotation.d.ts +51 -0
  4. package/lib/Annotation.d.ts.map +1 -0
  5. package/lib/Annotation.js +97 -0
  6. package/lib/Annotation.js.map +1 -0
  7. package/lib/ApiToken.d.ts +74 -0
  8. package/lib/ApiToken.d.ts.map +1 -0
  9. package/lib/ApiToken.js +130 -0
  10. package/lib/ApiToken.js.map +1 -0
  11. package/lib/AuthProvider.d.ts +40 -0
  12. package/lib/AuthProvider.d.ts.map +1 -0
  13. package/lib/AuthProvider.js +99 -0
  14. package/lib/AuthProvider.js.map +1 -0
  15. package/lib/Chart.d.ts +130 -0
  16. package/lib/Chart.d.ts.map +1 -0
  17. package/lib/Chart.js +14 -0
  18. package/lib/Chart.js.map +1 -0
  19. package/lib/Contributions.d.ts +7 -0
  20. package/lib/Contributions.d.ts.map +1 -0
  21. package/lib/Contributions.js +6 -0
  22. package/lib/Contributions.js.map +1 -0
  23. package/lib/Credentials.d.ts +10 -0
  24. package/lib/Credentials.d.ts.map +1 -0
  25. package/lib/Credentials.js +17 -0
  26. package/lib/Credentials.js.map +1 -0
  27. package/lib/Dashboard.d.ts +112 -0
  28. package/lib/Dashboard.d.ts.map +1 -0
  29. package/lib/Dashboard.js +157 -0
  30. package/lib/Dashboard.js.map +1 -0
  31. package/lib/Dataset.d.ts +129 -0
  32. package/lib/Dataset.d.ts.map +1 -0
  33. package/lib/Dataset.js +221 -0
  34. package/lib/Dataset.js.map +1 -0
  35. package/lib/Monitor.d.ts +76 -0
  36. package/lib/Monitor.d.ts.map +1 -0
  37. package/lib/Monitor.js +126 -0
  38. package/lib/Monitor.js.map +1 -0
  39. package/lib/Notifier.d.ts +65 -0
  40. package/lib/Notifier.d.ts.map +1 -0
  41. package/lib/Notifier.js +112 -0
  42. package/lib/Notifier.js.map +1 -0
  43. package/lib/OtelHeaders.d.ts +9 -0
  44. package/lib/OtelHeaders.d.ts.map +1 -0
  45. package/lib/OtelHeaders.js +9 -0
  46. package/lib/OtelHeaders.js.map +1 -0
  47. package/lib/Providers.d.ts +15 -0
  48. package/lib/Providers.d.ts.map +1 -0
  49. package/lib/Providers.js +34 -0
  50. package/lib/Providers.js.map +1 -0
  51. package/lib/Telemetry.d.ts +66 -0
  52. package/lib/Telemetry.d.ts.map +1 -0
  53. package/lib/Telemetry.js +68 -0
  54. package/lib/Telemetry.js.map +1 -0
  55. package/lib/View.d.ts +57 -0
  56. package/lib/View.d.ts.map +1 -0
  57. package/lib/View.js +100 -0
  58. package/lib/View.js.map +1 -0
  59. package/lib/VirtualField.d.ts +44 -0
  60. package/lib/VirtualField.d.ts.map +1 -0
  61. package/lib/VirtualField.js +97 -0
  62. package/lib/VirtualField.js.map +1 -0
  63. package/lib/index.d.ts +14 -0
  64. package/lib/index.d.ts.map +1 -0
  65. package/lib/index.js +14 -0
  66. package/lib/index.js.map +1 -0
  67. package/package.json +53 -3
  68. package/src/Annotation.ts +121 -0
  69. package/src/ApiToken.ts +158 -0
  70. package/src/AuthProvider.ts +135 -0
  71. package/src/Chart.ts +156 -0
  72. package/src/Contributions.ts +9 -0
  73. package/src/Credentials.ts +26 -0
  74. package/src/Dashboard.ts +192 -0
  75. package/src/Dataset.ts +333 -0
  76. package/src/Monitor.ts +148 -0
  77. package/src/Notifier.ts +136 -0
  78. package/src/OtelHeaders.ts +9 -0
  79. package/src/Providers.ts +60 -0
  80. package/src/Telemetry.ts +116 -0
  81. package/src/View.ts +130 -0
  82. package/src/VirtualField.ts +123 -0
  83. package/src/index.ts +13 -0
@@ -0,0 +1,40 @@
1
+ import { type StoredAuthConfig } from "alchemy/Auth/StoredAuthProvider";
2
+ import * as Redacted from "effect/Redacted";
3
+ export declare const AXIOM_AUTH_PROVIDER_NAME = "Axiom";
4
+ export type AxiomAuthConfig = StoredAuthConfig;
5
+ /**
6
+ * Resolved Axiom credentials. The provider values are a flat record
7
+ * (token + optional orgId/apiBaseUrl); the `apiToken`/`pat` distinction is
8
+ * derived at resolution time from orgId presence — an org id means the token
9
+ * is treated as a personal access token, mirroring how the CI environment
10
+ * resolution has always classified `AXIOM_ORG_ID`.
11
+ */
12
+ export type AxiomResolvedCredentials = {
13
+ type: "apiToken";
14
+ apiToken: Redacted.Redacted<string>;
15
+ apiBaseUrl: string;
16
+ orgId?: string;
17
+ source: {
18
+ type: AxiomAuthConfig["method"] | "env";
19
+ details?: string;
20
+ };
21
+ } | {
22
+ type: "pat";
23
+ apiToken: Redacted.Redacted<string>;
24
+ apiBaseUrl: string;
25
+ orgId: string;
26
+ source: {
27
+ type: AxiomAuthConfig["method"] | "env";
28
+ details?: string;
29
+ };
30
+ };
31
+ /**
32
+ * Layer that registers the Axiom {@link AuthProvider} into the
33
+ * {@link AuthProviders} registry when built. Include this in the Axiom
34
+ * `providers()` layer so the alchemy CLI can discover it.
35
+ */
36
+ export declare const AxiomAuth: import("effect/Layer").Layer<never, never, import("alchemy/Auth/Registry").AuthProviders | import("effect/FileSystem").FileSystem | import("effect/Path").Path>;
37
+ /** Schema of Axiom's inline static-token values. */
38
+ export declare const AxiomStoredCredentials: import("effect/Schema").Codec<import("alchemy/Auth/StoredAuthProvider").StoredValues, import("alchemy/Auth/StoredAuthProvider").StoredValues, never, never>;
39
+ export type AxiomStoredCredentials = typeof AxiomStoredCredentials.Type;
40
+ //# sourceMappingURL=AuthProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../src/AuthProvider.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,eAAO,MAAM,wBAAwB,UAAU,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAChC;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE;QAAE,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACvE,GACD;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE;QAAE,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACvE,CAAC;AAwFN;;;;GAIG;AACH,eAAO,MAAM,SAAS,iKAAkB,CAAC;AAEzC,oDAAoD;AACpD,eAAO,MAAM,sBAAsB,6JAAyB,CAAC;AAC7D,MAAM,MAAM,sBAAsB,GAAG,OAAO,sBAAsB,CAAC,IAAI,CAAC"}
@@ -0,0 +1,99 @@
1
+ import { DEFAULT_API_BASE_URL } from "@distilled.cloud/axiom/Credentials";
2
+ import { AuthError } from "alchemy/Auth/AuthProvider";
3
+ import { getEnv, getEnvRedacted } from "alchemy/Auth/Env";
4
+ import { makeStoredAuthProvider, storedSecret, storedValueText, } from "alchemy/Auth/StoredAuthProvider";
5
+ import * as Effect from "effect/Effect";
6
+ import * as Redacted from "effect/Redacted";
7
+ export const AXIOM_AUTH_PROVIDER_NAME = "Axiom";
8
+ const readEnvironment = Effect.gen(function* () {
9
+ const apiToken = (yield* getEnvRedacted("AXIOM_TOKEN")) ?? (yield* getEnvRedacted("AXIOM_API_KEY"));
10
+ if (!apiToken) {
11
+ return yield* AuthError.make({
12
+ message: "Axiom CI credentials not found. Set AXIOM_TOKEN or AXIOM_API_KEY.",
13
+ });
14
+ }
15
+ const apiBaseUrl = (yield* getEnv("AXIOM_URL")) ?? DEFAULT_API_BASE_URL;
16
+ const orgId = yield* getEnv("AXIOM_ORG_ID");
17
+ return orgId
18
+ ? {
19
+ type: "pat",
20
+ apiToken,
21
+ apiBaseUrl,
22
+ orgId,
23
+ source: { type: "env" },
24
+ }
25
+ : {
26
+ type: "apiToken",
27
+ apiToken,
28
+ apiBaseUrl,
29
+ source: { type: "env" },
30
+ };
31
+ });
32
+ const axiomAuth = makeStoredAuthProvider({
33
+ provider: AXIOM_AUTH_PROVIDER_NAME,
34
+ fields: [
35
+ {
36
+ name: "token",
37
+ label: "Axiom API Token or Personal Access Token",
38
+ secret: true,
39
+ },
40
+ {
41
+ name: "orgId",
42
+ label: "Axiom Org ID (required for personal access tokens)",
43
+ optional: true,
44
+ },
45
+ {
46
+ name: "apiBaseUrl",
47
+ label: "Axiom API Base URL",
48
+ optional: true,
49
+ placeholder: DEFAULT_API_BASE_URL,
50
+ },
51
+ ],
52
+ toResolved: (values, source) => {
53
+ const apiToken = storedSecret(values.token) ?? Redacted.make("");
54
+ const apiBaseUrl = storedValueText(values.apiBaseUrl) ?? DEFAULT_API_BASE_URL;
55
+ return values.orgId !== undefined
56
+ ? {
57
+ type: "pat",
58
+ apiToken,
59
+ apiBaseUrl,
60
+ orgId: storedValueText(values.orgId) ?? "",
61
+ source: { type: source },
62
+ }
63
+ : {
64
+ type: "apiToken",
65
+ apiToken,
66
+ apiBaseUrl,
67
+ source: { type: source },
68
+ };
69
+ },
70
+ readEnvironment,
71
+ environment: [
72
+ {
73
+ name: "AXIOM_TOKEN",
74
+ required: true,
75
+ secret: true,
76
+ alternatives: ["AXIOM_API_KEY"],
77
+ description: "Personal access token or API token.",
78
+ },
79
+ {
80
+ name: "AXIOM_URL",
81
+ required: false,
82
+ description: "API base URL for self-hosted or regional deployments.",
83
+ },
84
+ {
85
+ name: "AXIOM_ORG_ID",
86
+ required: false,
87
+ description: "Organization id; required when the token is a personal access token.",
88
+ },
89
+ ],
90
+ });
91
+ /**
92
+ * Layer that registers the Axiom {@link AuthProvider} into the
93
+ * {@link AuthProviders} registry when built. Include this in the Axiom
94
+ * `providers()` layer so the alchemy CLI can discover it.
95
+ */
96
+ export const AxiomAuth = axiomAuth.layer;
97
+ /** Schema of Axiom's inline static-token values. */
98
+ export const AxiomStoredCredentials = axiomAuth.storedSchema;
99
+ //# sourceMappingURL=AuthProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthProvider.js","sourceRoot":"","sources":["../src/AuthProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,eAAe,GAEhB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAC;AA2BhD,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC1C,MAAM,QAAQ,GACZ,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC;IACrF,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,KAAK,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC;YAC3B,OAAO,EAAE,mEAAmE;SAC7E,CAAC,CAAC;IACL,CAAC;IACD,MAAM,UAAU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,EAAE;gBAC1C,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;aACzB;YACH,CAAC,CAAC;gBACE,IAAI,EAAE,UAAU;gBAChB,QAAQ;gBACR,UAAU;gBACV,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;aACzB,CAAC;IACR,CAAC;IACD,eAAe;IACf,WAAW,EAAE;QACX;YACE,IAAI,EAAE,aAAa;YACnB,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,IAAI;YACZ,YAAY,EAAE,CAAC,eAAe,CAAC;YAC/B,WAAW,EAAE,qCAAqC;SACnD;QACD;YACE,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,uDAAuD;SACrE;QACD;YACE,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,sEAAsE;SACpF;KACF;CACF,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC;AAEzC,oDAAoD;AACpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC,YAAY,CAAC"}
package/lib/Chart.d.ts ADDED
@@ -0,0 +1,130 @@
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" | "SmartFilter";
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
+ /**
53
+ * A free-form markdown note. Unlike data charts, `Note` has no `query`
54
+ * or `name` — Axiom's payload is strictly `{ id, type, text, variant? }`.
55
+ */
56
+ export interface NoteChart {
57
+ readonly id: string;
58
+ readonly type: "Note";
59
+ /** Markdown body rendered in the note cell. */
60
+ readonly text: string;
61
+ readonly variant?: "default";
62
+ }
63
+ /**
64
+ * A dashboard filter bar (Axiom calls it `SmartFilter` on the wire,
65
+ * `Filter bar` in the UI). Holds one or more filters whose IDs can
66
+ * be referenced from other charts' APL via
67
+ * `declare query_parameters (<filter-id>:string = "")`.
68
+ *
69
+ * Unlike data charts, `SmartFilter` has no top-level `query` field —
70
+ * each filter inside `filters` may carry its own option-source APL.
71
+ */
72
+ export interface SmartFilterChart {
73
+ readonly id: string;
74
+ readonly type: "SmartFilter";
75
+ /** Optional display name for the filter bar element. */
76
+ readonly name?: string;
77
+ readonly filters: readonly SmartFilter[];
78
+ }
79
+ /**
80
+ * One filter inside a {@link SmartFilterChart}. Either a free-text
81
+ * `search` filter or a dropdown `select` filter. Select filters draw
82
+ * their options from either an inline `list` or an APL `query`.
83
+ */
84
+ export type SmartFilter = SmartFilterSearch | SmartFilterSelect;
85
+ export interface SmartFilterSearch {
86
+ readonly id: string;
87
+ readonly type: "search";
88
+ readonly name?: string;
89
+ readonly active?: boolean;
90
+ }
91
+ export interface SmartFilterSelect {
92
+ readonly id: string;
93
+ readonly type: "select";
94
+ readonly name?: string;
95
+ readonly active?: boolean;
96
+ /** `"list"` for inline `options`, `"apl"` for a query-driven dropdown. */
97
+ readonly selectType?: "list" | "apl";
98
+ /**
99
+ * APL query that returns rows shaped `{ key, value }`. Axiom shows
100
+ * `key` in the dropdown and substitutes `value` into chart queries.
101
+ */
102
+ readonly apl?: {
103
+ readonly apl: string;
104
+ };
105
+ /** Inline key/value options when `selectType === "list"`. */
106
+ readonly options?: readonly {
107
+ readonly id?: string;
108
+ readonly key: string;
109
+ readonly value: string;
110
+ readonly default?: boolean;
111
+ }[];
112
+ }
113
+ export type Chart = TimeSeriesChart | TableChart | PieChart | StatisticChart | HeatmapChart | LogStreamChart | NoteChart | SmartFilterChart;
114
+ /**
115
+ * Mirrors Axiom's `CreateDashboardInput.dashboard.layout` cell schema.
116
+ * `i` references a chart by its `id`.
117
+ */
118
+ export interface LayoutCell {
119
+ readonly i: string;
120
+ readonly x: number;
121
+ readonly y: number | null;
122
+ readonly w: number;
123
+ readonly h: number;
124
+ readonly minW?: number;
125
+ readonly minH?: number;
126
+ readonly maxW?: number;
127
+ readonly maxH?: number;
128
+ readonly static?: boolean;
129
+ }
130
+ //# sourceMappingURL=Chart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../src/Chart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,OAAO,GACP,KAAK,GACL,WAAW,GACX,SAAS,GACT,WAAW,GAC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CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,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"}
package/lib/Chart.js ADDED
@@ -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/Chart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
@@ -0,0 +1,7 @@
1
+ import * as Contributions from "alchemy/Contributions";
2
+ declare const _default: {
3
+ readonly name: "axiom";
4
+ readonly auth: Contributions.Lazy<import("effect/Layer").Layer<never, never, import("alchemy/Auth/Registry").AuthProviders | import("effect/FileSystem").FileSystem | import("effect/Path").Path>>;
5
+ };
6
+ export default _default;
7
+ //# sourceMappingURL=Contributions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Contributions.d.ts","sourceRoot":"","sources":["../src/Contributions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,uBAAuB,CAAC;;;;;AAEvD,wBAMG"}
@@ -0,0 +1,6 @@
1
+ import * as Contributions from "alchemy/Contributions";
2
+ export default Contributions.make({
3
+ name: "axiom",
4
+ auth: Contributions.lazy(() => import("./AuthProvider.js"), (module) => module.AxiomAuth),
5
+ });
6
+ //# sourceMappingURL=Contributions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Contributions.js","sourceRoot":"","sources":["../src/Contributions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,uBAAuB,CAAC;AAEvD,eAAe,aAAa,CAAC,IAAI,CAAC;IAChC,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,aAAa,CAAC,IAAI,CACtB,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,EACjC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAC7B;CACF,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Credentials } from "@distilled.cloud/axiom/Credentials";
2
+ import * as Layer from "effect/Layer";
3
+ export { Credentials, CredentialsFromEnv, DEFAULT_API_BASE_URL, } from "@distilled.cloud/axiom/Credentials";
4
+ /**
5
+ * Build a `Credentials` layer that resolves Axiom credentials via the Alchemy
6
+ * AuthProvider using the configured profile (defaults to "default", overridable
7
+ * with the current Alchemy profile).
8
+ */
9
+ export declare const fromAuthProvider: () => Layer.Layer<Credentials, never, import("alchemy/Auth/Registry").AuthProviders | import("alchemy/Auth/Profile").ProfileStore>;
10
+ //# sourceMappingURL=Credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Credentials.d.ts","sourceRoot":"","sources":["../src/Credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAGjE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,oCAAoC,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,oIAQ1B,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Credentials } from "@distilled.cloud/axiom/Credentials";
2
+ import { ConfigError } from "@distilled.cloud/core/errors";
3
+ import { lazyCredentials } from "alchemy/Auth/Resolve";
4
+ import * as Layer from "effect/Layer";
5
+ import { AXIOM_AUTH_PROVIDER_NAME } from "./AuthProvider.js";
6
+ export { Credentials, CredentialsFromEnv, DEFAULT_API_BASE_URL, } from "@distilled.cloud/axiom/Credentials";
7
+ /**
8
+ * Build a `Credentials` layer that resolves Axiom credentials via the Alchemy
9
+ * AuthProvider using the configured profile (defaults to "default", overridable
10
+ * with the current Alchemy profile).
11
+ */
12
+ export const fromAuthProvider = () => Layer.effect(Credentials, lazyCredentials()(AXIOM_AUTH_PROVIDER_NAME, (creds) => ({
13
+ apiKey: creds.apiToken,
14
+ apiBaseUrl: creds.apiBaseUrl,
15
+ orgId: creds.orgId,
16
+ })));
17
+ //# sourceMappingURL=Credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Credentials.js","sourceRoot":"","sources":["../src/Credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,wBAAwB,EAAiC,MAAM,mBAAmB,CAAC;AAE5F,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,oCAAoC,CAAC;AAE5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE,CACnC,KAAK,CAAC,MAAM,CACV,WAAW,EACX,eAAe,EAAyC,CAAC,wBAAwB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC7F,MAAM,EAAE,KAAK,CAAC,QAAQ;IACtB,UAAU,EAAE,KAAK,CAAC,UAAU;IAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;CACnB,CAAC,CAAC,CACJ,CAAC"}
@@ -0,0 +1,112 @@
1
+ import * as Axiom from "@distilled.cloud/axiom";
2
+ import * as Provider from "alchemy/Provider";
3
+ import { Resource } from "alchemy/Resource";
4
+ import type { Providers } from "./Providers.ts";
5
+ /** Dashboard input. */
6
+ export type DashboardProps = Axiom.CreateDashboardRequest;
7
+ export type Dashboard = Resource<"Axiom.Dashboard", DashboardProps, {
8
+ /** Stable Axiom dashboard `uid` (used as the path identifier). */
9
+ uid: string;
10
+ id: string;
11
+ createdAt: string;
12
+ createdBy: string;
13
+ updatedAt: string;
14
+ updatedBy: string;
15
+ /** The full dashboard document as returned by Axiom. */
16
+ dashboard: Axiom.DashboardWriteResponse["dashboard"]["dashboard"];
17
+ }, never, Providers>;
18
+ /**
19
+ * An Axiom dashboard — a named, layout-driven collection of charts. Each
20
+ * dashboard takes a full document (`charts` + `layout` array of grid cells +
21
+ * `timeWindow` + `refreshTime`) at version `schemaVersion: 2`.
22
+ *
23
+ * Charts are typed via {@link Chart} (a discriminated union over the
24
+ * Axiom-validated chart kinds — `TimeSeries`, `Table`, `Pie`, `Statistic`,
25
+ * `Heatmap`, `LogStream`, `Note`). The `id` on each chart is a free-form
26
+ * string the author picks; layout cells join via `LayoutCell.i`.
27
+ *
28
+ * The path identifier is `uid` (auto-assigned by Axiom). `id` is also
29
+ * exposed as an output but the API uses `uid` everywhere.
30
+ *
31
+ * Notes from probing `POST /v2/dashboards`:
32
+ *
33
+ * - Relative time windows must use the `qr-now-{duration}` form (e.g.
34
+ * `"qr-now-7d"` / `"qr-now"`); plain `"now-7d"` is rejected.
35
+ * - When authenticating with an API token, `dashboard.owner` must be `""`
36
+ * (Axiom rewrites this to the org-shared `X-AXIOM-EVERYONE`); per-user
37
+ * "private" dashboards aren't allowed for tokens.
38
+ * - The chart payload is strict: only `id`, `name`, `type`, `query`. Extra
39
+ * keys (e.g. `dataset`, `description`) trigger
40
+ * `Unrecognized keys: "<name>"`.
41
+ * @see https://axiom.co/docs/query-data/dashboards
42
+ *
43
+ * ### Creating a Dashboard
44
+ * **Example:** Minimal empty dashboard
45
+ * ```typescript
46
+ * yield* Axiom.Dashboard("ops", {
47
+ * dashboard: {
48
+ * name: "Ops Overview",
49
+ * owner: "", // org-shared (required for API tokens)
50
+ * description: "Top-level service health",
51
+ * charts: [],
52
+ * layout: [],
53
+ * refreshTime: 60, // seconds: 15 | 60 | 300
54
+ * schemaVersion: 2,
55
+ * timeWindowStart: "qr-now-1h",
56
+ * timeWindowEnd: "qr-now",
57
+ * },
58
+ * });
59
+ * ```
60
+ *
61
+ * **Example:** One-chart dashboard
62
+ * ```typescript
63
+ * import type { Chart, LayoutCell } from "@alchemy.run/axiom";
64
+ *
65
+ * const errors: Chart = {
66
+ * id: "errors-5m",
67
+ * name: "5xx errors / 5m",
68
+ * type: "TimeSeries",
69
+ * query: {
70
+ * apl: `['my-app-traces']
71
+ * | where status >= 500
72
+ * | summarize count() by bin_auto(_time)`,
73
+ * },
74
+ * };
75
+ *
76
+ * yield* Axiom.Dashboard("errors", {
77
+ * dashboard: {
78
+ * name: "Errors",
79
+ * owner: "",
80
+ * refreshTime: 60,
81
+ * schemaVersion: 2,
82
+ * timeWindowStart: "qr-now-24h",
83
+ * timeWindowEnd: "qr-now",
84
+ * charts: [errors],
85
+ * layout: [{ i: errors.id, x: 0, y: 0, w: 12, h: 6 } satisfies LayoutCell],
86
+ * },
87
+ * });
88
+ * ```
89
+ *
90
+ * **Example:** Compare to last 24h
91
+ * ```typescript
92
+ * yield* Axiom.Dashboard("compare", {
93
+ * dashboard: {
94
+ * name: "Compare vs yesterday",
95
+ * owner: "",
96
+ * refreshTime: 300,
97
+ * schemaVersion: 2,
98
+ * timeWindowStart: "qr-now-1h",
99
+ * timeWindowEnd: "qr-now",
100
+ * against: "-1d", // overlay the same window from 24h ago
101
+ * charts: [],
102
+ * layout: [],
103
+ * },
104
+ * });
105
+ * ```
106
+ *
107
+ * @resource
108
+ * @product Dashboard
109
+ */
110
+ export declare const Dashboard: import("alchemy/Resource").ResourceClass<Dashboard>;
111
+ export declare const DashboardProvider: () => import("effect/Layer").Layer<Provider.Provider<Dashboard>, never, Axiom.AxiomOpContext>;
112
+ //# sourceMappingURL=Dashboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../src/Dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,uBAAuB;AACvB,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,sBAAsB,CAAC;AAE1D,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,KAAK,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,CAAC;CACnE,EACD,KAAK,EACL,SAAS,CACV,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,eAAO,MAAM,SAAS,qDAAyC,CAAC;AAEhE,eAAO,MAAM,iBAAiB,+FAsE3B,CAAC"}
@@ -0,0 +1,157 @@
1
+ import * as Axiom from "@distilled.cloud/axiom";
2
+ import * as Provider from "alchemy/Provider";
3
+ import { Resource } from "alchemy/Resource";
4
+ import * as Effect from "effect/Effect";
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
+ * @see https://axiom.co/docs/query-data/dashboards
29
+ *
30
+ * ### Creating a Dashboard
31
+ * **Example:** Minimal empty dashboard
32
+ * ```typescript
33
+ * yield* Axiom.Dashboard("ops", {
34
+ * dashboard: {
35
+ * name: "Ops Overview",
36
+ * owner: "", // org-shared (required for API tokens)
37
+ * description: "Top-level service health",
38
+ * charts: [],
39
+ * layout: [],
40
+ * refreshTime: 60, // seconds: 15 | 60 | 300
41
+ * schemaVersion: 2,
42
+ * timeWindowStart: "qr-now-1h",
43
+ * timeWindowEnd: "qr-now",
44
+ * },
45
+ * });
46
+ * ```
47
+ *
48
+ * **Example:** One-chart dashboard
49
+ * ```typescript
50
+ * import type { Chart, LayoutCell } from "@alchemy.run/axiom";
51
+ *
52
+ * const errors: Chart = {
53
+ * id: "errors-5m",
54
+ * name: "5xx errors / 5m",
55
+ * type: "TimeSeries",
56
+ * query: {
57
+ * apl: `['my-app-traces']
58
+ * | where status >= 500
59
+ * | summarize count() by bin_auto(_time)`,
60
+ * },
61
+ * };
62
+ *
63
+ * yield* Axiom.Dashboard("errors", {
64
+ * dashboard: {
65
+ * name: "Errors",
66
+ * owner: "",
67
+ * refreshTime: 60,
68
+ * schemaVersion: 2,
69
+ * timeWindowStart: "qr-now-24h",
70
+ * timeWindowEnd: "qr-now",
71
+ * charts: [errors],
72
+ * layout: [{ i: errors.id, x: 0, y: 0, w: 12, h: 6 } satisfies LayoutCell],
73
+ * },
74
+ * });
75
+ * ```
76
+ *
77
+ * **Example:** Compare to last 24h
78
+ * ```typescript
79
+ * yield* Axiom.Dashboard("compare", {
80
+ * dashboard: {
81
+ * name: "Compare vs yesterday",
82
+ * owner: "",
83
+ * refreshTime: 300,
84
+ * schemaVersion: 2,
85
+ * timeWindowStart: "qr-now-1h",
86
+ * timeWindowEnd: "qr-now",
87
+ * against: "-1d", // overlay the same window from 24h ago
88
+ * charts: [],
89
+ * layout: [],
90
+ * },
91
+ * });
92
+ * ```
93
+ *
94
+ * @resource
95
+ * @product Dashboard
96
+ */
97
+ export const Dashboard = Resource("Axiom.Dashboard");
98
+ export const DashboardProvider = () => Provider.effect(Dashboard, Effect.gen(function* () {
99
+ const create = yield* Axiom.createDashboard;
100
+ const update = yield* Axiom.updateDashboard;
101
+ const get = yield* Axiom.getDashboard;
102
+ const del = yield* Axiom.deleteDashboard;
103
+ const listAll = yield* Axiom.listDashboards;
104
+ const toAttrsFromCreate = (envelope) => ({
105
+ uid: envelope.dashboard.uid,
106
+ id: envelope.dashboard.id,
107
+ createdAt: envelope.dashboard.createdAt,
108
+ createdBy: envelope.dashboard.createdBy,
109
+ updatedAt: envelope.dashboard.updatedAt,
110
+ updatedBy: envelope.dashboard.updatedBy,
111
+ dashboard: envelope.dashboard.dashboard,
112
+ });
113
+ const toAttrsFromGet = (current) => ({
114
+ uid: current.uid,
115
+ id: current.id,
116
+ createdAt: current.createdAt,
117
+ createdBy: current.createdBy,
118
+ updatedAt: current.updatedAt,
119
+ updatedBy: current.updatedBy,
120
+ dashboard: current.dashboard,
121
+ });
122
+ return {
123
+ stables: ["uid", "id", "createdAt", "createdBy"],
124
+ reconcile: Effect.fn(function* ({ news, output }) {
125
+ // Observe — `uid` is server-assigned at create time. We probe
126
+ // Axiom for the dashboard via the cached uid; treat NotFound
127
+ // (deleted out-of-band) as "no observed state" so we converge
128
+ // by re-creating.
129
+ const observed = output?.uid
130
+ ? yield* get({ uid: output.uid }).pipe(Effect.catchTag("NotFound", () => Effect.undefined))
131
+ : undefined;
132
+ // Ensure — POST mints a new dashboard with a fresh uid.
133
+ if (observed === undefined) {
134
+ return toAttrsFromCreate(yield* create(news));
135
+ }
136
+ // Sync — `overwrite: true` short-circuits Axiom's optimistic-
137
+ // concurrency check (otherwise the API requires the caller to
138
+ // echo back the server-side `version`, which we don't track).
139
+ return toAttrsFromCreate(yield* update({ ...news, uid: observed.uid, overwrite: true }));
140
+ }),
141
+ delete: Effect.fn(function* ({ output }) {
142
+ yield* del({ uid: output.uid }).pipe(Effect.catchTag("NotFound", () => Effect.void));
143
+ }),
144
+ read: Effect.fn(function* ({ output }) {
145
+ if (!output?.uid)
146
+ return undefined;
147
+ return yield* get({ uid: output.uid }).pipe(Effect.map(toAttrsFromGet), Effect.catchTag("NotFound", () => Effect.undefined));
148
+ }),
149
+ // Enumerate every dashboard visible to the caller. `GET /v2/dashboards`
150
+ // returns the full collection in one response (no pagination wrapper);
151
+ // each item carries the same shape as `getDashboard`, so we map through
152
+ // the shared `toAttrsFromGet` hydrator to produce the exact `read`
153
+ // Attributes shape.
154
+ list: () => listAll({}).pipe(Effect.map((dashboards) => dashboards.map(toAttrsFromGet))),
155
+ };
156
+ }));
157
+ //# sourceMappingURL=Dashboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dashboard.js","sourceRoot":"","sources":["../src/Dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAwBxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;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,KAAK,CAAC,eAAe,CAAC;IAC5C,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;IAC5C,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC;IACtC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;IACzC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC;IAE5C,MAAM,iBAAiB,GAAG,CAAC,QAAsC,EAAE,EAAE,CAAC,CAAC;QACrE,GAAG,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG;QAC3B,EAAE,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE;QACzB,SAAS,EAAE,Q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