alchemy 2.0.0-beta.18 → 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/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/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/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/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 @@
|
|
|
1
|
+
{"version":3,"file":"Providers.d.ts","sourceRoot":"","sources":["../../src/Axiom/Providers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAI3C,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAQhD,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;;AAEjE,qBAAa,SAAU,SAAQ,cAE9B;CAAG;AAEJ,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;AAEhF;;;;GAIG;AACH,eAAO,MAAM,SAAS,2HA8BnB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import * as Provider from "../Provider.js";
|
|
4
|
+
import { Annotation, AnnotationProvider } from "./Annotation.js";
|
|
5
|
+
import { ApiToken, ApiTokenProvider } from "./ApiToken.js";
|
|
6
|
+
import { AxiomAuth } from "./AuthProvider.js";
|
|
7
|
+
import * as Credentials from "./Credentials.js";
|
|
8
|
+
import { Dashboard, DashboardProvider } from "./Dashboard.js";
|
|
9
|
+
import { Dataset, DatasetProvider } from "./Dataset.js";
|
|
10
|
+
import { Monitor, MonitorProvider } from "./Monitor.js";
|
|
11
|
+
import { Notifier, NotifierProvider } from "./Notifier.js";
|
|
12
|
+
import { View, ViewProvider } from "./View.js";
|
|
13
|
+
import { VirtualField, VirtualFieldProvider } from "./VirtualField.js";
|
|
14
|
+
export { Credentials } from "@distilled.cloud/axiom/Credentials";
|
|
15
|
+
export class Providers extends Provider.ProviderCollection()("Axiom") {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Axiom providers and credentials. Wires up Dataset, ApiToken, Notifier,
|
|
19
|
+
* Monitor, Dashboard, VirtualField, View and Annotation resources, and
|
|
20
|
+
* registers the Axiom AuthProvider so `alchemy login` can configure it.
|
|
21
|
+
*/
|
|
22
|
+
export const providers = () => Layer.effect(Providers, Provider.collection([
|
|
23
|
+
Annotation,
|
|
24
|
+
ApiToken,
|
|
25
|
+
Dashboard,
|
|
26
|
+
Dataset,
|
|
27
|
+
Monitor,
|
|
28
|
+
Notifier,
|
|
29
|
+
View,
|
|
30
|
+
VirtualField,
|
|
31
|
+
])).pipe(Layer.provide(Layer.mergeAll(AnnotationProvider(), ApiTokenProvider(), DashboardProvider(), DatasetProvider(), MonitorProvider(), NotifierProvider(), ViewProvider(), VirtualFieldProvider())), Layer.provideMerge(Credentials.fromAuthProvider()), Layer.provideMerge(FetchHttpClient.layer), Layer.provideMerge(AxiomAuth), Layer.orDie);
|
|
32
|
+
//# sourceMappingURL=Providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Providers.js","sourceRoot":"","sources":["../../src/Axiom/Providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,sCAAsC,CAAC;AACxE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEjE,MAAM,OAAO,SAAU,SAAQ,QAAQ,CAAC,kBAAkB,EAAa,CACrE,OAAO,CACR;CAAG;AAIJ;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE,CAC5B,KAAK,CAAC,MAAM,CACV,SAAS,EACT,QAAQ,CAAC,UAAU,CAAC;IAClB,UAAU;IACV,QAAQ;IACR,SAAS;IACT,OAAO;IACP,OAAO;IACP,QAAQ;IACR,IAAI;IACJ,YAAY;CACb,CAAC,CACH,CAAC,IAAI,CACJ,KAAK,CAAC,OAAO,CACX,KAAK,CAAC,QAAQ,CACZ,kBAAkB,EAAE,EACpB,gBAAgB,EAAE,EAClB,iBAAiB,EAAE,EACnB,eAAe,EAAE,EACjB,eAAe,EAAE,EACjB,gBAAgB,EAAE,EAClB,YAAY,EAAE,EACd,oBAAoB,EAAE,CACvB,CACF,EACD,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,gBAAgB,EAAE,CAAC,EAClD,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,KAAK,CAAC,EACzC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,EAC7B,KAAK,CAAC,KAAK,CACZ,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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 { Providers } from "./Providers.ts";
|
|
5
|
+
export type ViewProps = Operations.CreateViewInput;
|
|
6
|
+
export type View = Resource<"Axiom.View", ViewProps, Operations.CreateViewOutput & {
|
|
7
|
+
/**
|
|
8
|
+
* Path identifier used by `updateView` / `getView` / `deleteView`.
|
|
9
|
+
* Currently derived from `name` because Axiom's view list/get responses
|
|
10
|
+
* don't expose a separate id field.
|
|
11
|
+
*/
|
|
12
|
+
id: string;
|
|
13
|
+
}, never, Providers>;
|
|
14
|
+
/**
|
|
15
|
+
* An Axiom saved view — a named, shareable APL query. Useful for building
|
|
16
|
+
* starter dashboards, providing canned "open in Axiom" links from your app,
|
|
17
|
+
* or pinning common investigations the team revisits.
|
|
18
|
+
*
|
|
19
|
+
* The path identifier is `name`. Renaming a view triggers a replacement
|
|
20
|
+
* (the old one is deleted, a new one is created).
|
|
21
|
+
*
|
|
22
|
+
* @see https://axiom.co/docs/query-data/datasets — APL query reference
|
|
23
|
+
*
|
|
24
|
+
* @section Creating a View
|
|
25
|
+
* @example Recent errors across one dataset
|
|
26
|
+
* ```typescript
|
|
27
|
+
* yield* Axiom.View("recent-errors", {
|
|
28
|
+
* name: "recent-errors",
|
|
29
|
+
* description: "Last 100 5xx responses",
|
|
30
|
+
* datasets: ["my-app-traces"],
|
|
31
|
+
* aplQuery: `
|
|
32
|
+
* ['my-app-traces']
|
|
33
|
+
* | where status >= 500
|
|
34
|
+
* | order by _time desc
|
|
35
|
+
* | take 100
|
|
36
|
+
* `,
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example Cross-dataset join (logs + traces by trace_id)
|
|
41
|
+
* ```typescript
|
|
42
|
+
* yield* Axiom.View("trace-with-logs", {
|
|
43
|
+
* name: "trace-with-logs",
|
|
44
|
+
* datasets: ["my-app-traces", "my-app-logs"],
|
|
45
|
+
* aplQuery: `
|
|
46
|
+
* ['my-app-traces']
|
|
47
|
+
* | where duration_ms > 1000
|
|
48
|
+
* | join kind=leftouter (['my-app-logs']) on trace_id
|
|
49
|
+
* `,
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare const View: import("../Resource.ts").ResourceClass<View>;
|
|
54
|
+
export declare const ViewProvider: () => import("effect/Layer").Layer<Provider.Provider<View>, never, any>;
|
|
55
|
+
//# sourceMappingURL=View.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"View.d.ts","sourceRoot":"","sources":["../../src/Axiom/View.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,mCAAmC,CAAC;AAGhE,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,eAAe,CAAC;AAEnD,MAAM,MAAM,IAAI,GAAG,QAAQ,CACzB,YAAY,EACZ,SAAS,EACT,UAAU,CAAC,gBAAgB,GAAG;IAC5B;;;;OAIG;IACH,EAAE,EAAE,MAAM,CAAC;CACZ,EACD,KAAK,EACL,SAAS,CACV,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,IAAI,8CAA+B,CAAC;AAEjD,eAAO,MAAM,YAAY,yEAwCtB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as Operations from "@distilled.cloud/axiom/Operations";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { isResolved } from "../Diff.js";
|
|
4
|
+
import * as Provider from "../Provider.js";
|
|
5
|
+
import { Resource } from "../Resource.js";
|
|
6
|
+
/**
|
|
7
|
+
* An Axiom saved view — a named, shareable APL query. Useful for building
|
|
8
|
+
* starter dashboards, providing canned "open in Axiom" links from your app,
|
|
9
|
+
* or pinning common investigations the team revisits.
|
|
10
|
+
*
|
|
11
|
+
* The path identifier is `name`. Renaming a view triggers a replacement
|
|
12
|
+
* (the old one is deleted, a new one is created).
|
|
13
|
+
*
|
|
14
|
+
* @see https://axiom.co/docs/query-data/datasets — APL query reference
|
|
15
|
+
*
|
|
16
|
+
* @section Creating a View
|
|
17
|
+
* @example Recent errors across one dataset
|
|
18
|
+
* ```typescript
|
|
19
|
+
* yield* Axiom.View("recent-errors", {
|
|
20
|
+
* name: "recent-errors",
|
|
21
|
+
* description: "Last 100 5xx responses",
|
|
22
|
+
* datasets: ["my-app-traces"],
|
|
23
|
+
* aplQuery: `
|
|
24
|
+
* ['my-app-traces']
|
|
25
|
+
* | where status >= 500
|
|
26
|
+
* | order by _time desc
|
|
27
|
+
* | take 100
|
|
28
|
+
* `,
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example Cross-dataset join (logs + traces by trace_id)
|
|
33
|
+
* ```typescript
|
|
34
|
+
* yield* Axiom.View("trace-with-logs", {
|
|
35
|
+
* name: "trace-with-logs",
|
|
36
|
+
* datasets: ["my-app-traces", "my-app-logs"],
|
|
37
|
+
* aplQuery: `
|
|
38
|
+
* ['my-app-traces']
|
|
39
|
+
* | where duration_ms > 1000
|
|
40
|
+
* | join kind=leftouter (['my-app-logs']) on trace_id
|
|
41
|
+
* `,
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export const View = Resource("Axiom.View");
|
|
46
|
+
export const ViewProvider = () => Provider.effect(View, Effect.gen(function* () {
|
|
47
|
+
const create = yield* Operations.createView;
|
|
48
|
+
const update = yield* Operations.updateView;
|
|
49
|
+
const get = yield* Operations.getView;
|
|
50
|
+
const del = yield* Operations.deleteView;
|
|
51
|
+
return {
|
|
52
|
+
stables: ["id"],
|
|
53
|
+
diff: Effect.fn(function* ({ news, output }) {
|
|
54
|
+
if (!isResolved(news))
|
|
55
|
+
return undefined;
|
|
56
|
+
if (output && news.name !== output.name) {
|
|
57
|
+
return { action: "replace" };
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}),
|
|
61
|
+
create: Effect.fn(function* ({ news }) {
|
|
62
|
+
const result = yield* create(news);
|
|
63
|
+
return { ...result, id: news.name };
|
|
64
|
+
}),
|
|
65
|
+
update: Effect.fn(function* ({ news, output }) {
|
|
66
|
+
const result = yield* update({ ...news, id: output.id });
|
|
67
|
+
return { ...result, id: output.id };
|
|
68
|
+
}),
|
|
69
|
+
delete: Effect.fn(function* ({ output }) {
|
|
70
|
+
yield* del({ id: output.id }).pipe(Effect.catchTag("NotFound", () => Effect.void));
|
|
71
|
+
}),
|
|
72
|
+
read: Effect.fn(function* ({ output }) {
|
|
73
|
+
if (!output?.id)
|
|
74
|
+
return undefined;
|
|
75
|
+
return yield* get({ id: output.id }).pipe(Effect.map((current) => ({ ...current, id: output.id })), Effect.catchTag("NotFound", () => Effect.succeed(undefined)));
|
|
76
|
+
}),
|
|
77
|
+
};
|
|
78
|
+
}));
|
|
79
|
+
//# sourceMappingURL=View.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"View.js","sourceRoot":"","sources":["../../src/Axiom/View.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,mCAAmC,CAAC;AAChE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAoB1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,QAAQ,CAAO,YAAY,CAAC,CAAC;AAEjD,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE,CAC/B,QAAQ,CAAC,MAAM,CACb,IAAI,EACJ,MAAM,CAAC,GAAG,CAAC,QAAQ,CA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E,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE;YACrC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAChC,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAC/C,CAAC;QACJ,CAAC,CAAC;QACF,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE;YACnC,IAAI,CAAC,MAAM,EAAE,EAAE;gBAAE,OAAO,SAAS,CAAC;YAClC,OAAO,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CACvC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,EACxD,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAC7D,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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 { Providers } from "./Providers.ts";
|
|
5
|
+
export type VirtualFieldProps = Operations.CreateVirtualFieldInput;
|
|
6
|
+
export type VirtualField = Resource<"Axiom.VirtualField", VirtualFieldProps, Operations.CreateVirtualFieldOutput, never, Providers>;
|
|
7
|
+
/**
|
|
8
|
+
* An Axiom virtual field — a saved APL expression that appears as a derived
|
|
9
|
+
* column on a dataset at query time. Use these to standardise common
|
|
10
|
+
* computations (status classes, latency buckets, parsed JSON paths) so
|
|
11
|
+
* dashboards and monitors don't have to redefine them.
|
|
12
|
+
*
|
|
13
|
+
* Bound to a single `dataset`; changing the dataset triggers a replacement.
|
|
14
|
+
*
|
|
15
|
+
* @see https://axiom.co/docs/query-data/virtual-fields
|
|
16
|
+
*
|
|
17
|
+
* @section Creating a Virtual Field
|
|
18
|
+
* @example HTTP status class (e.g. 200 → "2xx")
|
|
19
|
+
* ```typescript
|
|
20
|
+
* yield* Axiom.VirtualField("status-class", {
|
|
21
|
+
* dataset: "my-app-traces",
|
|
22
|
+
* name: "status_class",
|
|
23
|
+
* description: "HTTP response class bucket",
|
|
24
|
+
* expression: 'strcat(tostring(toint(status / 100)), "xx")',
|
|
25
|
+
* type: "string",
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example Latency bucket in seconds
|
|
30
|
+
* ```typescript
|
|
31
|
+
* yield* Axiom.VirtualField("latency-bucket", {
|
|
32
|
+
* dataset: "my-app-traces",
|
|
33
|
+
* name: "latency_bucket_s",
|
|
34
|
+
* expression: "bin(duration_ms / 1000.0, 0.5)",
|
|
35
|
+
* type: "number",
|
|
36
|
+
* unit: "s",
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare const VirtualField: import("../Resource.ts").ResourceClass<VirtualField>;
|
|
41
|
+
export declare const VirtualFieldProvider: () => import("effect/Layer").Layer<Provider.Provider<VirtualField>, never, any>;
|
|
42
|
+
//# sourceMappingURL=VirtualField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VirtualField.d.ts","sourceRoot":"","sources":["../../src/Axiom/VirtualField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,mCAAmC,CAAC;AAGhE,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,uBAAuB,CAAC;AAEnE,MAAM,MAAM,YAAY,GAAG,QAAQ,CACjC,oBAAoB,EACpB,iBAAiB,EACjB,UAAU,CAAC,wBAAwB,EACnC,KAAK,EACL,SAAS,CACV,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,YAAY,sDAA+C,CAAC;AAEzE,eAAO,MAAM,oBAAoB,iFAqC9B,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as Operations from "@distilled.cloud/axiom/Operations";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { isResolved } from "../Diff.js";
|
|
4
|
+
import * as Provider from "../Provider.js";
|
|
5
|
+
import { Resource } from "../Resource.js";
|
|
6
|
+
/**
|
|
7
|
+
* An Axiom virtual field — a saved APL expression that appears as a derived
|
|
8
|
+
* column on a dataset at query time. Use these to standardise common
|
|
9
|
+
* computations (status classes, latency buckets, parsed JSON paths) so
|
|
10
|
+
* dashboards and monitors don't have to redefine them.
|
|
11
|
+
*
|
|
12
|
+
* Bound to a single `dataset`; changing the dataset triggers a replacement.
|
|
13
|
+
*
|
|
14
|
+
* @see https://axiom.co/docs/query-data/virtual-fields
|
|
15
|
+
*
|
|
16
|
+
* @section Creating a Virtual Field
|
|
17
|
+
* @example HTTP status class (e.g. 200 → "2xx")
|
|
18
|
+
* ```typescript
|
|
19
|
+
* yield* Axiom.VirtualField("status-class", {
|
|
20
|
+
* dataset: "my-app-traces",
|
|
21
|
+
* name: "status_class",
|
|
22
|
+
* description: "HTTP response class bucket",
|
|
23
|
+
* expression: 'strcat(tostring(toint(status / 100)), "xx")',
|
|
24
|
+
* type: "string",
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @example Latency bucket in seconds
|
|
29
|
+
* ```typescript
|
|
30
|
+
* yield* Axiom.VirtualField("latency-bucket", {
|
|
31
|
+
* dataset: "my-app-traces",
|
|
32
|
+
* name: "latency_bucket_s",
|
|
33
|
+
* expression: "bin(duration_ms / 1000.0, 0.5)",
|
|
34
|
+
* type: "number",
|
|
35
|
+
* unit: "s",
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export const VirtualField = Resource("Axiom.VirtualField");
|
|
40
|
+
export const VirtualFieldProvider = () => Provider.effect(VirtualField, Effect.gen(function* () {
|
|
41
|
+
const create = yield* Operations.createVirtualField;
|
|
42
|
+
const update = yield* Operations.updateVirtualField;
|
|
43
|
+
const get = yield* Operations.getVirtualField;
|
|
44
|
+
const del = yield* Operations.deleteVirtualField;
|
|
45
|
+
return {
|
|
46
|
+
stables: ["id"],
|
|
47
|
+
diff: Effect.fn(function* ({ news, output }) {
|
|
48
|
+
if (!isResolved(news))
|
|
49
|
+
return undefined;
|
|
50
|
+
if (output && news.dataset !== output.dataset) {
|
|
51
|
+
return { action: "replace" };
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}),
|
|
55
|
+
create: Effect.fn(function* ({ news }) {
|
|
56
|
+
return yield* create(news);
|
|
57
|
+
}),
|
|
58
|
+
update: Effect.fn(function* ({ news, output }) {
|
|
59
|
+
return yield* update({ ...news, id: output.id });
|
|
60
|
+
}),
|
|
61
|
+
delete: Effect.fn(function* ({ output }) {
|
|
62
|
+
yield* del({ id: output.id }).pipe(Effect.catchTag("NotFound", () => Effect.void));
|
|
63
|
+
}),
|
|
64
|
+
read: Effect.fn(function* ({ output }) {
|
|
65
|
+
if (!output?.id)
|
|
66
|
+
return undefined;
|
|
67
|
+
return yield* get({ id: output.id }).pipe(Effect.catchTag("NotFound", () => Effect.succeed(undefined)));
|
|
68
|
+
}),
|
|
69
|
+
};
|
|
70
|
+
}));
|
|
71
|
+
//# sourceMappingURL=VirtualField.js.map
|
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
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";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Axiom/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./Annotation.js";
|
|
2
|
+
export * from "./ApiToken.js";
|
|
3
|
+
export * from "./AuthProvider.js";
|
|
4
|
+
export * from "./Chart.js";
|
|
5
|
+
export * from "./Credentials.js";
|
|
6
|
+
export * from "./Dashboard.js";
|
|
7
|
+
export * from "./Dataset.js";
|
|
8
|
+
export * from "./Monitor.js";
|
|
9
|
+
export * from "./Notifier.js";
|
|
10
|
+
export * from "./Providers.js";
|
|
11
|
+
export * from "./View.js";
|
|
12
|
+
export * from "./VirtualField.js";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Axiom/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC"}
|
package/lib/Bundle/Bundle.d.ts
CHANGED
|
@@ -3,6 +3,24 @@ import * as Path from "effect/Path";
|
|
|
3
3
|
import * as Result from "effect/Result";
|
|
4
4
|
import * as Stream from "effect/Stream";
|
|
5
5
|
import * as rolldown from "rolldown";
|
|
6
|
+
import { type PurePluginOptions } from "./PurePlugin.ts";
|
|
7
|
+
/**
|
|
8
|
+
* Extra options accepted by {@link build} / {@link watch} on top of the
|
|
9
|
+
* standard rolldown input/output options.
|
|
10
|
+
*/
|
|
11
|
+
export interface BundleExtraOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Configures the {@link purePlugin} which annotates top-level
|
|
14
|
+
* call/new expressions in matching packages with `/*#__PURE__*\/`
|
|
15
|
+
* so rolldown can tree-shake them.
|
|
16
|
+
*
|
|
17
|
+
* - `undefined` (default): plugin is enabled with default packages
|
|
18
|
+
* (`effect`, `@effect/*`).
|
|
19
|
+
* - `PurePluginOptions`: plugin is enabled with the provided options.
|
|
20
|
+
* - `false`: plugin is disabled.
|
|
21
|
+
*/
|
|
22
|
+
readonly pure?: PurePluginOptions | false;
|
|
23
|
+
}
|
|
6
24
|
export interface BundleOutput {
|
|
7
25
|
/**
|
|
8
26
|
* The files in the bundle.
|
|
@@ -33,14 +51,14 @@ export declare class BundleError extends BundleError_base<{
|
|
|
33
51
|
* @param outputOptions - The output options for the bundle.
|
|
34
52
|
* @returns The bundle output.
|
|
35
53
|
*/
|
|
36
|
-
export declare const build: (inputOptions: rolldown.InputOptions, outputOptions?: rolldown.OutputOptions) => Effect.Effect<BundleOutput, BundleError>;
|
|
54
|
+
export declare const build: (inputOptions: rolldown.InputOptions, outputOptions?: rolldown.OutputOptions, extra?: BundleExtraOptions) => Effect.Effect<BundleOutput, BundleError>;
|
|
37
55
|
/**
|
|
38
56
|
* Watch for changes in the bundle and return a stream of bundle output.
|
|
39
57
|
* @param inputOptions - The input options for the bundle.
|
|
40
58
|
* @param outputOptions - The output options for the bundle.
|
|
41
59
|
* @returns A stream of Result instances containing either the bundle output or an error.
|
|
42
60
|
*/
|
|
43
|
-
export declare const watch: (inputOptions: rolldown.InputOptions, outputOptions?: rolldown.OutputOptions) => Stream.Stream<Result.Result<BundleOutput, BundleError>>;
|
|
61
|
+
export declare const watch: (inputOptions: rolldown.InputOptions, outputOptions?: rolldown.OutputOptions, extra?: BundleExtraOptions) => Stream.Stream<Result.Result<BundleOutput, BundleError>>;
|
|
44
62
|
export declare const virtualEntryPlugin: Effect.Effect<(content: (importPath: string) => string) => {
|
|
45
63
|
name: string;
|
|
46
64
|
options(this: rolldown.MinimalPluginContext, inputOptions: rolldown.InputOptions): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bundle.d.ts","sourceRoot":"","sources":["../../src/Bundle/Bundle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"Bundle.d.ts","sourceRoot":"","sources":["../../src/Bundle/Bundle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAA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M,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;oBA2B/C,CAAC;AAEH,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,QAAQ,CAAC,YAAY,GAC5B,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,CAiB1C"}
|
package/lib/Bundle/Bundle.js
CHANGED
|
@@ -7,6 +7,7 @@ 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.js";
|
|
10
|
+
import { purePlugin } from "./PurePlugin.js";
|
|
10
11
|
export class BundleError extends Data.TaggedError("BundleError") {
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
@@ -15,10 +16,11 @@ export class BundleError extends Data.TaggedError("BundleError") {
|
|
|
15
16
|
* @param outputOptions - The output options for the bundle.
|
|
16
17
|
* @returns The bundle output.
|
|
17
18
|
*/
|
|
18
|
-
export const build = (inputOptions, outputOptions) => Effect.tryPromise({
|
|
19
|
+
export const build = (inputOptions, outputOptions, extra) => Effect.tryPromise({
|
|
19
20
|
try: async () => {
|
|
20
21
|
const bundle = await rolldown.rolldown({
|
|
21
22
|
...inputOptions,
|
|
23
|
+
plugins: withPurePlugin(inputOptions.plugins, extra?.pure),
|
|
22
24
|
optimization: inputOptions.optimization ?? {
|
|
23
25
|
inlineConst: {
|
|
24
26
|
mode: "smart",
|
|
@@ -38,11 +40,11 @@ export const build = (inputOptions, outputOptions) => Effect.tryPromise({
|
|
|
38
40
|
* @param outputOptions - The output options for the bundle.
|
|
39
41
|
* @returns A stream of Result instances containing either the bundle output or an error.
|
|
40
42
|
*/
|
|
41
|
-
export const watch = (inputOptions, outputOptions) => Stream.callback((queue) => Effect.acquireRelease(Effect.sync(() => {
|
|
43
|
+
export const watch = (inputOptions, outputOptions, extra) => Stream.callback((queue) => Effect.acquireRelease(Effect.sync(() => {
|
|
42
44
|
const watcher = rolldown.watch({
|
|
43
45
|
...inputOptions,
|
|
44
46
|
plugins: [
|
|
45
|
-
inputOptions.plugins,
|
|
47
|
+
withPurePlugin(inputOptions.plugins, extra?.pure),
|
|
46
48
|
// The watcher event listener does not receive the bundle output, so we grab it using a plugin.
|
|
47
49
|
{
|
|
48
50
|
name: "alchemy:watch-bundle",
|
|
@@ -113,6 +115,19 @@ export function bundleOutputFromRolldownOutputBundle(bundle) {
|
|
|
113
115
|
}
|
|
114
116
|
return Effect.forEach(files, bundleFileFromOutputChunk).pipe(Effect.flatMap(bundleOutputFromFiles));
|
|
115
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Composes the user-provided plugin chain with the default
|
|
120
|
+
* {@link purePlugin} according to the `pure` option.
|
|
121
|
+
*
|
|
122
|
+
* The pure plugin is appended LAST so it sees module ids that have already
|
|
123
|
+
* been resolved into `node_modules/<pkg>/...` by upstream resolver plugins
|
|
124
|
+
* such as `@distilled.cloud/cloudflare-rolldown-plugin`.
|
|
125
|
+
*/
|
|
126
|
+
function withPurePlugin(plugins, pure) {
|
|
127
|
+
if (pure === false)
|
|
128
|
+
return plugins;
|
|
129
|
+
return [plugins, purePlugin(pure ?? {})];
|
|
130
|
+
}
|
|
116
131
|
function bundleErrorFromUnknown(error) {
|
|
117
132
|
const message = error instanceof Error ? error.message : String(error);
|
|
118
133
|
return new BundleError({
|
package/lib/Bundle/Bundle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bundle.js","sourceRoot":"","sources":["../../src/Bundle/Bundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,MAAM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KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBAC/C,IAAI,EAAE,KAAK,CAAC,QAAQ;gBACpB,OAAO,EAAE,KAAK,CAAC,IAAI;gBACnB,IAAI;aACL,CAAC,CAAC,CAAC;QACN,KAAK,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACjD,IAAI,EAAE,KAAK,CAAC,QAAQ;gBACpB,OAAO,EAAE,KAAK,CAAC,MAAM;gBACrB,IAAI;aACL,CAAC,CAAC,CAAC;IACR,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import MagicString from "magic-string";
|
|
2
|
+
import type * as rolldown from "rolldown";
|
|
3
|
+
/**
|
|
4
|
+
* Default packages whose modules will receive `/*#__PURE__*\/` annotations.
|
|
5
|
+
* Mirrors what `effect-smol` ships via `babel-plugin-annotate-pure-calls`
|
|
6
|
+
* applied to its own `dist/` output.
|
|
7
|
+
*
|
|
8
|
+
* `alchemy` is included so its own resources (which consist almost entirely
|
|
9
|
+
* of `Effect.fn(...)`, `Context.Service(...)(...)`, `Layer.effect(...)` and
|
|
10
|
+
* `Data.TaggedError(...)` top-level calls) become tree-shakeable. The
|
|
11
|
+
* package already declares `"sideEffects": false`, so it is safe.
|
|
12
|
+
*/
|
|
13
|
+
export declare const DEFAULT_PURE_PACKAGES: ReadonlyArray<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Options for {@link purePlugin}.
|
|
16
|
+
*/
|
|
17
|
+
export interface PurePluginOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Extra package names or globs to annotate, in addition to
|
|
20
|
+
* {@link DEFAULT_PURE_PACKAGES}. Globs are matched with picomatch
|
|
21
|
+
* against the package name (e.g. `effect`, `@effect/cluster`).
|
|
22
|
+
*/
|
|
23
|
+
readonly packages?: ReadonlyArray<string>;
|
|
24
|
+
/**
|
|
25
|
+
* If true, the configured `packages` list replaces the defaults
|
|
26
|
+
* entirely instead of extending them.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
readonly replaceDefaults?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* If true, also marks matched modules as side-effect free
|
|
32
|
+
* (mirrors `"sideEffects": []` in package.json), so rolldown drops
|
|
33
|
+
* unused re-exports from those packages.
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
readonly markSideEffectFree?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* If true, automatically detect the npm package that owns the bundle
|
|
39
|
+
* entry (by walking up to the nearest `package.json`) and annotate it
|
|
40
|
+
* too. This makes the user's own source tree-shakeable without any
|
|
41
|
+
* configuration.
|
|
42
|
+
*
|
|
43
|
+
* The package's `sideEffects` field is NOT consulted for this gate —
|
|
44
|
+
* if your entry's package has init-time side effects you wish to
|
|
45
|
+
* preserve, declare them in `package.json` (`"sideEffects": ["./foo.ts"]`)
|
|
46
|
+
* or set this option to `false`.
|
|
47
|
+
*
|
|
48
|
+
* @default true
|
|
49
|
+
*/
|
|
50
|
+
readonly autoDetectEntryPackage?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Rolldown plugin that injects `/*#__PURE__*\/` annotations on top-level
|
|
54
|
+
* call/new expressions of modules belonging to the configured packages,
|
|
55
|
+
* enabling tree-shaking of `effect`, `@effect/*`, and any user-listed
|
|
56
|
+
* packages without requiring a babel post-build pass.
|
|
57
|
+
*/
|
|
58
|
+
export declare const purePlugin: (options?: PurePluginOptions) => rolldown.Plugin;
|
|
59
|
+
/**
|
|
60
|
+
* Metadata extracted from a `package.json`. `name` may be `null` when the
|
|
61
|
+
* file exists but has no `"name"` field (rare, but possible for private
|
|
62
|
+
* subpackage roots).
|
|
63
|
+
*/
|
|
64
|
+
export interface PackageInfo {
|
|
65
|
+
readonly name: string | null;
|
|
66
|
+
readonly sideEffects: unknown;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Extracts the npm package name from a resolved module id by walking back to
|
|
70
|
+
* the last `node_modules/` segment. Handles scoped packages. This is the
|
|
71
|
+
* fast path that does not hit the filesystem; it works for ordinary
|
|
72
|
+
* `node_modules/<pkg>/...` ids but NOT for workspace-linked sources whose
|
|
73
|
+
* resolved path is e.g. `<repo>/packages/alchemy/src/Bundle/PurePlugin.ts`.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* packageNameFromId("/proj/node_modules/effect/dist/Effect.js")
|
|
77
|
+
* // => "effect"
|
|
78
|
+
* packageNameFromId("/proj/node_modules/@effect/cluster/dist/index.js")
|
|
79
|
+
* // => "@effect/cluster"
|
|
80
|
+
*/
|
|
81
|
+
export declare function packageNameFromId(id: string): string | null;
|
|
82
|
+
/**
|
|
83
|
+
* Resolves the owning {@link PackageInfo} for a module id by walking up
|
|
84
|
+
* the directory tree to the nearest `package.json`. This is what makes
|
|
85
|
+
* the plugin work for workspace-linked sources (e.g. our own
|
|
86
|
+
* `packages/alchemy/src/**` when consumers import via the `worker`/`bun`
|
|
87
|
+
* conditions which resolve to `.ts`).
|
|
88
|
+
*
|
|
89
|
+
* Caches both positive and negative results per directory to keep the
|
|
90
|
+
* filesystem walk bounded across an entire bundle pass.
|
|
91
|
+
*/
|
|
92
|
+
export declare function resolvePackageInfo(id: string, cache: Map<string, PackageInfo | null>): Promise<PackageInfo | null>;
|
|
93
|
+
/**
|
|
94
|
+
* Convenience wrapper that returns just the package name. Equivalent to
|
|
95
|
+
* `resolvePackageInfo(...)?.name ?? packageNameFromId(id)`.
|
|
96
|
+
*/
|
|
97
|
+
export declare function resolvePackageName(id: string, cache: Map<string, string | null>): Promise<string | null>;
|
|
98
|
+
interface AnnotatedModule {
|
|
99
|
+
readonly code: string;
|
|
100
|
+
readonly map: ReturnType<MagicString["generateMap"]>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Parses `code` and inserts `/*#__PURE__*\/` before every top-level
|
|
104
|
+
* `CallExpression` / `NewExpression` callee. Returns `null` if the file
|
|
105
|
+
* does not need to be modified (parse failure or no annotations added).
|
|
106
|
+
*/
|
|
107
|
+
export declare function annotateModule(code: string, filename: string): AnnotatedModule | null;
|
|
108
|
+
export {};
|
|
109
|
+
//# sourceMappingURL=PurePlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PurePlugin.d.ts","sourceRoot":"","sources":["../../src/Bundle/PurePlugin.ts"],"names":[],"mappings":"AAWA,OAAO,WAAW,MAAM,cAAc,CAAC;AAIvC,OAAO,KAAK,KAAK,QAAQ,MAAM,UAAU,CAAC;AAG1C;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,MAAM,CAKvD,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IACtC;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAC3C;AAKD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GACrB,UAAS,iBAAsB,KAC9B,QAAQ,CAAC,MA+DX,CAAC;AAkDF;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAkDD;;;;;;;;;;;;GAYG;AACH,wB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