EdgeAIG's picture
download
raw
7.75 kB
/**
* Defines the experimental wire schema used by the Effect devtools protocol.
*
* The module contains the serialized message shapes exchanged between devtools
* clients and servers: span snapshots, span events, metric snapshots,
* heartbeats, and request/response unions. Use these schemas at protocol
* boundaries to encode, decode, or validate custom transports that need to
* interoperate with the built-in unstable devtools client and server.
*
* @since 4.0.0
*/
import * as Exit from "../../Exit.js";
import { identity } from "../../Function.js";
import * as Schema from "../../Schema.js";
import * as SchemaTransformation from "../../SchemaTransformation.js";
/**
* Schema for a span status representing a span that has started but not yet
* ended.
*
* @category schemas
* @since 4.0.0
*/
export const SpanStatusStarted = /*#__PURE__*/Schema.Struct({
_tag: /*#__PURE__*/Schema.tag("Started"),
startTime: Schema.BigInt
});
/**
* Schema for a span status representing an ended span, including start time,
* end time, and encoded exit status. Encoding drops success values with
* `Exit.asVoid`.
*
* @category schemas
* @since 4.0.0
*/
export const SpanStatusEnded = /*#__PURE__*/Schema.Struct({
_tag: /*#__PURE__*/Schema.tag("Ended"),
startTime: Schema.BigInt,
endTime: Schema.BigInt,
exit: /*#__PURE__*/Schema.Exit(Schema.Void, Schema.Defect({
includeStack: true
}), Schema.Defect({
includeStack: true
})).pipe(/*#__PURE__*/Schema.decodeTo(/*#__PURE__*/Schema.Exit(Schema.Unknown, Schema.Unknown, Schema.Unknown), /*#__PURE__*/SchemaTransformation.transform({
decode: identity,
encode: Exit.asVoid
})))
});
/**
* Schema for devtools span status, either started or ended.
*
* @category schemas
* @since 4.0.0
*/
export const SpanStatus = /*#__PURE__*/Schema.Union([SpanStatusStarted, SpanStatusEnded]);
/**
* Schema for an external parent span context containing span id, trace id, and
* sampling flag.
*
* @category schemas
* @since 4.0.0
*/
export const ExternalSpan = /*#__PURE__*/Schema.Struct({
_tag: /*#__PURE__*/Schema.tag("ExternalSpan"),
spanId: Schema.String,
traceId: Schema.String,
sampled: Schema.Boolean
});
/**
* Schema for an Effect span telemetry payload sent to devtools.
*
* @category schemas
* @since 4.0.0
*/
export const Span = /*#__PURE__*/Schema.Struct({
_tag: /*#__PURE__*/Schema.tag("Span"),
spanId: Schema.String,
traceId: Schema.String,
name: Schema.String,
sampled: Schema.Boolean,
attributes: /*#__PURE__*/Schema.ReadonlyMap(Schema.String, Schema.Any),
status: SpanStatus,
parent: /*#__PURE__*/Schema.Option(/*#__PURE__*/Schema.suspend(() => ParentSpan))
});
/**
* Schema for a named event emitted by a span, including trace id, span id,
* start time, and optional attributes.
*
* @category schemas
* @since 4.0.0
*/
export const SpanEvent = /*#__PURE__*/Schema.Struct({
_tag: /*#__PURE__*/Schema.tag("SpanEvent"),
traceId: Schema.String,
spanId: Schema.String,
name: Schema.String,
startTime: Schema.BigInt,
attributes: /*#__PURE__*/Schema.UndefinedOr(/*#__PURE__*/Schema.Record(Schema.String, Schema.Any))
});
/**
* Schema for a span parent, either a full devtools `Span` payload or an
* `ExternalSpan` context.
*
* @category schemas
* @since 4.0.0
*/
export const ParentSpan = /*#__PURE__*/Schema.Union([Span, ExternalSpan]);
/**
* Schema for the devtools heartbeat request sent by the client.
*
* @category schemas
* @since 4.0.0
*/
export const Ping = /*#__PURE__*/Schema.Struct({
_tag: /*#__PURE__*/Schema.tag("Ping")
});
/**
* Schema for the devtools heartbeat response.
*
* @category schemas
* @since 4.0.0
*/
export const Pong = /*#__PURE__*/Schema.Struct({
_tag: /*#__PURE__*/Schema.tag("Pong")
});
/**
* Schema for a devtools request asking the client to send a metrics snapshot.
*
* @category schemas
* @since 4.0.0
*/
export const MetricsRequest = /*#__PURE__*/Schema.Struct({
_tag: /*#__PURE__*/Schema.tag("MetricsRequest")
});
/**
* Schema for a metric label key/value pair in a devtools metrics snapshot.
*
* @category schemas
* @since 4.0.0
*/
export const MetricLabel = /*#__PURE__*/Schema.Struct({
key: Schema.String,
value: Schema.String
});
const metric = (type, state) => Schema.Struct({
id: Schema.String,
type: Schema.tag(type),
description: Schema.UndefinedOr(Schema.String),
attributes: Schema.UndefinedOr(Schema.Record(Schema.String, Schema.String)),
state
});
/**
* Schema for a counter metric snapshot, including the count and whether updates
* are incremental.
*
* @category schemas
* @since 4.0.0
*/
export const Counter = /*#__PURE__*/metric("Counter", /*#__PURE__*/Schema.Struct({
count: /*#__PURE__*/Schema.Union([Schema.Number, Schema.BigInt]),
incremental: Schema.Boolean
}));
/**
* Schema for a devtools frequency metric snapshot.
*
* **Details**
*
* The metric state records occurrence counts by string key.
*
* @category schemas
* @since 4.0.0
*/
export const Frequency = /*#__PURE__*/metric("Frequency", /*#__PURE__*/Schema.Struct({
occurrences: /*#__PURE__*/Schema.ReadonlyMap(Schema.String, Schema.Number)
}));
/**
* Schema for a devtools gauge metric snapshot.
*
* **Details**
*
* The metric state contains the current numeric or bigint value.
*
* @category schemas
* @since 4.0.0
*/
export const Gauge = /*#__PURE__*/metric("Gauge", /*#__PURE__*/Schema.Struct({
value: /*#__PURE__*/Schema.Union([Schema.Number, Schema.BigInt])
}));
/**
* Schema for a devtools histogram metric snapshot.
*
* **Details**
*
* The metric state includes bucket counts plus the total count, minimum,
* maximum, and sum.
*
* @category schemas
* @since 4.0.0
*/
export const Histogram = /*#__PURE__*/metric("Histogram", /*#__PURE__*/Schema.Struct({
buckets: /*#__PURE__*/Schema.Array(/*#__PURE__*/Schema.Tuple([Schema.Number, Schema.Number])),
count: Schema.Number,
min: Schema.Number,
max: Schema.Number,
sum: Schema.Number
}));
/**
* Schema for a devtools summary metric snapshot.
*
* **Details**
*
* The metric state contains quantile values plus the total count, minimum,
* maximum, and sum.
*
* @category schemas
* @since 4.0.0
*/
export const Summary = /*#__PURE__*/metric("Summary", /*#__PURE__*/Schema.Struct({
quantiles: /*#__PURE__*/Schema.Array(/*#__PURE__*/Schema.Tuple([Schema.Number, /*#__PURE__*/Schema.UndefinedOr(Schema.Number)])),
count: Schema.Number,
min: Schema.Number,
max: Schema.Number,
sum: Schema.Number
}));
/**
* Schema for any devtools metric snapshot.
*
* **Details**
*
* Accepted metric kinds are counters, frequencies, gauges, histograms, and
* summaries.
*
* @category schemas
* @since 4.0.0
*/
export const Metric = /*#__PURE__*/Schema.Union([Counter, Frequency, Gauge, Histogram, Summary]);
/**
* Schema for a devtools protocol message containing the current metric
* snapshots.
*
* @category schemas
* @since 4.0.0
*/
export const MetricsSnapshot = /*#__PURE__*/Schema.Struct({
_tag: /*#__PURE__*/Schema.tag("MetricsSnapshot"),
metrics: /*#__PURE__*/Schema.Array(Metric)
});
/**
* Schema for devtools protocol requests accepted by the server.
*
* **Details**
*
* Requests include heartbeat pings, spans, span events, and metric snapshots.
*
* @category schemas
* @since 4.0.0
*/
export const Request = /*#__PURE__*/Schema.Union([Ping, Span, SpanEvent, MetricsSnapshot]);
/**
* Schema for devtools protocol responses sent by the server.
*
* **Details**
*
* Responses include heartbeat pongs and requests for metric snapshots.
*
* @category schemas
* @since 4.0.0
*/
export const Response = /*#__PURE__*/Schema.Union([Pong, MetricsRequest]);
//# sourceMappingURL=DevToolsSchema.js.map

Xet Storage Details

Size:
7.75 kB
·
Xet hash:
42f741a963d22548b50b496f30df419fc0b2589277fcf1870c7f5bd18ee9fba2

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.