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.
Files changed (182) hide show
  1. package/bin/alchemy.js +428 -80
  2. package/bin/alchemy.js.map +1 -1
  3. package/bin/alchemy.ts +2 -0
  4. package/bin/commands/_shared.ts +34 -0
  5. package/bin/commands/bootstrap.ts +10 -3
  6. package/bin/commands/deploy.ts +23 -3
  7. package/bin/commands/login.ts +18 -3
  8. package/bin/commands/logs.ts +11 -2
  9. package/bin/commands/profile.ts +11 -5
  10. package/bin/commands/state.ts +21 -13
  11. package/bin/commands/tail.ts +10 -2
  12. package/lib/AWS/CloudFront/CachePolicy.d.ts +106 -0
  13. package/lib/AWS/CloudFront/CachePolicy.d.ts.map +1 -0
  14. package/lib/AWS/CloudFront/CachePolicy.js +147 -0
  15. package/lib/AWS/CloudFront/CachePolicy.js.map +1 -0
  16. package/lib/AWS/CloudFront/KeyGroup.d.ts +72 -0
  17. package/lib/AWS/CloudFront/KeyGroup.d.ts.map +1 -0
  18. package/lib/AWS/CloudFront/KeyGroup.js +136 -0
  19. package/lib/AWS/CloudFront/KeyGroup.js.map +1 -0
  20. package/lib/AWS/CloudFront/OriginRequestPolicy.d.ts +84 -0
  21. package/lib/AWS/CloudFront/OriginRequestPolicy.d.ts.map +1 -0
  22. package/lib/AWS/CloudFront/OriginRequestPolicy.js +139 -0
  23. package/lib/AWS/CloudFront/OriginRequestPolicy.js.map +1 -0
  24. package/lib/AWS/CloudFront/PublicKey.d.ts +72 -0
  25. package/lib/AWS/CloudFront/PublicKey.d.ts.map +1 -0
  26. package/lib/AWS/CloudFront/PublicKey.js +137 -0
  27. package/lib/AWS/CloudFront/PublicKey.js.map +1 -0
  28. package/lib/AWS/CloudFront/ResponseHeadersPolicy.d.ts +114 -0
  29. package/lib/AWS/CloudFront/ResponseHeadersPolicy.d.ts.map +1 -0
  30. package/lib/AWS/CloudFront/ResponseHeadersPolicy.js +162 -0
  31. package/lib/AWS/CloudFront/ResponseHeadersPolicy.js.map +1 -0
  32. package/lib/AWS/CloudFront/index.d.ts +5 -0
  33. package/lib/AWS/CloudFront/index.d.ts.map +1 -1
  34. package/lib/AWS/CloudFront/index.js +5 -0
  35. package/lib/AWS/CloudFront/index.js.map +1 -1
  36. package/lib/AWS/ECS/CapacityProvider.d.ts +102 -0
  37. package/lib/AWS/ECS/CapacityProvider.d.ts.map +1 -0
  38. package/lib/AWS/ECS/CapacityProvider.js +217 -0
  39. package/lib/AWS/ECS/CapacityProvider.js.map +1 -0
  40. package/lib/AWS/ECS/index.d.ts +1 -0
  41. package/lib/AWS/ECS/index.d.ts.map +1 -1
  42. package/lib/AWS/ECS/index.js +1 -0
  43. package/lib/AWS/ECS/index.js.map +1 -1
  44. package/lib/AWS/Providers.d.ts.map +1 -1
  45. package/lib/AWS/Providers.js +7 -1
  46. package/lib/AWS/Providers.js.map +1 -1
  47. package/lib/Agent/lsp/client.d.ts +2 -2
  48. package/lib/Apply.d.ts.map +1 -1
  49. package/lib/Apply.js +41 -9
  50. package/lib/Apply.js.map +1 -1
  51. package/lib/Axiom/Annotation.d.ts +49 -0
  52. package/lib/Axiom/Annotation.d.ts.map +1 -0
  53. package/lib/Axiom/Annotation.js +74 -0
  54. package/lib/Axiom/Annotation.js.map +1 -0
  55. package/lib/Axiom/ApiToken.d.ts +62 -0
  56. package/lib/Axiom/ApiToken.d.ts.map +1 -0
  57. package/lib/Axiom/ApiToken.js +98 -0
  58. package/lib/Axiom/ApiToken.js.map +1 -0
  59. package/lib/Axiom/AuthProvider.d.ts +48 -0
  60. package/lib/Axiom/AuthProvider.d.ts.map +1 -0
  61. package/lib/Axiom/AuthProvider.js +177 -0
  62. package/lib/Axiom/AuthProvider.js.map +1 -0
  63. package/lib/Axiom/Chart.d.ts +72 -0
  64. package/lib/Axiom/Chart.d.ts.map +1 -0
  65. package/lib/Axiom/Chart.js +14 -0
  66. package/lib/Axiom/Chart.js.map +1 -0
  67. package/lib/Axiom/Credentials.d.ts +12 -0
  68. package/lib/Axiom/Credentials.d.ts.map +1 -0
  69. package/lib/Axiom/Credentials.js +34 -0
  70. package/lib/Axiom/Credentials.js.map +1 -0
  71. package/lib/Axiom/Dashboard.d.ts +124 -0
  72. package/lib/Axiom/Dashboard.d.ts.map +1 -0
  73. package/lib/Axiom/Dashboard.js +140 -0
  74. package/lib/Axiom/Dashboard.js.map +1 -0
  75. package/lib/Axiom/Dataset.d.ts +101 -0
  76. package/lib/Axiom/Dataset.d.ts.map +1 -0
  77. package/lib/Axiom/Dataset.js +183 -0
  78. package/lib/Axiom/Dataset.js.map +1 -0
  79. package/lib/Axiom/Monitor.d.ts +74 -0
  80. package/lib/Axiom/Monitor.d.ts.map +1 -0
  81. package/lib/Axiom/Monitor.js +103 -0
  82. package/lib/Axiom/Monitor.js.map +1 -0
  83. package/lib/Axiom/Notifier.d.ts +63 -0
  84. package/lib/Axiom/Notifier.d.ts.map +1 -0
  85. package/lib/Axiom/Notifier.js +83 -0
  86. package/lib/Axiom/Notifier.js.map +1 -0
  87. package/lib/Axiom/Providers.d.ts +15 -0
  88. package/lib/Axiom/Providers.d.ts.map +1 -0
  89. package/lib/Axiom/Providers.js +32 -0
  90. package/lib/Axiom/Providers.js.map +1 -0
  91. package/lib/Axiom/View.d.ts +55 -0
  92. package/lib/Axiom/View.d.ts.map +1 -0
  93. package/lib/Axiom/View.js +79 -0
  94. package/lib/Axiom/View.js.map +1 -0
  95. package/lib/Axiom/VirtualField.d.ts +42 -0
  96. package/lib/Axiom/VirtualField.d.ts.map +1 -0
  97. package/lib/Axiom/VirtualField.js +71 -0
  98. package/lib/Axiom/VirtualField.js.map +1 -0
  99. package/lib/Axiom/index.d.ts +13 -0
  100. package/lib/Axiom/index.d.ts.map +1 -0
  101. package/lib/Axiom/index.js +13 -0
  102. package/lib/Axiom/index.js.map +1 -0
  103. package/lib/Bundle/Bundle.d.ts +20 -2
  104. package/lib/Bundle/Bundle.d.ts.map +1 -1
  105. package/lib/Bundle/Bundle.js +18 -3
  106. package/lib/Bundle/Bundle.js.map +1 -1
  107. package/lib/Bundle/PurePlugin.d.ts +109 -0
  108. package/lib/Bundle/PurePlugin.d.ts.map +1 -0
  109. package/lib/Bundle/PurePlugin.js +469 -0
  110. package/lib/Bundle/PurePlugin.js.map +1 -0
  111. package/lib/Bundle/index.d.ts +1 -0
  112. package/lib/Bundle/index.d.ts.map +1 -1
  113. package/lib/Bundle/index.js +1 -0
  114. package/lib/Bundle/index.js.map +1 -1
  115. package/lib/Cloudflare/Workers/Worker.d.ts +12 -0
  116. package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
  117. package/lib/Cloudflare/Workers/Worker.js +19 -4
  118. package/lib/Cloudflare/Workers/Worker.js.map +1 -1
  119. package/lib/GitHub/Secrets.d.ts +45 -0
  120. package/lib/GitHub/Secrets.d.ts.map +1 -0
  121. package/lib/GitHub/Secrets.js +30 -0
  122. package/lib/GitHub/Secrets.js.map +1 -0
  123. package/lib/GitHub/index.d.ts +1 -0
  124. package/lib/GitHub/index.d.ts.map +1 -1
  125. package/lib/GitHub/index.js +1 -0
  126. package/lib/GitHub/index.js.map +1 -1
  127. package/lib/Output.d.ts.map +1 -1
  128. package/lib/Output.js +1 -1
  129. package/lib/Output.js.map +1 -1
  130. package/lib/Plan.d.ts.map +1 -1
  131. package/lib/Plan.js +10 -4
  132. package/lib/Plan.js.map +1 -1
  133. package/lib/Resource.d.ts +2 -2
  134. package/lib/Resource.d.ts.map +1 -1
  135. package/lib/Telemetry/Attributes.d.ts +43 -0
  136. package/lib/Telemetry/Attributes.d.ts.map +1 -0
  137. package/lib/Telemetry/Attributes.js +144 -0
  138. package/lib/Telemetry/Attributes.js.map +1 -0
  139. package/lib/Telemetry/Layer.d.ts +14 -0
  140. package/lib/Telemetry/Layer.d.ts.map +1 -0
  141. package/lib/Telemetry/Layer.js +50 -0
  142. package/lib/Telemetry/Layer.js.map +1 -0
  143. package/lib/Telemetry/Metrics.d.ts +34 -0
  144. package/lib/Telemetry/Metrics.d.ts.map +1 -0
  145. package/lib/Telemetry/Metrics.js +57 -0
  146. package/lib/Telemetry/Metrics.js.map +1 -0
  147. package/package.json +12 -1
  148. package/src/AWS/CloudFront/CachePolicy.ts +271 -0
  149. package/src/AWS/CloudFront/KeyGroup.ts +233 -0
  150. package/src/AWS/CloudFront/OriginRequestPolicy.ts +256 -0
  151. package/src/AWS/CloudFront/PublicKey.ts +245 -0
  152. package/src/AWS/CloudFront/ResponseHeadersPolicy.ts +308 -0
  153. package/src/AWS/CloudFront/index.ts +11 -0
  154. package/src/AWS/ECS/CapacityProvider.ts +336 -0
  155. package/src/AWS/ECS/index.ts +4 -0
  156. package/src/AWS/Providers.ts +12 -0
  157. package/src/Apply.ts +118 -9
  158. package/src/Axiom/Annotation.ts +95 -0
  159. package/src/Axiom/ApiToken.ts +125 -0
  160. package/src/Axiom/AuthProvider.ts +341 -0
  161. package/src/Axiom/Chart.ts +94 -0
  162. package/src/Axiom/Credentials.ts +70 -0
  163. package/src/Axiom/Dashboard.ts +192 -0
  164. package/src/Axiom/Dataset.ts +291 -0
  165. package/src/Axiom/Monitor.ts +122 -0
  166. package/src/Axiom/Notifier.ts +104 -0
  167. package/src/Axiom/Providers.ts +58 -0
  168. package/src/Axiom/View.ts +106 -0
  169. package/src/Axiom/VirtualField.ts +90 -0
  170. package/src/Axiom/index.ts +12 -0
  171. package/src/Bundle/Bundle.ts +39 -1
  172. package/src/Bundle/PurePlugin.ts +556 -0
  173. package/src/Bundle/index.ts +1 -0
  174. package/src/Cloudflare/Workers/Worker.ts +37 -6
  175. package/src/GitHub/Secrets.ts +66 -0
  176. package/src/GitHub/index.ts +1 -0
  177. package/src/Output.ts +2 -1
  178. package/src/Plan.ts +13 -4
  179. package/src/Resource.ts +2 -2
  180. package/src/Telemetry/Attributes.ts +216 -0
  181. package/src/Telemetry/Layer.ts +65 -0
  182. package/src/Telemetry/Metrics.ts +101 -0
@@ -0,0 +1,90 @@
1
+ import * as Operations from "@distilled.cloud/axiom/Operations";
2
+ import * as Effect from "effect/Effect";
3
+ import { isResolved } from "../Diff.ts";
4
+ import * as Provider from "../Provider.ts";
5
+ import { Resource } from "../Resource.ts";
6
+ import type { Providers } from "./Providers.ts";
7
+
8
+ export type VirtualFieldProps = Operations.CreateVirtualFieldInput;
9
+
10
+ export type VirtualField = Resource<
11
+ "Axiom.VirtualField",
12
+ VirtualFieldProps,
13
+ Operations.CreateVirtualFieldOutput,
14
+ never,
15
+ Providers
16
+ >;
17
+
18
+ /**
19
+ * An Axiom virtual field — a saved APL expression that appears as a derived
20
+ * column on a dataset at query time. Use these to standardise common
21
+ * computations (status classes, latency buckets, parsed JSON paths) so
22
+ * dashboards and monitors don't have to redefine them.
23
+ *
24
+ * Bound to a single `dataset`; changing the dataset triggers a replacement.
25
+ *
26
+ * @see https://axiom.co/docs/query-data/virtual-fields
27
+ *
28
+ * @section Creating a Virtual Field
29
+ * @example HTTP status class (e.g. 200 → "2xx")
30
+ * ```typescript
31
+ * yield* Axiom.VirtualField("status-class", {
32
+ * dataset: "my-app-traces",
33
+ * name: "status_class",
34
+ * description: "HTTP response class bucket",
35
+ * expression: 'strcat(tostring(toint(status / 100)), "xx")',
36
+ * type: "string",
37
+ * });
38
+ * ```
39
+ *
40
+ * @example Latency bucket in seconds
41
+ * ```typescript
42
+ * yield* Axiom.VirtualField("latency-bucket", {
43
+ * dataset: "my-app-traces",
44
+ * name: "latency_bucket_s",
45
+ * expression: "bin(duration_ms / 1000.0, 0.5)",
46
+ * type: "number",
47
+ * unit: "s",
48
+ * });
49
+ * ```
50
+ */
51
+ export const VirtualField = Resource<VirtualField>("Axiom.VirtualField");
52
+
53
+ export const VirtualFieldProvider = () =>
54
+ Provider.effect(
55
+ VirtualField,
56
+ Effect.gen(function* () {
57
+ const create = yield* Operations.createVirtualField;
58
+ const update = yield* Operations.updateVirtualField;
59
+ const get = yield* Operations.getVirtualField;
60
+ const del = yield* Operations.deleteVirtualField;
61
+
62
+ return {
63
+ stables: ["id"],
64
+ diff: Effect.fn(function* ({ news, output }) {
65
+ if (!isResolved(news)) return undefined;
66
+ if (output && news.dataset !== output.dataset) {
67
+ return { action: "replace" } as const;
68
+ }
69
+ return undefined;
70
+ }),
71
+ create: Effect.fn(function* ({ news }) {
72
+ return yield* create(news);
73
+ }),
74
+ update: Effect.fn(function* ({ news, output }) {
75
+ return yield* update({ ...news, id: output.id });
76
+ }),
77
+ delete: Effect.fn(function* ({ output }) {
78
+ yield* del({ id: output.id }).pipe(
79
+ Effect.catchTag("NotFound", () => Effect.void),
80
+ );
81
+ }),
82
+ read: Effect.fn(function* ({ output }) {
83
+ if (!output?.id) return undefined;
84
+ return yield* get({ id: output.id }).pipe(
85
+ Effect.catchTag("NotFound", () => Effect.succeed(undefined)),
86
+ );
87
+ }),
88
+ };
89
+ }),
90
+ );
@@ -0,0 +1,12 @@
1
+ export * from "./Annotation.ts";
2
+ export * from "./ApiToken.ts";
3
+ export * from "./AuthProvider.ts";
4
+ export * from "./Chart.ts";
5
+ export * from "./Credentials.ts";
6
+ export * from "./Dashboard.ts";
7
+ export * from "./Dataset.ts";
8
+ export * from "./Monitor.ts";
9
+ export * from "./Notifier.ts";
10
+ export * from "./Providers.ts";
11
+ export * from "./View.ts";
12
+ export * from "./VirtualField.ts";
@@ -7,6 +7,25 @@ import * as Stream from "effect/Stream";
7
7
  import assert from "node:assert";
8
8
  import * as rolldown from "rolldown";
9
9
  import { sha256, sha256Object } from "../Util/sha256.ts";
10
+ import { purePlugin, type PurePluginOptions } from "./PurePlugin.ts";
11
+
12
+ /**
13
+ * Extra options accepted by {@link build} / {@link watch} on top of the
14
+ * standard rolldown input/output options.
15
+ */
16
+ export interface BundleExtraOptions {
17
+ /**
18
+ * Configures the {@link purePlugin} which annotates top-level
19
+ * call/new expressions in matching packages with `/*#__PURE__*\/`
20
+ * so rolldown can tree-shake them.
21
+ *
22
+ * - `undefined` (default): plugin is enabled with default packages
23
+ * (`effect`, `@effect/*`).
24
+ * - `PurePluginOptions`: plugin is enabled with the provided options.
25
+ * - `false`: plugin is disabled.
26
+ */
27
+ readonly pure?: PurePluginOptions | false;
28
+ }
10
29
 
11
30
  export interface BundleOutput {
12
31
  /**
@@ -40,11 +59,13 @@ export class BundleError extends Data.TaggedError("BundleError")<{
40
59
  export const build = (
41
60
  inputOptions: rolldown.InputOptions,
42
61
  outputOptions?: rolldown.OutputOptions,
62
+ extra?: BundleExtraOptions,
43
63
  ): Effect.Effect<BundleOutput, BundleError> =>
44
64
  Effect.tryPromise({
45
65
  try: async () => {
46
66
  const bundle = await rolldown.rolldown({
47
67
  ...inputOptions,
68
+ plugins: withPurePlugin(inputOptions.plugins, extra?.pure),
48
69
  optimization: inputOptions.optimization ?? {
49
70
  inlineConst: {
50
71
  mode: "smart",
@@ -71,6 +92,7 @@ export const build = (
71
92
  export const watch = (
72
93
  inputOptions: rolldown.InputOptions,
73
94
  outputOptions?: rolldown.OutputOptions,
95
+ extra?: BundleExtraOptions,
74
96
  ): Stream.Stream<Result.Result<BundleOutput, BundleError>> =>
75
97
  Stream.callback<Result.Result<rolldown.OutputBundle, BundleError>>((queue) =>
76
98
  Effect.acquireRelease(
@@ -78,7 +100,7 @@ export const watch = (
78
100
  const watcher = rolldown.watch({
79
101
  ...inputOptions,
80
102
  plugins: [
81
- inputOptions.plugins,
103
+ withPurePlugin(inputOptions.plugins, extra?.pure),
82
104
  // The watcher event listener does not receive the bundle output, so we grab it using a plugin.
83
105
  {
84
106
  name: "alchemy:watch-bundle",
@@ -179,6 +201,22 @@ export function bundleOutputFromRolldownOutputBundle(
179
201
  ).pipe(Effect.flatMap(bundleOutputFromFiles));
180
202
  }
181
203
 
204
+ /**
205
+ * Composes the user-provided plugin chain with the default
206
+ * {@link purePlugin} according to the `pure` option.
207
+ *
208
+ * The pure plugin is appended LAST so it sees module ids that have already
209
+ * been resolved into `node_modules/<pkg>/...` by upstream resolver plugins
210
+ * such as `@distilled.cloud/cloudflare-rolldown-plugin`.
211
+ */
212
+ function withPurePlugin(
213
+ plugins: rolldown.RolldownPluginOption,
214
+ pure: PurePluginOptions | false | undefined,
215
+ ): rolldown.RolldownPluginOption {
216
+ if (pure === false) return plugins;
217
+ return [plugins, purePlugin(pure ?? {})];
218
+ }
219
+
182
220
  function bundleErrorFromUnknown(error: unknown): BundleError {
183
221
  const message = error instanceof Error ? error.message : String(error);
184
222
  return new BundleError({