apps 0.0.1-beta.143 → 0.0.1-beta.148
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/README.md +14 -0
- package/check-publish.mjs +0 -1
- package/framework-reference.json +1 -1
- package/js/{chunk-IWLFLMIL.js → chunk-4XXHO5UG.js} +3966 -1760
- package/js/{chunk-NXUNFV44.js → chunk-63BS5GBH.js} +9 -14
- package/js/{chunk-2XEQYDQY.js → chunk-A6FRLRCN.js} +0 -1
- package/js/{chunk-PASOVDON.js → chunk-ALZDZ3ZT.js} +9 -30
- package/js/{chunk-H4JK7UTH.js → chunk-CQCY3OZS.js} +8 -49
- package/js/{chunk-V6OUBNL4.js → chunk-CWAPV2TN.js} +4 -6
- package/js/{chunk-RW5EXIO6.js → chunk-DX5DD6Z2.js} +8 -17
- package/js/{chunk-B54D6AN7.js → chunk-E2PVLAGK.js} +7 -15
- package/js/{chunk-LRXY54YF.js → chunk-EXL6F456.js} +1 -1
- package/js/{chunk-Y3QPWYHC.js → chunk-FWK2WTJB.js} +4 -5
- package/js/{chunk-2OGVSUNI.js → chunk-GWFQCQB5.js} +2 -2
- package/js/chunk-HEFJFDU4.js +87 -0
- package/js/{chunk-XRNSAU62.js → chunk-I7MYW7IK.js} +2 -2
- package/js/{chunk-ADG72XX3.js → chunk-JLHRRTRH.js} +6 -13
- package/js/{chunk-K24M6LZ7.js → chunk-MXFPSMNM.js} +2 -2
- package/js/{chunk-INQON4A2.js → chunk-OA4UYCJ4.js} +2 -2
- package/js/{chunk-3RIEA22Q.js → chunk-PUMGAWHB.js} +24 -43
- package/js/{chunk-W6V5OIHB.js → chunk-SEJXUMGT.js} +267 -1
- package/js/{chunk-RUSVGD5N.js → chunk-SXYFFXHM.js} +2 -2
- package/js/{chunk-BHSWVS3Q.js → chunk-UT2CBMW3.js} +4 -1
- package/js/{chunk-XAOJP46A.js → chunk-XR7KZNKD.js} +1 -1
- package/js/{chunk-TMYRAFMC.js → chunk-ZWFMEH2Y.js} +18 -1
- package/js/client.js +31 -14
- package/js/contracts.js +3 -4
- package/js/effect.js +14 -15
- package/js/graphql.js +16 -19
- package/js/host.js +14 -17
- package/js/index.js +10 -16
- package/js/mcp/effect.js +15 -16
- package/js/mcp.js +17 -18
- package/js/openapi.js +14 -22
- package/js/react.js +122 -3
- package/js/skills/effect.js +3 -4
- package/js/skills.js +17 -24
- package/js/ui/auth/contracts.js +5 -1
- package/js/ui/auth.js +7 -4
- package/js/ui/contracts.js +52 -5
- package/js/ui/serving.js +55 -17
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/app-cache/src/index.d.ts +1 -40
- package/types/app-data/src/contracts/database.d.ts +0 -21
- package/types/apps/src/client.d.ts +3 -0
- package/types/apps/src/contracts/desktop-errors.d.ts +46 -0
- package/types/apps/src/contracts/desktop.d.ts +228 -0
- package/types/apps/src/contracts/ui-auth.d.ts +4 -1
- package/types/apps/src/contracts/ui.d.ts +43 -1
- package/types/apps/src/implementation/desktop.d.ts +85 -0
- package/types/apps/src/implementation/ui-serving.d.ts +13 -1
- package/types/apps/src/react.d.ts +29 -0
- package/types/apps/src/ui-serving.d.ts +1 -1
- package/types/telemetry/src/app-records.d.ts +0 -24
- package/types/telemetry/src/browser-operations.d.ts +0 -8
- package/types/telemetry/src/browser-performance.d.ts +0 -2
- package/types/telemetry/src/browser-request-timing.d.ts +0 -1
- package/types/telemetry/src/browser.d.ts +0 -10
- package/types/telemetry/src/config.d.ts +0 -8
- package/types/telemetry/src/context.d.ts +0 -6
- package/types/telemetry/src/index.d.ts +0 -1
- package/types/telemetry/src/keepalive.d.ts +0 -44
- package/types/telemetry/src/layer.d.ts +0 -8
- package/types/telemetry/src/measurements.d.ts +0 -8
- package/types/telemetry/src/ownership.d.ts +0 -45
- package/types/telemetry/src/pending-span.d.ts +0 -2
- package/types/telemetry/src/recorded-failure.d.ts +0 -26
- package/types/telemetry/src/relay.d.ts +0 -29
- package/types/telemetry/src/span-attributes.d.ts +0 -38
- package/types/telemetry/src/trace-context.d.ts +0 -6
- package/types/telemetry/src/transport.d.ts +0 -10
- package/types/utils/src/api-error.d.ts +0 -22
- package/types/utils/src/connection-failure.d.ts +0 -10
- package/types/utils/src/random-uuid.d.ts +0 -5
- package/types/utils/src/recorded-message.d.ts +0 -15
- package/types/utils/src/schema-definitions.d.ts +0 -6
- package/types/utils/src/user-facing-error.d.ts +0 -19
- package/js/chunk-QLUWYCOT.js +0 -2325
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
import { AsyncResult, type Atom } from "effect/reactivity";
|
|
2
|
+
import type { DesktopPermission, DesktopPermissionState } from "./contracts/desktop.js";
|
|
2
3
|
/** Subscribe for the component lifetime. Each mount owns and disposes its registry, including StrictMode remounts. */
|
|
3
4
|
export declare const useAppQuery: <A, E>(atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>) => {
|
|
4
5
|
data: A | undefined;
|
|
5
6
|
pending: boolean;
|
|
6
7
|
error: string | undefined;
|
|
7
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Hold a global desktop shortcut while the component is mounted, calling the latest `handler` on
|
|
11
|
+
* each press. Does nothing outside an installed Executor desktop window. Registering and removing
|
|
12
|
+
* one accelerator happen in order, so a remount or a changed accelerator never races its earlier
|
|
13
|
+
* registration; a removal the desktop refused is tried again before the next registration. Returns
|
|
14
|
+
* why the latest registration failed, such as `ShortcutTaken` or `DesktopPermissionDenied` from
|
|
15
|
+
* `apps/client`, or `undefined`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const useDesktopShortcut: (accelerator: string, handler: () => void) => unknown;
|
|
18
|
+
/**
|
|
19
|
+
* The person's choice for one desktop permission, read when the component mounts and again each
|
|
20
|
+
* time its window gains focus, since they can change it in the app's menu or the dashboard.
|
|
21
|
+
* `undefined` until the first read; `"unavailable"` outside an installed Executor desktop window.
|
|
22
|
+
*/
|
|
23
|
+
export declare const useDesktopPermission: (name: DesktopPermission) => DesktopPermissionState | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Show `count` on the app's icon while the component is mounted (see `desktop.badge.set`), and
|
|
26
|
+
* remove it on unmount. Does nothing outside an installed Executor desktop window. Returns why the
|
|
27
|
+
* latest change failed, such as `DesktopInvalidInput` from `apps/client`, or `undefined`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const useDesktopBadge: (count: number | null) => unknown;
|
|
30
|
+
/**
|
|
31
|
+
* Call the latest `handler` whenever this page's desktop window loses focus (`"blur"`) or gains
|
|
32
|
+
* it (`"focus"`), while the component is mounted. Does nothing outside an installed Executor
|
|
33
|
+
* desktop window. Hide a summoned window on blur with
|
|
34
|
+
* `useDesktopWindowEvent("blur", () => void desktop.window.hide())`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const useDesktopWindowEvent: (type: "focus" | "blur", handler: () => void) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Host-only rendering utilities; the host supplies authorized retained assets. */
|
|
2
|
-
export { appDocument, appAsset, appFile, assetPath, storedAppFile, } from "./implementation/ui-serving.js";
|
|
2
|
+
export { appDocument, appAsset, appIcon, appUiPages, appFile, assetPath, storedAppFile, } from "./implementation/ui-serving.js";
|
|
@@ -1,40 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What the host keeps of the spans and logs an app isolate returns.
|
|
3
|
-
*
|
|
4
|
-
* Those records come from whatever framework the app's build bundles, and the app's own code runs
|
|
5
|
-
* in the same isolate: it can throw any text, name its errors and codes, and rewrite every record
|
|
6
|
-
* before the isolate returns it. So the host does not filter the records it receives. It builds
|
|
7
|
-
* new ones from a closed vocabulary: the framework's span names, attributes whose values are
|
|
8
|
-
* closed sets, counts and status codes, and each exception's kind. Ids, parents and timings are
|
|
9
|
-
* kept. Everything else, including events other than exceptions, links, status and exception
|
|
10
|
-
* messages, stacks and log bodies, is dropped or replaced with a fixed sentence.
|
|
11
|
-
*
|
|
12
|
-
* The vocabulary is the framework's (`packages/apps`, `app-cache`, `app-data`): host request
|
|
13
|
-
* operations, failure sources and reasons, MCP and cache attributes. A name or value outside it is
|
|
14
|
-
* recorded as `unrecognized` or not at all. `bun run check` (`scripts/check-app-telemetry.ts`)
|
|
15
|
-
* fails when the framework names a span or sets an attribute key this vocabulary does not know.
|
|
16
|
-
*/
|
|
17
1
|
import type { Schema } from "effect";
|
|
18
2
|
type Json = Schema.Json;
|
|
19
3
|
type JsonObject = {
|
|
20
4
|
readonly [key: string]: Json;
|
|
21
5
|
};
|
|
22
|
-
/** What an exception message, stack or log body from an app isolate records instead. */
|
|
23
6
|
export declare const appText = "Text from the app is not recorded";
|
|
24
|
-
/** The framework's span names, and the libraries' spans it runs. */
|
|
25
7
|
export declare const appSpanNames: ReadonlySet<string>;
|
|
26
8
|
export declare const appSpanAttributeKeys: ReadonlySet<string>;
|
|
27
|
-
/**
|
|
28
|
-
* Attributes the framework sets whose values the app chooses, such as its tool names, so the host
|
|
29
|
-
* drops them. `scripts/check-app-telemetry.ts` fails on a framework attribute in neither set.
|
|
30
|
-
*/
|
|
31
9
|
export declare const droppedAppAttributeKeys: ReadonlySet<string>;
|
|
32
|
-
/** The span the host records for one an app isolate returned, or nothing without its timings. */
|
|
33
10
|
export declare const appSpan: (span: JsonObject & {
|
|
34
11
|
readonly traceId: string;
|
|
35
12
|
readonly spanId: string;
|
|
36
13
|
}) => JsonObject | undefined;
|
|
37
|
-
/** The log record the host records for one an app isolate returned. */
|
|
38
14
|
export declare const appLog: (log: JsonObject & {
|
|
39
15
|
readonly traceId?: string | undefined;
|
|
40
16
|
readonly spanId?: string | undefined;
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
/** Correlate transport and decoded outcomes without exporting response bodies or errors. */
|
|
2
1
|
import { Effect, Schema, Tracer } from "effect";
|
|
3
2
|
import { HttpClient, HttpClientError } from "effect/http";
|
|
4
|
-
/**
|
|
5
|
-
* A random identity for the current browser document. It is never an authentication or user
|
|
6
|
-
* identifier. Server renders have no document, so they get none instead of sharing one per isolate.
|
|
7
|
-
*/
|
|
8
3
|
export declare const browserPageId: () => string | undefined;
|
|
9
|
-
/** Safe event shared with the host's error reporter and product analytics. */
|
|
10
4
|
export declare const BrowserOperationFailure: Schema.Struct<{
|
|
11
5
|
readonly error_type: Schema.Literals<readonly ["BrowserDecodeFailed", "BrowserConnectionFailed", "BrowserTransportFailed", "BrowserOperationFailed"]>;
|
|
12
6
|
readonly trace_id: Schema.String;
|
|
13
7
|
readonly span_id: Schema.String;
|
|
14
8
|
readonly page_id: Schema.String;
|
|
15
9
|
}>;
|
|
16
|
-
/** Observe transport failure and retain only its trace identity for the subsequent decoder. */
|
|
17
10
|
export declare const observeBrowserTransport: (client: HttpClient.HttpClient) => HttpClient.HttpClient.With<HttpClientError.HttpClientError, never>;
|
|
18
|
-
/** AtomHttpApi invokes this after status/body decoding, including handled schema failures. */
|
|
19
11
|
export declare const observeBrowserResponse: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Tracer.ParentSpan>>;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/** Native page measurements. Observers and reporting fibers belong to the browser Layer. */
|
|
2
1
|
import { Effect } from "effect";
|
|
3
|
-
/** Collect page measurements without making them parents of unrelated API calls. */
|
|
4
2
|
export declare const observeBrowserPerformance: Effect.Effect<{
|
|
5
3
|
flush: Effect.Effect<void, never, never>;
|
|
6
4
|
pause: Effect.Effect<void, never, never>;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
/** Browser-owned Effect telemetry, shared by Promise calls and Atom runtimes. */
|
|
2
1
|
import { Context, Effect, Layer, ManagedRuntime } from "effect";
|
|
3
2
|
import { OtlpExporter } from "effect/observability";
|
|
4
3
|
import { Atom } from "effect/reactivity";
|
|
5
4
|
import type { TelemetryConfig } from "./config.js";
|
|
6
5
|
declare const BrowserTelemetry_base: Context.ServiceClass<BrowserTelemetry, "executor/BrowserTelemetry", {
|
|
7
|
-
/**
|
|
8
|
-
* `load` names the document's initial route without a span: hydration resolves no route
|
|
9
|
-
* change, and first load is measured by the vitals. `start` opens a `ui.navigation` span
|
|
10
|
-
* that the router's next `end` closes or the next `start` interrupts.
|
|
11
|
-
*/
|
|
12
6
|
readonly navigation: (event: {
|
|
13
7
|
readonly type: "load" | "start";
|
|
14
8
|
readonly path: string;
|
|
@@ -17,16 +11,12 @@ declare const BrowserTelemetry_base: Context.ServiceClass<BrowserTelemetry, "exe
|
|
|
17
11
|
}) => Effect.Effect<void>;
|
|
18
12
|
readonly flush: Effect.Effect<void>;
|
|
19
13
|
}>;
|
|
20
|
-
/** Page events use the same tracer and export scope as browser API operations. */
|
|
21
14
|
export declare class BrowserTelemetry extends BrowserTelemetry_base {
|
|
22
15
|
}
|
|
23
|
-
/** Install listeners for this page lifetime. Closing the Layer removes them and drains exporters. */
|
|
24
16
|
export declare const browserTelemetryLayer: (settings: Effect.Effect<TelemetryConfig>) => Layer.Layer<OtlpExporter.Flusher | BrowserTelemetry, never, never>;
|
|
25
|
-
/** Share a memo map so the page and its Atom registries acquire one telemetry Layer. */
|
|
26
17
|
export declare const makeBrowserTelemetry: (settings: Effect.Effect<TelemetryConfig>) => {
|
|
27
18
|
runtime: ManagedRuntime.ManagedRuntime<OtlpExporter.Flusher | BrowserTelemetry, never>;
|
|
28
19
|
atoms: Atom.SharedRuntimeFactory;
|
|
29
20
|
};
|
|
30
|
-
/** Read public build metadata and use only same-origin telemetry endpoints. */
|
|
31
21
|
export declare const browserSettings: (basePath: string, service: string) => Effect.Effect<TelemetryConfig>;
|
|
32
22
|
export { browserPageId, BrowserOperationFailure, observeBrowserTransport, observeBrowserResponse, } from "./browser-operations.js";
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
/** Telemetry configuration is parsed at composition roots; headers remain redacted. */
|
|
2
1
|
import { Config, Context, Effect, Schema } from "effect";
|
|
3
|
-
/** Bound each collector request, including its acknowledgement; exporter retries retain the batch. */
|
|
4
2
|
export declare const telemetryRequestTimeout: "5 seconds";
|
|
5
|
-
/** One private exporter target. Endpoints are complete signal URLs. */
|
|
6
3
|
export declare const TelemetryTarget: Schema.Struct<{
|
|
7
4
|
readonly url: Schema.String;
|
|
8
5
|
readonly headers: Schema.optional<Schema.RedactedFromValue<Schema.$Record<Schema.String, Schema.String>>>;
|
|
9
6
|
}>;
|
|
10
|
-
/** Parsed target with redaction-safe headers. */
|
|
11
7
|
export type TelemetryTarget = typeof TelemetryTarget.Type;
|
|
12
|
-
/** Shared identity and independently selectable OTLP signals. */
|
|
13
8
|
export declare const TelemetryConfig: Schema.Struct<{
|
|
14
9
|
readonly service: Schema.NonEmptyString;
|
|
15
10
|
readonly version: Schema.NonEmptyString;
|
|
@@ -29,9 +24,7 @@ export declare const TelemetryConfig: Schema.Struct<{
|
|
|
29
24
|
}>>;
|
|
30
25
|
readonly metricsProtocol: Schema.optional<Schema.Literals<readonly ["http/json", "http/protobuf"]>>;
|
|
31
26
|
}>;
|
|
32
|
-
/** Resolved telemetry configuration. */
|
|
33
27
|
export type TelemetryConfig = typeof TelemetryConfig.Type;
|
|
34
|
-
/** Host-only destinations; never copied into an app's invocation telemetry capability. */
|
|
35
28
|
export declare const CurrentTelemetryConfig: Context.Reference<{
|
|
36
29
|
readonly service: string;
|
|
37
30
|
readonly version: string;
|
|
@@ -57,7 +50,6 @@ export declare const CurrentTelemetryConfig: Context.Reference<{
|
|
|
57
50
|
} | undefined;
|
|
58
51
|
readonly metricsProtocol?: "http/json" | "http/protobuf" | undefined;
|
|
59
52
|
} | undefined>;
|
|
60
|
-
/** Read OTLP endpoints uniformly for all signals; development chooses which signals to configure. */
|
|
61
53
|
export declare const telemetryConfig: (service: string) => Effect.Effect<{
|
|
62
54
|
readonly service: string;
|
|
63
55
|
readonly version: string;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
/** Explicit telemetry-only context across Promise and HTTP boundaries. */
|
|
2
1
|
import { Context, Effect, Tracer } from "effect";
|
|
3
|
-
/** Trusted in-process capability containing no product authority, database or credentials. */
|
|
4
2
|
export interface InvocationTelemetry {
|
|
5
3
|
readonly context: Context.Context<never>;
|
|
6
4
|
}
|
|
7
|
-
/** Capture the tracer, loggers, registry and parent for a host-owned callback. */
|
|
8
5
|
export declare const captureTelemetry: Effect.Effect<InvocationTelemetry>;
|
|
9
|
-
/** Encode the active span; absent tracing remains a valid no-header case. */
|
|
10
6
|
export declare const traceHeaders: Effect.Effect<Readonly<Record<string, string>>>;
|
|
11
|
-
/** Decode W3C context and start a server span in the recipient's own telemetry runtime. */
|
|
12
7
|
export declare const withRemoteSpan: (request: Request, name: string) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Tracer.ParentSpan>>;
|
|
13
|
-
/** Plain fetch for app authors, correlated with the invocation and cancelled by its owner. */
|
|
14
8
|
export declare const invocationFetch: (signal: AbortSignal) => Effect.Effect<(input: string | URL | Request, init?: RequestInit) => Promise<Response>, never, never>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** Effect-native observability shared by Executor hosts and framework operations. */
|
|
2
1
|
export { CurrentTelemetryConfig, TelemetryConfig, TelemetryTarget, telemetryConfig, } from "./config.js";
|
|
3
2
|
export { telemetryLayer, telemetryFromConfig } from "./layer.js";
|
|
4
3
|
export { captureTelemetry, traceHeaders, withRemoteSpan, invocationFetch, type InvocationTelemetry, } from "./context.js";
|
|
@@ -1,53 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One page-wide budget for keepalive request bodies.
|
|
3
|
-
*
|
|
4
|
-
* Fetch refuses a keepalive request, and `sendBeacon` refuses a beacon, once the page's keepalive
|
|
5
|
-
* bodies in flight would pass 64 KiB. Chromium counts every sender on the page together, the
|
|
6
|
-
* Sentry SDK's sandboxed fetch included, while each SDK counts only its own requests. A refused
|
|
7
|
-
* request never leaves the browser and its sender drops it: an error report sent while trace and
|
|
8
|
-
* log exports were in flight was lost this way.
|
|
9
|
-
*
|
|
10
|
-
* Counted here: the dashboard's trace and log exports, its Sentry reports and its analytics
|
|
11
|
-
* events, each of which goes as an ordinary request when it does not fit. Not counted: PostHog's
|
|
12
|
-
* own requests, which the dashboard sends without keepalive, except the beacons PostHog sends as
|
|
13
|
-
* the page unloads (its queued requests and the last replay chunk); and any other keepalive
|
|
14
|
-
* request or beacon on the page. Those can still fill the quota; a keepalive request the browser
|
|
15
|
-
* refuses then goes once more as an ordinary request, and the page records that it did.
|
|
16
|
-
*/
|
|
17
|
-
/** Which of the page's telemetry senders a request belongs to: a fixed name, never an identifier. */
|
|
18
1
|
export type KeepaliveSender = "exports" | "error-reports" | "error-sessions" | "analytics";
|
|
19
|
-
/** What became of a request the browser refused and the page sent once more as an ordinary one. */
|
|
20
2
|
export type KeepaliveResend = "resent" | "resend-failed";
|
|
21
3
|
type ResendListener = (sender: KeepaliveSender, outcome: KeepaliveResend) => void;
|
|
22
|
-
/**
|
|
23
|
-
* Hear each resend of a refused keepalive request, including those before this was called. The
|
|
24
|
-
* page's telemetry records them; the returned function stops listening.
|
|
25
|
-
*/
|
|
26
4
|
export declare const onKeepaliveResend: (listener: ResendListener) => () => void;
|
|
27
|
-
/**
|
|
28
|
-
* The page's own `fetch`, taken when this module first loads, before any SDK wraps it. The Sentry
|
|
29
|
-
* SDK wraps `window.fetch` to record each request as a breadcrumb on later reports; the page's own
|
|
30
|
-
* reports and analytics events go through this one, so neither becomes a breadcrumb.
|
|
31
|
-
*/
|
|
32
5
|
export declare const pageFetch: typeof fetch;
|
|
33
|
-
/** The keepalive body bytes the page can still send before the browser refuses one. */
|
|
34
6
|
export declare const keepaliveRoom: () => number;
|
|
35
|
-
/**
|
|
36
|
-
* Send with keepalive, counting `keepaliveBytes`, the body's size, against the page's budget; or,
|
|
37
|
-
* given `false`, as an ordinary request. The browser counts a keepalive request until its whole
|
|
38
|
-
* response has arrived, not just its headers, so the bytes are counted until a copy of the
|
|
39
|
-
* response body has been read. Only for idempotent telemetry: see `budgetedFetch`.
|
|
40
|
-
*/
|
|
41
7
|
export declare const countedFetch: (sender: KeepaliveSender, send: typeof fetch, input: RequestInfo | URL, init: RequestInit, keepaliveBytes: number | false) => Promise<Response>;
|
|
42
|
-
/**
|
|
43
|
-
* `send`, with a requested keepalive kept only when the body fits what is left of the page's
|
|
44
|
-
* budget. Otherwise the request goes as an ordinary one, which the browser sends at once but may
|
|
45
|
-
* cancel if the page unloads first.
|
|
46
|
-
*
|
|
47
|
-
* Only for idempotent telemetry: a keepalive request that fails with a TypeError is sent once more,
|
|
48
|
-
* and a TypeError cannot tell a refusal, which sent nothing, from a connection lost after the
|
|
49
|
-
* request was sent. A request whose repeat would do something twice, such as a write, must not
|
|
50
|
-
* use this.
|
|
51
|
-
*/
|
|
52
8
|
export declare const budgetedFetch: (sender: KeepaliveSender, send?: typeof fetch) => typeof fetch;
|
|
53
9
|
export {};
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
/** Portable Effect exporters. The host owns scope and export lifetime. */
|
|
2
1
|
import { Duration, Layer, Logger } from "effect";
|
|
3
2
|
import { type TelemetryConfig } from "./config.js";
|
|
4
|
-
/** How long each signal's final flush may take when the scope closes. */
|
|
5
3
|
export type ShutdownTimeouts = Partial<Record<"traces" | "logs" | "metrics", Duration.Input>>;
|
|
6
|
-
/**
|
|
7
|
-
* Build one tracer per runtime. Event mode defers export until Worker scope finalization.
|
|
8
|
-
* A signal's final flush gets three seconds unless `shutdownTimeouts` names its own bound; only
|
|
9
|
-
* the host that owns a destination knows it answers faster.
|
|
10
|
-
*/
|
|
11
4
|
export declare const telemetryLayer: (config: TelemetryConfig, lifetime?: "process" | "event", logger?: Logger.Logger<unknown, void>, shutdownTimeouts?: ShutdownTimeouts) => Layer.Layer<import("effect/observability/OtlpExporter").Flusher, never, never>;
|
|
12
|
-
/** Node/local entry points resolve telemetry once and share it for their process lifetime. */
|
|
13
5
|
export declare const telemetryFromConfig: (service: string) => Layer.Layer<import("effect/observability/OtlpExporter").Flusher, import("effect/Schema").SchemaError | import("effect/Config").ConfigError, never>;
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
/** Low-cardinality transport measurements; these are wall/CPU totals with explicit units, not app data. */
|
|
2
1
|
import { Effect } from "effect";
|
|
3
|
-
/** Classify URLs into a fixed set before attaching attributes; raw paths and query strings are never labels. */
|
|
4
2
|
export declare const recordResponseReady: (path: string | undefined, method: string, status: number, milliseconds: number) => Effect.Effect<void, never, never>;
|
|
5
|
-
/**
|
|
6
|
-
* Count and log one failed export. `elapsedMs`, when known, is how long its request had run when
|
|
7
|
-
* it failed: an interruption at an exporter's deadline, such as the relay's three seconds, shows
|
|
8
|
-
* that deadline.
|
|
9
|
-
*/
|
|
10
3
|
export declare const recordExportFailure: (path: string, reason: "transport" | "interrupted" | "partial-success" | "capacity" | "acknowledgement" | "timeout" | "relay" | "shutdown", records?: number, elapsedMs?: number) => Effect.Effect<void, never, never>;
|
|
11
|
-
/** Record provider-owned invocation totals separately from response-ready timing. */
|
|
12
4
|
export declare const recordWorkerMeasurements: (worker: string, outcome: string, cpu: number, wall: number) => Effect.Effect<void, never, never>;
|
|
@@ -1,60 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Who a span's work belongs to, and how a measured span's time divides among them. A span that
|
|
3
|
-
* starts work for someone other than its caller declares the owner with `ownedBy`; any other span
|
|
4
|
-
* works for whoever its parent works for. Each instant then belongs to the innermost boundary in
|
|
5
|
-
* progress, so Executor's work inside an upstream session stays Executor's, and an app's callback
|
|
6
|
-
* inside Executor's cache stays the app's. Background work is the exception: everything inside it
|
|
7
|
-
* is background, and it runs beside its caller rather than inside it. It takes no instant from the
|
|
8
|
-
* caller's window; how long it ran within the window is reported beside the division.
|
|
9
|
-
*
|
|
10
|
-
* Workers clocks advance only on I/O, so durations are comparable within one isolate and not across
|
|
11
|
-
* isolates: each isolate measures its own part, and the spans that already bracket the work define
|
|
12
|
-
* it, so the accounting and the trace agree.
|
|
13
|
-
*/
|
|
14
1
|
import { Context, Effect, Tracer } from "effect";
|
|
15
|
-
/**
|
|
16
|
-
* Executor's own work; the app's authored code; waiting on an upstream provider; waiting on a
|
|
17
|
-
* person's answer; waiting on another call that holds the lease to load a cache entry; or work
|
|
18
|
-
* handed to the background, such as refreshing a stale cache entry, that no caller waits on.
|
|
19
|
-
*/
|
|
20
2
|
export type Owner = "executor" | "app" | "upstream" | "person" | "lease" | "background";
|
|
21
|
-
/** The attribute that shows a boundary's owner in the trace; the telemetry tracer sets it. */
|
|
22
3
|
export declare const ownerAttribute = "executor.owner";
|
|
23
|
-
/** The owner a span declared when it started, if it is an ownership boundary. */
|
|
24
4
|
export declare const declaredOwner: (annotations: Context.Context<never>) => Owner | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Options for a span whose work belongs to `owner`. Every ownership boundary uses them, at the point
|
|
27
|
-
* the work starts: provider requests and sessions are the upstream's, Executor's services called by
|
|
28
|
-
* an app are Executor's, an app's callbacks are the app's, and waiting for an answer is the person's.
|
|
29
|
-
*/
|
|
30
5
|
export declare const ownedBy: (owner: Owner, options?: Tracer.SpanOptionsNoTrace) => Tracer.SpanOptionsNoTrace;
|
|
31
|
-
/** Run `effect` in span `name`, owned by `owner`. */
|
|
32
6
|
export declare const owned: (owner: Owner, name: string, options?: Tracer.SpanOptionsNoTrace) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Tracer.ParentSpan>>;
|
|
33
|
-
/** What a measured span does with its work and its end. */
|
|
34
7
|
export interface SpanMeasure {
|
|
35
|
-
/** Wraps the work inside the span, for example to observe the spans it opens. */
|
|
36
8
|
readonly around?: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
37
|
-
/** Receives the span's end, before the span ends, to record what it measured on it. */
|
|
38
9
|
readonly end: (end: bigint, span: Tracer.Span) => void;
|
|
39
10
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Run `effect` in span `name`, measured by `measure` from the span's own start to its own end, so
|
|
42
|
-
* the span's duration and the measurement share both boundaries.
|
|
43
|
-
*/
|
|
44
11
|
export declare const measuredSpan: (name: string, options: Tracer.SpanOptionsNoTrace, measure: (start: bigint) => SpanMeasure) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Tracer.ParentSpan>>;
|
|
45
|
-
/**
|
|
46
|
-
* Divide a window that starts at `origin`, whose own work is `owner`'s, among owners. At each
|
|
47
|
-
* instant, the work in progress is the innermost span of each branch: a span with no child still
|
|
48
|
-
* open. Its owner takes the instant. With nothing open inside the window, `owner` takes it. Spans
|
|
49
|
-
* are counted as they open and end, in constant time each, and only spans still open are kept.
|
|
50
|
-
* `background` is not part of the division: it is how long background work was in progress.
|
|
51
|
-
*/
|
|
52
12
|
export declare const makeOwnershipAccounting: (origin: bigint, owner: Owner) => {
|
|
53
|
-
/** Run `effect` with the spans it opens observed, including spans it hands to later work. */
|
|
54
13
|
observe: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
55
|
-
/**
|
|
56
|
-
* Close the window at `end` and return its milliseconds by owner, each instant counted once.
|
|
57
|
-
* Spans still open count up to `end`; spans that open or end afterwards are ignored.
|
|
58
|
-
*/
|
|
59
14
|
read: (end: bigint) => Readonly<Record<Owner, number>>;
|
|
60
15
|
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/** A span ending at an asynchronous milestone, with cancellation owned by its enclosing scope. */
|
|
2
1
|
import { Effect, Exit, type Tracer } from "effect";
|
|
3
|
-
/** End exactly once at completion, failure, or scope release. It is not installed as a parent implicitly. */
|
|
4
2
|
export declare const pendingSpan: (name: string, options?: Tracer.SpanOptionsNoTrace) => Effect.Effect<{
|
|
5
3
|
span: Tracer.Span;
|
|
6
4
|
finish: (exit: Exit.Exit<unknown, unknown>) => Effect.Effect<void, never, never>;
|
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Failures as Executor's telemetry records them. Traces and error reports keep an error's text only
|
|
3
|
-
* when Executor wrote it: a tagged error is recorded by its tag and the fixed sentence it declares
|
|
4
|
-
* (see `RecordedMessage`), or by its tag alone when it declares none. Its fields, message, stack and
|
|
5
|
-
* cause are not recorded, so a value an error carries for its caller, an app's text or a service's
|
|
6
|
-
* reply cannot reach telemetry by an error forgetting to declare. The error itself, and what its
|
|
7
|
-
* caller receives, are unchanged.
|
|
8
|
-
*/
|
|
9
1
|
import { Cause } from "effect";
|
|
10
|
-
/**
|
|
11
|
-
* The error a trace or error report records in place of `error`.
|
|
12
|
-
*
|
|
13
|
-
* - A tagged error is named by its tag: a field called `name`, such as a requested skill's or an
|
|
14
|
-
* app's, replaces the error's own name. Its message is the sentence it declares, or empty. Its
|
|
15
|
-
* stack is generated here and names no frames: the error's own stack begins with its message,
|
|
16
|
-
* which can span lines that look like frames. Traces still show where it failed through the
|
|
17
|
-
* operation's own spans, which Effect appends to a recorded stack.
|
|
18
|
-
* - Any other value that is not an `Error`, such as a plain object Effect would print as JSON, is
|
|
19
|
-
* recorded as `UnrecognizedFailure` with no text.
|
|
20
|
-
* - An untagged `Error` is a defect or a platform's error: its message and stack come from the
|
|
21
|
-
* JavaScript engine or a library and are kept, as they are the only diagnosis of an Executor bug.
|
|
22
|
-
* Its cause is recorded by these same rules.
|
|
23
|
-
*/
|
|
24
2
|
export declare const recordedError: (error: unknown) => unknown;
|
|
25
|
-
/**
|
|
26
|
-
* A failure's cause as traces record it: each failure and defect by `recordedError`. Interruptions
|
|
27
|
-
* are unchanged, and each reason keeps its annotations, which locate it.
|
|
28
|
-
*/
|
|
29
3
|
export declare const recordedCause: <E>(cause: Cause.Cause<E>) => Cause.Cause<unknown>;
|
|
@@ -1,38 +1,14 @@
|
|
|
1
|
-
/** Bounded OTLP return channel for credential-free app isolates. The parent owns export. */
|
|
2
1
|
import { Context, Effect, Schema, Scope } from "effect";
|
|
3
|
-
/**
|
|
4
|
-
* A telemetry wait a request's close makes that reached its bound: the forwarder's drain, or the
|
|
5
|
-
* product analytics flush. A host that reports how its requests closed records it; the default
|
|
6
|
-
* records nothing.
|
|
7
|
-
*/
|
|
8
2
|
export type TelemetryWait = "forwarder" | "analytics";
|
|
9
3
|
export declare const TelemetryWaitReport: Context.Reference<(wait: TelemetryWait) => Effect.Effect<void>>;
|
|
10
|
-
/**
|
|
11
|
-
* The scope a host gives telemetry it waits for when a request ends: the forwarder's queue and
|
|
12
|
-
* its drain. A host that closes this scope after the request's other resources, such as its
|
|
13
|
-
* database connections, never holds them while it waits on a telemetry endpoint. Unset, the
|
|
14
|
-
* forwarder lives in the scope it is built in. The host may close this scope's finalizers in
|
|
15
|
-
* parallel; each user keeps its own order in a scope of its own.
|
|
16
|
-
*/
|
|
17
4
|
export declare const TelemetryDrainScope: Context.Reference<Scope.Scope | undefined>;
|
|
18
|
-
/**
|
|
19
|
-
* Forward app telemetry in the host scope without delaying an app result.
|
|
20
|
-
* Batches wait in one queue and a single sender exports everything waiting as one request per
|
|
21
|
-
* signal, so a burst of finished runs costs a few exports instead of one each. The queue holds at
|
|
22
|
-
* most eight MiB of payload and one export carries at most four. Overload and shutdown loss are
|
|
23
|
-
* reported through the normal safe export-failure signal. Scope release drains for the same
|
|
24
|
-
* three-second budget as the other exporters, in {@link TelemetryDrainScope} when the host sets it.
|
|
25
|
-
*/
|
|
26
5
|
export declare const makeTelemetryForwarder: Effect.Effect<(batch: TelemetryBatch, traceId: string, source: TelemetrySource) => Effect.Effect<void, never, never>, never, Scope.Scope>;
|
|
27
|
-
/** Untrusted isolate batches are bounded before decoding; no endpoint or credential crosses back. */
|
|
28
6
|
export declare const TelemetryBatch: Schema.Struct<{
|
|
29
7
|
readonly traces: Schema.$Array<Schema.String>;
|
|
30
8
|
readonly logs: Schema.$Array<Schema.String>;
|
|
31
9
|
readonly dropped: Schema.Int;
|
|
32
10
|
}>;
|
|
33
|
-
/** Parsed isolate telemetry envelope. */
|
|
34
11
|
export type TelemetryBatch = typeof TelemetryBatch.Type;
|
|
35
|
-
/** Collect one invocation into memory, flush before returning, and never contact a remote collector. */
|
|
36
12
|
export declare const collectTelemetry: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<{
|
|
37
13
|
value: A;
|
|
38
14
|
telemetry: {
|
|
@@ -41,13 +17,8 @@ export declare const collectTelemetry: <A, E, R>(effect: Effect.Effect<A, E, R>)
|
|
|
41
17
|
dropped: number;
|
|
42
18
|
};
|
|
43
19
|
}, E, Exclude<Exclude<R, import("effect/observability/OtlpExporter").Flusher>, never>>;
|
|
44
|
-
/**
|
|
45
|
-
* What the host knows about the records' source, from its own invocation rather than the records:
|
|
46
|
-
* the build that ran and, for an app isolate, the app's opaque ID. Both become resource attributes.
|
|
47
|
-
*/
|
|
48
20
|
export interface TelemetrySource {
|
|
49
21
|
readonly build?: string | undefined;
|
|
50
22
|
readonly app?: string | undefined;
|
|
51
23
|
}
|
|
52
|
-
/** Validate isolated records and export only this call's trace, using parent-owned credentials/identity. */
|
|
53
24
|
export declare const forwardTelemetry: (batch: TelemetryBatch, traceId: string | undefined, source: TelemetrySource, service?: "executor-app" | "executor-web") => Effect.Effect<void, Schema.SchemaError | import("effect/http/HttpClientError").HttpClientError | import("effect/Cause").TimeoutError, never>;
|
|
@@ -1,48 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP span attributes are allowlisted. Nothing else in an HTTP namespace is recorded.
|
|
3
|
-
*
|
|
4
|
-
* Effect's HTTP client and its server tracer write every request and response
|
|
5
|
-
* header, the full URL and the query string onto their spans. This product
|
|
6
|
-
* routes provider API keys through header and query names chosen by an imported
|
|
7
|
-
* OpenAPI spec, and carries bearer capabilities such as the one-click
|
|
8
|
-
* unsubscribe token in a query parameter and in a redirect `Location` header.
|
|
9
|
-
* No list of dangerous names can keep up with that, so HTTP spans record a
|
|
10
|
-
* fixed set of attributes and drop everything else.
|
|
11
|
-
*
|
|
12
|
-
* The allowlist runs on the tracer because that is the single point where the
|
|
13
|
-
* client tracer and the server tracer meet. Effect's
|
|
14
|
-
* `HttpClient.TracerHeaderFilter` controls outgoing headers only: nothing
|
|
15
|
-
* configures the URL attributes on either side, and the server tracer has no
|
|
16
|
-
* header hook at all. A second filter on the client would duplicate this one
|
|
17
|
-
* rather than complete it, so this is the only boundary.
|
|
18
|
-
*
|
|
19
|
-
* Attributes outside these namespaces are the product's own and pass through.
|
|
20
|
-
*/
|
|
21
1
|
import { Effect, Layer } from "effect";
|
|
22
|
-
/** Every HTTP attribute an exported span may carry. */
|
|
23
2
|
export declare const httpSpanAttributeAllowlist: ReadonlySet<string>;
|
|
24
|
-
/** Record this attribute? HTTP names must be allowlisted; product names pass through. */
|
|
25
3
|
export declare const spanAttributeAllowed: (key: string) => boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Record the template of a route whose path an app or its caller chose, in place of the router's
|
|
28
|
-
* wildcard: an app's own page or asset, or an app's outbound request. Its last parameter stands
|
|
29
|
-
* for the rest of the path. It annotates the current span, so call it from the request's handler.
|
|
30
|
-
*/
|
|
31
4
|
export declare const recordRoute: (template: `/${string}`) => Effect.Effect<void, never, never>;
|
|
32
|
-
/**
|
|
33
|
-
* A fixed set of endpoint templates served under one wildcard route, such as Better Auth's
|
|
34
|
-
* endpoints under `/api/auth/*`. `:name` stands for one segment. `record` names the request's
|
|
35
|
-
* endpoint by its template and leaves the wildcard for any path the set does not hold, so a span
|
|
36
|
-
* keeps which endpoint ran without any segment the caller chose.
|
|
37
|
-
*/
|
|
38
5
|
export declare const routeTemplates: (templates: Iterable<`/${string}`>) => {
|
|
39
6
|
match: (path: string) => `/${string}` | undefined;
|
|
40
7
|
record: (path: string) => Effect.Effect<void, never, never>;
|
|
41
8
|
};
|
|
42
|
-
/**
|
|
43
|
-
* Wrap whichever tracer is already in scope; provide this above the exporter. `ended` runs after
|
|
44
|
-
* each span has ended, once the exporter holds it.
|
|
45
|
-
*/
|
|
46
9
|
export declare const spanAttributes: (clock?: "system" | "cloudflare-io", recordAll?: boolean, ended?: () => void) => Layer.Layer<never>;
|
|
47
|
-
/** Header and URL filtering without making an unsupported claim about the runtime clock. */
|
|
48
10
|
export declare const allowlistedSpans: Layer.Layer<never, never, never>;
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
/** Safe W3C identifiers for correlation across transports that do not carry HTTP headers. */
|
|
2
1
|
import { Effect, Option, Schema, Tracer } from "effect";
|
|
3
|
-
/** Trace metadata conveys no authorization and must never contain app values or credentials. */
|
|
4
2
|
export declare const TraceContext: Schema.Struct<{
|
|
5
3
|
readonly traceId: Schema.String;
|
|
6
4
|
readonly spanId: Schema.String;
|
|
7
5
|
readonly sampled: Schema.Boolean;
|
|
8
6
|
}>;
|
|
9
|
-
/** Decoded, non-authorizing trace identity. */
|
|
10
7
|
export type TraceContext = typeof TraceContext.Type;
|
|
11
|
-
/** Capture only the current span's transport-safe identity. */
|
|
12
8
|
export declare const currentTraceContext: Effect.Effect<{
|
|
13
9
|
readonly traceId: string;
|
|
14
10
|
readonly spanId: string;
|
|
15
11
|
readonly sampled: boolean;
|
|
16
12
|
} | undefined, never, never>;
|
|
17
|
-
/** Invalid or absent optional telemetry never prevents otherwise valid application data from rendering. */
|
|
18
13
|
export declare const externalTrace: (input: unknown) => Option.Option<Tracer.ExternalSpan>;
|
|
19
|
-
/** Link a measurement to the observed request without inventing a parent/child lifetime. */
|
|
20
14
|
export declare const traceLinks: (input: unknown, relationship: string) => ReadonlyArray<Tracer.SpanLink>;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import { Context, Layer } from "effect";
|
|
2
2
|
import { HttpClient, HttpClientError } from "effect/http";
|
|
3
|
-
/** Local collector discovery can resolve its destination when an export runs. */
|
|
4
3
|
export declare const CurrentTelemetryClient: Context.Reference<HttpClient.HttpClient | undefined>;
|
|
5
|
-
/** Telemetry consumers inspect status and headers; release response I/O inside each export scope. */
|
|
6
4
|
export declare const telemetryHttpClient: Layer.Layer<HttpClient.HttpClient, never, never>;
|
|
7
|
-
/**
|
|
8
|
-
* Resend an export the collector refused for now, as OTLP requires and Effect's own
|
|
9
|
-
* exporters do: lost connections, timeouts, 429 and 5xx overload, at most three more times. A
|
|
10
|
-
* collector shedding load answers 429 or 503 with Retry-After, which sets the wait, as long as the
|
|
11
|
-
* next attempt, with its own time-out, still ends within `exportBudget`; a longer wait is shortened
|
|
12
|
-
* to that, so the last attempt runs before the runtime would cut it off. When no attempt fits, the
|
|
13
|
-
* export ends with its last failure.
|
|
14
|
-
*/
|
|
15
5
|
export declare const retryTelemetryExport: (client: HttpClient.HttpClient) => HttpClient.HttpClient.With<HttpClientError.HttpClientError, never>;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { Schema, type Cause } from "effect";
|
|
2
2
|
import "effect/http-api";
|
|
3
|
-
/**
|
|
4
|
-
* Encode the class's `message` getter as a required wire string. Decoding validates the field,
|
|
5
|
-
* then omits it, so the class derives its own message from the parsed payload and a supplied
|
|
6
|
-
* value never replaces it.
|
|
7
|
-
*/
|
|
8
3
|
export declare const MessageField: Schema.decodeTo<Schema.optionalKey<Schema.String>, Schema.String, never, never>;
|
|
9
|
-
/** An expected API error whose response states its cause in a `message` derived from its fields. */
|
|
10
4
|
export interface ApiError extends Cause.YieldableError {
|
|
11
5
|
readonly _tag: string;
|
|
12
6
|
}
|
|
@@ -18,17 +12,7 @@ type Definition<Tag extends string, Fields extends Schema.Struct.Fields> = Heade
|
|
|
18
12
|
readonly fields: Fields & {
|
|
19
13
|
readonly [Key in "_tag" | "message"]?: never;
|
|
20
14
|
};
|
|
21
|
-
/**
|
|
22
|
-
* The cause, stated for API and agent callers. It is also the error's `message`, which traces
|
|
23
|
-
* record, so it never includes credentials, upstream response text or submitted values.
|
|
24
|
-
*/
|
|
25
15
|
readonly message: string | ((fields: Schema.Struct.Type<Fields>) => string);
|
|
26
|
-
/**
|
|
27
|
-
* What traces and error reports record beside the tag. A fixed `message` is recorded as is; a
|
|
28
|
-
* message derived from fields is recorded only through this, from fixed text and closed fields,
|
|
29
|
-
* never a value the caller chose, an app's text or a service's reply. Without it the error is
|
|
30
|
-
* recorded by its tag alone.
|
|
31
|
-
*/
|
|
32
16
|
readonly recorded?: (fields: Schema.Struct.Type<Fields>) => string;
|
|
33
17
|
};
|
|
34
18
|
type ErrorFields<Tag extends string, Fields extends Schema.Struct.Fields> = Omit<Schema.TaggedStruct<Tag, Fields & {
|
|
@@ -39,16 +23,10 @@ type ErrorFields<Tag extends string, Fields extends Schema.Struct.Fields> = Omit
|
|
|
39
23
|
type ErrorClass<Tag extends string, Fields extends Schema.Struct.Fields> = Schema.Class<Schema.Struct.Type<Fields> & ApiError & {
|
|
40
24
|
readonly _tag: Tag;
|
|
41
25
|
}, ErrorFields<Tag, Fields>, ApiError>;
|
|
42
|
-
/** Define an error with no payload and a fixed message. Its tag is its public error code. */
|
|
43
26
|
declare function define<const Tag extends string>(definition: Header<Tag> & {
|
|
44
27
|
readonly message: string;
|
|
45
28
|
}): ErrorClass<Tag, {}>;
|
|
46
|
-
/** Define an error whose message can depend on its parsed fields. */
|
|
47
29
|
declare function define<const Tag extends string, const Fields extends Schema.Struct.Fields>(definition: Definition<Tag, Fields>): ErrorClass<Tag, Fields>;
|
|
48
|
-
/**
|
|
49
|
-
* Define the schema, constructor and API message of an expected error together. Errors that need
|
|
50
|
-
* a user-facing title and recovery use `UserFacingError`, which carries the same message field.
|
|
51
|
-
*/
|
|
52
30
|
export declare const ApiError: {
|
|
53
31
|
define: typeof define;
|
|
54
32
|
};
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
/** Requests the browser could not complete because no response reached it. */
|
|
2
1
|
import { Cause } from "effect";
|
|
3
2
|
import { HttpClientError } from "effect/http";
|
|
4
3
|
import { UserFacingError } from "./user-facing-error.js";
|
|
5
|
-
/**
|
|
6
|
-
* Fetch rejects with a `TypeError` when no response arrives: the device is offline, the page
|
|
7
|
-
* navigated away first, the connection was reset before a response, or the browser blocked the
|
|
8
|
-
* request. The server may still have completed the request and records its own outcome. Failures Executor constructs itself, such as a batch reply
|
|
9
|
-
* that ended without an answer, carry no such cause and stay unexpected.
|
|
10
|
-
*/
|
|
11
4
|
export declare const isConnectionFailure: (error: unknown) => error is HttpClientError.HttpClientError;
|
|
12
|
-
/** Typed API clients may surface a lost connection as a failure or, after narrowing, a defect. */
|
|
13
5
|
export declare const hasConnectionFailure: (cause: Cause.Cause<unknown>) => boolean;
|
|
14
|
-
/** The browser could not reach Executor. Nothing on the server needs fixing. */
|
|
15
6
|
export declare const ConnectionFailed: import("effect/Schema").Class<{} & UserFacingError & {
|
|
16
7
|
readonly _tag: "ConnectionFailed";
|
|
17
8
|
}, Omit<import("effect/Schema").TaggedStruct<"ConnectionFailed", {
|
|
@@ -29,5 +20,4 @@ export declare const ConnectionFailed: import("effect/Schema").Class<{} & UserFa
|
|
|
29
20
|
};
|
|
30
21
|
}, UserFacingError>;
|
|
31
22
|
export type ConnectionFailed = typeof ConnectionFailed.Type;
|
|
32
|
-
/** What to show for a failure no contract declares: a lost connection, or an unexpected error. */
|
|
33
23
|
export declare const undeclaredError: (cause: Cause.Cause<unknown>) => UserFacingError;
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A random UUID v4 for browser code. Browsers expose `crypto.randomUUID` only in secure contexts,
|
|
3
|
-
* and a self-hosted dashboard may be served over plain HTTP on a LAN address, where it is missing.
|
|
4
|
-
* `getRandomValues` exists in every context, so this is the one path everywhere.
|
|
5
|
-
*/
|
|
6
1
|
export declare const randomUuid: () => string;
|