effect-cf 0.40.0 → 0.40.2
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/CHANGELOG.md +14 -0
- package/README.md +2 -0
- package/dist/AiGateway.d.mts +86 -0
- package/dist/AiGateway.mjs +178 -0
- package/dist/AnalyticsEngine.d.mts +170 -0
- package/dist/AnalyticsEngine.mjs +275 -0
- package/dist/{Artifacts-B3r3RuTB.d.mts → Artifacts.d.mts} +8 -5
- package/dist/{Artifacts-CBxWGeZB.mjs → Artifacts.mjs} +9 -5
- package/dist/Binding.d.mts +45 -0
- package/dist/{Binding-C82jRhdr.mjs → Binding.mjs} +8 -4
- package/dist/BrowserRendering.d.mts +85 -0
- package/dist/BrowserRendering.mjs +81 -0
- package/dist/Cache.d.mts +40 -0
- package/dist/Cache.mjs +51 -0
- package/dist/CloudflareOtlp.d.mts +95 -0
- package/dist/CloudflareOtlp.mjs +125 -0
- package/dist/CloudflareTracer.d.mts +20 -0
- package/dist/CloudflareTracer.mjs +69 -0
- package/dist/ComputerArtifacts.d.mts +2 -2
- package/dist/ComputerArtifacts.mjs +3 -2
- package/dist/ComputerWorkspace.d.mts +36 -31
- package/dist/ComputerWorkspace.mjs +8 -3
- package/dist/ComputerWorkspaceHost.d.mts +1 -1
- package/dist/ComputerWorkspaceHost.mjs +1 -1
- package/dist/{ContainerNamespace-DbLaeFhN.d.mts → ContainerNamespace.d.mts} +16 -12
- package/dist/ContainerNamespace.mjs +165 -0
- package/dist/D1.d.mts +33 -0
- package/dist/D1.mjs +32 -0
- package/dist/DurableObject.d.mts +103 -0
- package/dist/DurableObject.mjs +77 -0
- package/dist/DurableObjectAlarm.d.mts +187 -0
- package/dist/DurableObjectAlarm.mjs +344 -0
- package/dist/DurableObjectDefinition.d.mts +87 -0
- package/dist/DurableObjectDefinition.mjs +125 -0
- package/dist/DurableObjectNamespace.d.mts +154 -0
- package/dist/DurableObjectNamespace.mjs +144 -0
- package/dist/DurableObjectRpcWebSocket.d.mts +112 -0
- package/dist/DurableObjectRpcWebSocket.mjs +547 -0
- package/dist/DurableObjectSqlite.d.mts +11 -0
- package/dist/DurableObjectSqlite.mjs +16 -0
- package/dist/DurableObjectState.d.mts +65 -0
- package/dist/DurableObjectState.mjs +47 -0
- package/dist/DurableObjectStorage.d.mts +112 -0
- package/dist/{DurableObjectState-DLL0YgBd.mjs → DurableObjectStorage.mjs} +19 -157
- package/dist/DurableObjectWebSocket.d.mts +83 -0
- package/dist/DurableObjectWebSocket.mjs +120 -0
- package/dist/Email.d.mts +106 -0
- package/dist/Email.mjs +247 -0
- package/dist/Environment.d.mts +59 -0
- package/dist/{ErrorMessage-Byx2OgNd.mjs → Environment.mjs} +7 -18
- package/dist/{Hyperdrive-HrwFlZ6x.d.mts → Hyperdrive.d.mts} +8 -5
- package/dist/Hyperdrive.mjs +32 -0
- package/dist/HyperdrivePg.d.mts +4 -3
- package/dist/HyperdrivePg.mjs +3 -1
- package/dist/Images.d.mts +191 -0
- package/dist/Images.mjs +112 -0
- package/dist/Kv.d.mts +84 -0
- package/dist/Kv.mjs +132 -0
- package/dist/Mcp.d.mts +5 -3
- package/dist/Mcp.mjs +13 -4
- package/dist/Queue.d.mts +64 -0
- package/dist/Queue.mjs +52 -0
- package/dist/QueueBinding.d.mts +42 -0
- package/dist/QueueBinding.mjs +69 -0
- package/dist/QueueDefinition.d.mts +48 -0
- package/dist/QueueDefinition.mjs +63 -0
- package/dist/R2.d.mts +89 -0
- package/dist/R2.mjs +117 -0
- package/dist/Rpc.d.mts +29 -0
- package/dist/Rpc.mjs +28 -0
- package/dist/RpcDefinition.d.mts +116 -0
- package/dist/RpcDefinition.mjs +184 -0
- package/dist/RpcTracing.d.mts +52 -0
- package/dist/RpcTracing.mjs +77 -0
- package/dist/Sandbox.d.mts +10 -5
- package/dist/Sandbox.mjs +9 -3
- package/dist/ServiceBinding.d.mts +112 -0
- package/dist/ServiceBinding.mjs +145 -0
- package/dist/Vectorize.d.mts +68 -0
- package/dist/Vectorize.mjs +76 -0
- package/dist/Vitest.d.mts +6 -4
- package/dist/Vitest.mjs +8 -4
- package/dist/WebTransport.d.mts +66 -0
- package/dist/WebTransport.mjs +63 -0
- package/dist/Worker.d.mts +139 -0
- package/dist/Worker.mjs +141 -0
- package/dist/WorkerDefinition.d.mts +100 -0
- package/dist/WorkerDefinition.mjs +103 -0
- package/dist/WorkersAi.d.mts +84 -0
- package/dist/WorkersAi.mjs +84 -0
- package/dist/Workflow.d.mts +86 -0
- package/dist/Workflow.mjs +137 -0
- package/dist/{WorkflowBinding-DtVykUCz.d.mts → WorkflowBinding.d.mts} +14 -10
- package/dist/WorkflowBinding.mjs +100 -0
- package/dist/WorkflowDefinition.d.mts +51 -0
- package/dist/WorkflowDefinition.mjs +69 -0
- package/dist/{rolldown-runtime-D7D4PA-g.mjs → _virtual/_rolldown/runtime.mjs} +1 -1
- package/dist/index.d.mts +40 -1839
- package/dist/index.mjs +40 -3161
- package/dist/{ComputerWorkspaceHostRegistry-CY5Fv4Ng.mjs → internal/ComputerWorkspaceHostRegistry.mjs} +1 -1
- package/dist/internal/Entrypoint.mjs +37 -0
- package/dist/internal/ErrorMessage.mjs +17 -0
- package/dist/internal/NativeCallback.mjs +33 -0
- package/dist/internal/RpcInvocation.d.mts +13 -0
- package/dist/internal/RpcInvocation.mjs +34 -0
- package/dist/internal/Runtime.mjs +31 -0
- package/dist/internal/Telemetry.mjs +20 -0
- package/dist/{WorkerContext-Yobnfw-K.mjs → internal/WorkerContext.mjs} +4 -31
- package/package.json +1 -1
- package/src/AiGateway.ts +5 -1
- package/src/AnalyticsEngine.ts +14 -19
- package/src/Artifacts.ts +6 -1
- package/src/Binding.ts +5 -1
- package/src/BrowserRendering.ts +5 -1
- package/src/Cache.ts +5 -1
- package/src/CloudflareOtlp.ts +12 -10
- package/src/CloudflareTracer.ts +7 -1
- package/src/ComputerArtifacts.ts +2 -1
- package/src/ComputerWorkspace.ts +7 -1
- package/src/ContainerNamespace.ts +6 -1
- package/src/D1.ts +4 -1
- package/src/DurableObject.ts +4 -1
- package/src/DurableObjectAlarm.ts +10 -12
- package/src/DurableObjectDefinition.ts +3 -1
- package/src/DurableObjectNamespace.ts +4 -1
- package/src/DurableObjectRpcWebSocket.ts +7 -1
- package/src/DurableObjectSqlite.ts +2 -1
- package/src/DurableObjectState.ts +4 -1
- package/src/DurableObjectStorage.ts +11 -13
- package/src/DurableObjectWebSocket.ts +5 -1
- package/src/Email.ts +5 -1
- package/src/Environment.ts +6 -1
- package/src/Hyperdrive.ts +4 -1
- package/src/HyperdrivePg.ts +3 -1
- package/src/Images.ts +7 -1
- package/src/Kv.ts +7 -1
- package/src/Mcp.ts +13 -13
- package/src/Queue.ts +5 -11
- package/src/QueueBinding.ts +5 -1
- package/src/QueueDefinition.ts +4 -1
- package/src/R2.ts +7 -1
- package/src/Rpc.ts +4 -1
- package/src/RpcDefinition.ts +4 -1
- package/src/RpcTracing.ts +9 -1
- package/src/Sandbox.ts +7 -1
- package/src/ServiceBinding.ts +6 -1
- package/src/Vectorize.ts +7 -1
- package/src/Vitest.ts +5 -1
- package/src/WebTransport.ts +6 -1
- package/src/Worker.ts +10 -16
- package/src/WorkerDefinition.ts +3 -1
- package/src/WorkersAi.ts +7 -1
- package/src/Workflow.ts +10 -25
- package/src/WorkflowBinding.ts +6 -1
- package/src/WorkflowDefinition.ts +4 -1
- package/src/internal/Entrypoint.ts +3 -1
- package/src/internal/ErrorMessage.ts +1 -1
- package/src/internal/NativeCallback.ts +3 -1
- package/src/internal/RpcInvocation.ts +5 -1
- package/src/internal/Runtime.ts +5 -1
- package/src/internal/Telemetry.ts +4 -3
- package/src/internal/WorkerContext.ts +3 -1
- package/dist/Binding-DKcLrQCM.d.mts +0 -94
- package/dist/DurableObjectState-DJ0K-zyd.d.mts +0 -244
- package/dist/Worker-XsGJsCJX.mjs +0 -885
- package/dist/Worker-gV4mDqIs.d.mts +0 -641
package/dist/Cache.mjs
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { causeMessage } from "./internal/ErrorMessage.mjs";
|
|
3
|
+
import * as Context from "effect/Context";
|
|
4
|
+
import * as Data from "effect/Data";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Layer from "effect/Layer";
|
|
7
|
+
import * as Option from "effect/Option";
|
|
8
|
+
//#region src/Cache.ts
|
|
9
|
+
var Cache_exports = /* @__PURE__ */ __exportAll({
|
|
10
|
+
CacheOperationError: () => CacheOperationError,
|
|
11
|
+
CacheStorage: () => CacheStorage,
|
|
12
|
+
layer: () => layer,
|
|
13
|
+
layerFrom: () => layerFrom,
|
|
14
|
+
makeCacheClient: () => makeCacheClient,
|
|
15
|
+
makeClient: () => makeClient
|
|
16
|
+
});
|
|
17
|
+
var CacheOperationError = class extends Data.TaggedError("CacheOperationError") {
|
|
18
|
+
get message() {
|
|
19
|
+
return `Cache ${this.operation} failed for cache "${this.cache}": ${causeMessage(this.cause)}`;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var CacheStorage = class extends Context.Service()("effect-cf/CacheStorage") {};
|
|
23
|
+
const cacheError = (cache, operation, cause) => new CacheOperationError({
|
|
24
|
+
cache,
|
|
25
|
+
operation,
|
|
26
|
+
cause
|
|
27
|
+
});
|
|
28
|
+
const tryCachePromise = (cache, operation, evaluate) => Effect.tryPromise({
|
|
29
|
+
try: evaluate,
|
|
30
|
+
catch: (cause) => cacheError(cache, operation, cause)
|
|
31
|
+
});
|
|
32
|
+
const spanOptions = (cache, operation) => ({ attributes: {
|
|
33
|
+
cache,
|
|
34
|
+
operation
|
|
35
|
+
} });
|
|
36
|
+
const makeCacheClient = (cache, name = "default") => ({
|
|
37
|
+
name,
|
|
38
|
+
match: Effect.fn("Cache.match", spanOptions(name, "match"))((request, options) => tryCachePromise(name, "match", () => cache.match(request, options)).pipe(Effect.map(Option.fromUndefinedOr))),
|
|
39
|
+
put: Effect.fn("Cache.put", spanOptions(name, "put"))((request, response) => tryCachePromise(name, "put", () => cache.put(request, response))),
|
|
40
|
+
delete: Effect.fn("Cache.delete", spanOptions(name, "delete"))((request, options) => tryCachePromise(name, "delete", () => cache.delete(request, options))),
|
|
41
|
+
rawUnsafe: Effect.succeed(cache)
|
|
42
|
+
});
|
|
43
|
+
const makeClient = (storage) => ({
|
|
44
|
+
default: makeCacheClient(storage.default),
|
|
45
|
+
open: (name) => tryCachePromise(name, "open", () => storage.open(name)).pipe(Effect.map((cache) => makeCacheClient(cache, name)), Effect.withSpan("Cache.open", spanOptions(name, "open"))),
|
|
46
|
+
rawUnsafe: Effect.succeed(storage)
|
|
47
|
+
});
|
|
48
|
+
const layerFrom = (storage) => Layer.succeed(CacheStorage, makeClient(storage));
|
|
49
|
+
const layer = Layer.sync(CacheStorage, () => makeClient(caches));
|
|
50
|
+
//#endregion
|
|
51
|
+
export { CacheOperationError, CacheStorage, Cache_exports, layer, layerFrom, makeCacheClient, makeClient };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { DurableObjectState } from "./DurableObjectState.mjs";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import * as OtlpExporter from "effect/unstable/observability/OtlpExporter";
|
|
4
|
+
import * as OtlpResource from "effect/unstable/observability/OtlpResource";
|
|
5
|
+
import * as Tracer from "effect/Tracer";
|
|
6
|
+
import { Headers } from "effect/unstable/http";
|
|
7
|
+
declare namespace CloudflareOtlp_d_exports {
|
|
8
|
+
export { DurableObjectLayerOptions, LayerOptions, ResourceOptions, Serialization, Signal, WorkerLayerOptions, layer, layerDurableObject, layerJson, layerProtobuf, layerWorker };
|
|
9
|
+
}
|
|
10
|
+
type ResourceAttributes = NonNullable<Parameters<typeof OtlpResource.make>[0]["attributes"]>;
|
|
11
|
+
/** Telemetry signal groups supported by the Cloudflare OTLP layers. */
|
|
12
|
+
type Signal = "logs" | "traces" | "metrics";
|
|
13
|
+
/** OTLP payload serialization used by the Effect OTLP exporters. */
|
|
14
|
+
type Serialization = "json" | "protobuf";
|
|
15
|
+
/**
|
|
16
|
+
* Resource metadata shared by Worker and Durable Object OTLP layers.
|
|
17
|
+
*
|
|
18
|
+
* Precedence follows Effect's `OtlpResource.fromConfig`: explicit
|
|
19
|
+
* `serviceName`/`serviceVersion` win over matching explicit `attributes`, and
|
|
20
|
+
* explicit attributes win over `OTEL_SERVICE_NAME`, `OTEL_SERVICE_VERSION`, and
|
|
21
|
+
* `OTEL_RESOURCE_ATTRIBUTES`. Omit an option to let operators set it from the
|
|
22
|
+
* environment.
|
|
23
|
+
*/
|
|
24
|
+
interface ResourceOptions {
|
|
25
|
+
/** Explicit service name. Takes precedence over OTEL environment variables. */
|
|
26
|
+
readonly serviceName?: string;
|
|
27
|
+
/** Explicit service version. Takes precedence over OTEL environment variables. */
|
|
28
|
+
readonly serviceVersion?: string;
|
|
29
|
+
/** Additional resource attributes attached to exported telemetry. */
|
|
30
|
+
readonly attributes?: ResourceAttributes;
|
|
31
|
+
}
|
|
32
|
+
/** Options shared by all Cloudflare OTLP telemetry layers. */
|
|
33
|
+
interface LayerOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Telemetry signals to export. Defaults to logs, traces, and metrics.
|
|
36
|
+
*
|
|
37
|
+
* Each selected signal is still controlled by standard OTEL exporter config,
|
|
38
|
+
* such as `OTEL_TRACES_EXPORTER=otlp`.
|
|
39
|
+
*/
|
|
40
|
+
readonly signals?: ReadonlyArray<Signal>;
|
|
41
|
+
/** OTLP payload serialization. Defaults to protobuf. */
|
|
42
|
+
readonly serialization?: Serialization;
|
|
43
|
+
readonly resource?: ResourceOptions;
|
|
44
|
+
readonly headers?: Headers.Input;
|
|
45
|
+
readonly loggerExcludeLogSpans?: boolean;
|
|
46
|
+
readonly loggerMergeWithExisting?: boolean;
|
|
47
|
+
readonly tracerContext?: <X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X;
|
|
48
|
+
}
|
|
49
|
+
interface WorkerLayerOptions extends LayerOptions {
|
|
50
|
+
readonly workerName?: string;
|
|
51
|
+
}
|
|
52
|
+
interface DurableObjectLayerOptions extends LayerOptions {
|
|
53
|
+
readonly className?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Include the Durable Object id as `cloudflare.durable_object.id`.
|
|
56
|
+
*
|
|
57
|
+
* This is disabled by default because object ids can be high-cardinality.
|
|
58
|
+
*/
|
|
59
|
+
readonly includeObjectId?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Base OTLP telemetry layer for Cloudflare-compatible runtimes.
|
|
63
|
+
*
|
|
64
|
+
* Standard OpenTelemetry environment variables are resolved by Effect's OTLP
|
|
65
|
+
* layers. In Cloudflare Workers and Durable Objects, the current `env` object is
|
|
66
|
+
* installed as the primary `ConfigProvider`; outside Cloudflare, the ambient
|
|
67
|
+
* Effect `ConfigProvider` remains the fallback.
|
|
68
|
+
*
|
|
69
|
+
* The layer provides {@link OtlpExporter.Flusher} for draining buffered
|
|
70
|
+
* telemetry before the isolate freezes.
|
|
71
|
+
*/
|
|
72
|
+
declare const layer: (options?: LayerOptions) => Layer.Layer<OtlpExporter.Flusher>;
|
|
73
|
+
/** Base OTLP telemetry layer forced to JSON serialization. */
|
|
74
|
+
declare const layerJson: (options?: Omit<LayerOptions, "serialization">) => Layer.Layer<OtlpExporter.Flusher>;
|
|
75
|
+
/** Base OTLP telemetry layer forced to protobuf serialization. */
|
|
76
|
+
declare const layerProtobuf: (options?: Omit<LayerOptions, "serialization">) => Layer.Layer<OtlpExporter.Flusher>;
|
|
77
|
+
/**
|
|
78
|
+
* OTLP layer with Cloudflare Worker resource attributes.
|
|
79
|
+
*
|
|
80
|
+
* Provide this layer at runtime scope for long-lived metrics aggregation, or at
|
|
81
|
+
* handler scope when traces/logs should flush as the Cloudflare event finishes.
|
|
82
|
+
* A handler-scoped exporter can delay scope closure while its own finalizer
|
|
83
|
+
* flushes; the two-second background flush limit does not bound layer shutdown.
|
|
84
|
+
*/
|
|
85
|
+
declare const layerWorker: (options?: WorkerLayerOptions) => Layer.Layer<OtlpExporter.Flusher>;
|
|
86
|
+
/**
|
|
87
|
+
* OTLP layer with Cloudflare Durable Object resource attributes.
|
|
88
|
+
*
|
|
89
|
+
* The layer reads {@link DurableObjectState} so it can optionally include the
|
|
90
|
+
* Durable Object id. Prefer leaving `includeObjectId` disabled unless the
|
|
91
|
+
* backend can tolerate high-cardinality resource attributes.
|
|
92
|
+
*/
|
|
93
|
+
declare const layerDurableObject: (options?: DurableObjectLayerOptions) => Layer.Layer<OtlpExporter.Flusher, never, DurableObjectState>;
|
|
94
|
+
//#endregion
|
|
95
|
+
export { CloudflareOtlp_d_exports, DurableObjectLayerOptions, LayerOptions, ResourceOptions, Serialization, Signal, WorkerLayerOptions, layer, layerDurableObject, layerJson, layerProtobuf, layerWorker };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { WorkerConfig, WorkerEnvironment } from "./Environment.mjs";
|
|
3
|
+
import { DurableObjectState } from "./DurableObjectState.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as ConfigProvider from "effect/ConfigProvider";
|
|
7
|
+
import * as Option from "effect/Option";
|
|
8
|
+
import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
|
|
9
|
+
import * as OtlpExporter from "effect/unstable/observability/OtlpExporter";
|
|
10
|
+
import * as OtlpLogger from "effect/unstable/observability/OtlpLogger";
|
|
11
|
+
import * as OtlpMetrics from "effect/unstable/observability/OtlpMetrics";
|
|
12
|
+
import "effect/unstable/observability/OtlpResource";
|
|
13
|
+
import * as OtlpSerialization from "effect/unstable/observability/OtlpSerialization";
|
|
14
|
+
import * as OtlpTracer from "effect/unstable/observability/OtlpTracer";
|
|
15
|
+
//#region src/CloudflareOtlp.ts
|
|
16
|
+
/**
|
|
17
|
+
* Worker fetch/queue/RPC and Durable Object alarm/RPC handlers schedule a
|
|
18
|
+
* best-effort flusher. It settles within two seconds; other lifecycles must
|
|
19
|
+
* flush explicitly. Scheduled flush failures cannot fail user events. Exporter
|
|
20
|
+
* layer finalizers run separately and follow their configured shutdown timeout.
|
|
21
|
+
*/
|
|
22
|
+
var CloudflareOtlp_exports = /* @__PURE__ */ __exportAll({
|
|
23
|
+
layer: () => layer,
|
|
24
|
+
layerDurableObject: () => layerDurableObject,
|
|
25
|
+
layerJson: () => layerJson,
|
|
26
|
+
layerProtobuf: () => layerProtobuf,
|
|
27
|
+
layerWorker: () => layerWorker
|
|
28
|
+
});
|
|
29
|
+
const allSignals = [
|
|
30
|
+
"logs",
|
|
31
|
+
"traces",
|
|
32
|
+
"metrics"
|
|
33
|
+
];
|
|
34
|
+
const emptyConfigProvider = ConfigProvider.fromUnknown({});
|
|
35
|
+
const cloudflareConfigProviderLayer = ConfigProvider.layerAdd(Effect.map(Effect.serviceOption(WorkerEnvironment), (env) => Option.isSome(env) ? WorkerConfig.providerFromEnv(env.value) : emptyConfigProvider), { asPrimary: true });
|
|
36
|
+
const selectedSignals = (signals) => new Set(signals ?? allSignals);
|
|
37
|
+
const withDefinedAttributes = (attributes) => {
|
|
38
|
+
const out = {};
|
|
39
|
+
for (const [key, value] of Object.entries(attributes)) if (value !== void 0) out[key] = value;
|
|
40
|
+
return out;
|
|
41
|
+
};
|
|
42
|
+
const makeResource = (options, runtimeAttributes) => ({
|
|
43
|
+
serviceName: options.resource?.serviceName,
|
|
44
|
+
serviceVersion: options.resource?.serviceVersion,
|
|
45
|
+
attributes: {
|
|
46
|
+
...withDefinedAttributes(runtimeAttributes),
|
|
47
|
+
...options.resource?.attributes
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const serializationLayer = (serialization) => serialization === "json" ? OtlpSerialization.layerJson : OtlpSerialization.layerProtobuf;
|
|
51
|
+
const mergeSignalLayers = (layers) => {
|
|
52
|
+
let merged = layers[0];
|
|
53
|
+
for (let index = 1; index < layers.length; index++) merged = Layer.mergeAll(merged, layers[index]);
|
|
54
|
+
return merged;
|
|
55
|
+
};
|
|
56
|
+
const makeLayer = (options = {}, runtimeAttributes = {}) => {
|
|
57
|
+
const signals = selectedSignals(options.signals);
|
|
58
|
+
const resource = makeResource(options, runtimeAttributes);
|
|
59
|
+
const layers = [];
|
|
60
|
+
if (signals.has("logs")) layers.push(OtlpLogger.layerFromConfig({
|
|
61
|
+
resource,
|
|
62
|
+
headers: options.headers,
|
|
63
|
+
excludeLogSpans: options.loggerExcludeLogSpans,
|
|
64
|
+
mergeWithExisting: options.loggerMergeWithExisting
|
|
65
|
+
}));
|
|
66
|
+
if (signals.has("traces")) layers.push(OtlpTracer.layerFromConfig({
|
|
67
|
+
resource,
|
|
68
|
+
headers: options.headers,
|
|
69
|
+
context: options.tracerContext
|
|
70
|
+
}));
|
|
71
|
+
if (signals.has("metrics")) layers.push(OtlpMetrics.layerFromConfig({
|
|
72
|
+
resource,
|
|
73
|
+
headers: options.headers
|
|
74
|
+
}));
|
|
75
|
+
if (layers.length === 0) return OtlpExporter.layerFlusher;
|
|
76
|
+
return mergeSignalLayers(layers).pipe(Layer.provide(cloudflareConfigProviderLayer), Layer.provide(serializationLayer(options.serialization)), Layer.provide(FetchHttpClient.layer));
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Base OTLP telemetry layer for Cloudflare-compatible runtimes.
|
|
80
|
+
*
|
|
81
|
+
* Standard OpenTelemetry environment variables are resolved by Effect's OTLP
|
|
82
|
+
* layers. In Cloudflare Workers and Durable Objects, the current `env` object is
|
|
83
|
+
* installed as the primary `ConfigProvider`; outside Cloudflare, the ambient
|
|
84
|
+
* Effect `ConfigProvider` remains the fallback.
|
|
85
|
+
*
|
|
86
|
+
* The layer provides {@link OtlpExporter.Flusher} for draining buffered
|
|
87
|
+
* telemetry before the isolate freezes.
|
|
88
|
+
*/
|
|
89
|
+
const layer = (options = {}) => makeLayer(options);
|
|
90
|
+
/** Base OTLP telemetry layer forced to JSON serialization. */
|
|
91
|
+
const layerJson = (options = {}) => layer({
|
|
92
|
+
...options,
|
|
93
|
+
serialization: "json"
|
|
94
|
+
});
|
|
95
|
+
/** Base OTLP telemetry layer forced to protobuf serialization. */
|
|
96
|
+
const layerProtobuf = (options = {}) => layer({
|
|
97
|
+
...options,
|
|
98
|
+
serialization: "protobuf"
|
|
99
|
+
});
|
|
100
|
+
/**
|
|
101
|
+
* OTLP layer with Cloudflare Worker resource attributes.
|
|
102
|
+
*
|
|
103
|
+
* Provide this layer at runtime scope for long-lived metrics aggregation, or at
|
|
104
|
+
* handler scope when traces/logs should flush as the Cloudflare event finishes.
|
|
105
|
+
* A handler-scoped exporter can delay scope closure while its own finalizer
|
|
106
|
+
* flushes; the two-second background flush limit does not bound layer shutdown.
|
|
107
|
+
*/
|
|
108
|
+
const layerWorker = (options = {}) => makeLayer(options, {
|
|
109
|
+
"cloudflare.resource_type": "worker",
|
|
110
|
+
"cloudflare.worker.name": options.workerName
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* OTLP layer with Cloudflare Durable Object resource attributes.
|
|
114
|
+
*
|
|
115
|
+
* The layer reads {@link DurableObjectState} so it can optionally include the
|
|
116
|
+
* Durable Object id. Prefer leaving `includeObjectId` disabled unless the
|
|
117
|
+
* backend can tolerate high-cardinality resource attributes.
|
|
118
|
+
*/
|
|
119
|
+
const layerDurableObject = (options = {}) => Layer.unwrap(Effect.map(DurableObjectState, (state) => makeLayer(options, {
|
|
120
|
+
"cloudflare.resource_type": "durable_object",
|
|
121
|
+
"cloudflare.durable_object.class": options.className,
|
|
122
|
+
"cloudflare.durable_object.id": options.includeObjectId ? state.id.toString() : void 0
|
|
123
|
+
})));
|
|
124
|
+
//#endregion
|
|
125
|
+
export { CloudflareOtlp_exports, layer, layerDurableObject, layerJson, layerProtobuf, layerWorker };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as Layer from "effect/Layer";
|
|
2
|
+
declare namespace CloudflareTracer_d_exports {
|
|
3
|
+
export { layer };
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Sends Effect spans to Cloudflare Workers Observability using the runtime's
|
|
7
|
+
* custom span API. Build this layer inside each invocation, for example with
|
|
8
|
+
* `Worker.make(Services, { eventLayer: CloudflareTracer.layer, fetch })`.
|
|
9
|
+
* It captures the invocation's async context and must not be cached across requests.
|
|
10
|
+
*
|
|
11
|
+
* Enable `observability.traces.enabled` in Wrangler. Cloudflare owns sampling
|
|
12
|
+
* and export; no OTLP exporter or flush is required. Scalar attributes are
|
|
13
|
+
* forwarded; other attributes, events, and links remain Effect-local. Completion
|
|
14
|
+
* is recorded as `effect.exit`, since Cloudflare has no outcome-setting API.
|
|
15
|
+
* Effect trace/span IDs remain independent of Cloudflare's opaque IDs. External
|
|
16
|
+
* parents and `root: true` cannot override the invocation's Cloudflare trace.
|
|
17
|
+
*/
|
|
18
|
+
declare const layer: Layer.Layer<never>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { CloudflareTracer_d_exports, layer };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Predicate from "effect/Predicate";
|
|
5
|
+
import * as Option from "effect/Option";
|
|
6
|
+
import * as Cause from "effect/Cause";
|
|
7
|
+
import * as Exit from "effect/Exit";
|
|
8
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
|
+
import { tracing } from "cloudflare:workers";
|
|
10
|
+
import * as Tracer from "effect/Tracer";
|
|
11
|
+
//#region src/CloudflareTracer.ts
|
|
12
|
+
var CloudflareTracer_exports = /* @__PURE__ */ __exportAll({ layer: () => layer });
|
|
13
|
+
var Span = class extends Tracer.NativeSpan {
|
|
14
|
+
runInContext;
|
|
15
|
+
cloudflareSpan;
|
|
16
|
+
constructor(options, runInContext, cloudflareSpan) {
|
|
17
|
+
super({
|
|
18
|
+
...options,
|
|
19
|
+
sampled: options.sampled && (cloudflareSpan?.isTraced ?? false)
|
|
20
|
+
});
|
|
21
|
+
this.runInContext = runInContext;
|
|
22
|
+
this.cloudflareSpan = cloudflareSpan;
|
|
23
|
+
}
|
|
24
|
+
attribute(key, value) {
|
|
25
|
+
super.attribute(key, value);
|
|
26
|
+
if (Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) this.cloudflareSpan?.setAttribute(key, value);
|
|
27
|
+
}
|
|
28
|
+
end(endTime, exit) {
|
|
29
|
+
if (this.status._tag === "Ended") return;
|
|
30
|
+
super.end(endTime, exit);
|
|
31
|
+
this.cloudflareSpan?.setAttribute("effect.exit", Exit.isSuccess(exit) ? "success" : Cause.hasInterruptsOnly(exit.cause) ? "interrupted" : "failure");
|
|
32
|
+
this.cloudflareSpan?.end();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Sends Effect spans to Cloudflare Workers Observability using the runtime's
|
|
37
|
+
* custom span API. Build this layer inside each invocation, for example with
|
|
38
|
+
* `Worker.make(Services, { eventLayer: CloudflareTracer.layer, fetch })`.
|
|
39
|
+
* It captures the invocation's async context and must not be cached across requests.
|
|
40
|
+
*
|
|
41
|
+
* Enable `observability.traces.enabled` in Wrangler. Cloudflare owns sampling
|
|
42
|
+
* and export; no OTLP exporter or flush is required. Scalar attributes are
|
|
43
|
+
* forwarded; other attributes, events, and links remain Effect-local. Completion
|
|
44
|
+
* is recorded as `effect.exit`, since Cloudflare has no outcome-setting API.
|
|
45
|
+
* Effect trace/span IDs remain independent of Cloudflare's opaque IDs. External
|
|
46
|
+
* parents and `root: true` cannot override the invocation's Cloudflare trace.
|
|
47
|
+
*/
|
|
48
|
+
const layer = Layer.effect(Tracer.Tracer, Effect.sync(() => {
|
|
49
|
+
const invocationContext = AsyncLocalStorage.snapshot();
|
|
50
|
+
const contextFor = (span) => {
|
|
51
|
+
while (span?._tag === "Span") {
|
|
52
|
+
if (span instanceof Span) return span.runInContext;
|
|
53
|
+
span = Option.getOrUndefined(span.parent);
|
|
54
|
+
}
|
|
55
|
+
return invocationContext;
|
|
56
|
+
};
|
|
57
|
+
return Tracer.make({
|
|
58
|
+
span(options) {
|
|
59
|
+
const parentContext = options.root ? invocationContext : contextFor(Option.getOrUndefined(options.parent));
|
|
60
|
+
if (!options.sampled) return new Span(options, parentContext);
|
|
61
|
+
return parentContext(() => tracing.startActiveSpan(options.name, (span) => new Span(options, AsyncLocalStorage.snapshot(), span)));
|
|
62
|
+
},
|
|
63
|
+
context(primitive, fiber) {
|
|
64
|
+
return contextFor(fiber.currentSpan)(() => primitive["~effect/Effect/evaluate"](fiber));
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}));
|
|
68
|
+
//#endregion
|
|
69
|
+
export { CloudflareTracer_exports, layer };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { ArtifactsBinding, ArtifactsCreateOptions, ArtifactsCreateRepoResult, ArtifactsCreateTokenResult, ArtifactsOperationError, ArtifactsRepoInfo, ArtifactsTokenInfo, ArtifactsTokenListResult, RepoName } from "./Artifacts.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
3
|
import { ArtifactClient, ArtifactImportOptions, ArtifactImportSource, ArtifactRepoSummary, ArtifactScope, ArtifactsCLIInput, ArtifactsCLIResult, RemoteAddFn } from "@cloudflare/computer/artifacts";
|
|
4
4
|
//#region src/ComputerArtifacts.d.ts
|
|
5
5
|
/** External Git source accepted by a session-scoped repository import. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { ArtifactsOperationError } from "./Artifacts.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Predicate from "effect/Predicate";
|
|
3
4
|
//#region src/ComputerArtifacts.ts
|
|
4
5
|
const artifactsErrorDetails = (cause) => {
|
|
5
6
|
if (!Predicate.isObject(cause)) return {};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { ComputerArtifactsClient } from "./ComputerArtifacts.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { DurableObjectState } from "./DurableObjectState.mjs";
|
|
3
|
+
import * as Context$1 from "effect/Context";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Schema$1 from "effect/Schema";
|
|
6
|
+
import * as Layer$1 from "effect/Layer";
|
|
7
|
+
import * as Stream from "effect/Stream";
|
|
4
8
|
import { CommitView, GitClient, GitCloneOptions, GitCommitOptions, GitDiffOptions, GitFetchOptions, GitLogOptions, GitUpdateRefOptions } from "@cloudflare/computer/git";
|
|
5
9
|
import { ExecSyncResult, RuntimeExecOptions, RuntimeGetOptions, RuntimeKillOptions, ShellValue, SkippedEntry, ThinkWorkspaceCompatibility, WorkspaceClient, WorkspaceRuntimeResult, WorkspaceRuntimeValue as WorkspaceRuntimeValue$1 } from "@cloudflare/computer";
|
|
10
|
+
import { Scope } from "effect";
|
|
6
11
|
import { ShareOptions } from "@cloudflare/computer/assets";
|
|
7
12
|
//#region src/ComputerWorkspace.d.ts
|
|
8
13
|
type CloudflareWorkspaceFilesystem = WorkspaceClient["fs"];
|
|
@@ -18,12 +23,12 @@ type CloudflareWorkspaceDirentResult = Awaited<ReturnType<CloudflareWorkspaceFil
|
|
|
18
23
|
type CloudflareWorkspaceStatResult = Awaited<ReturnType<CloudflareWorkspaceFilesystem["stat"]>>;
|
|
19
24
|
type CloudflareWorkspaceFoundEntry = Awaited<ReturnType<CloudflareWorkspaceFilesystem["find"]>>[number];
|
|
20
25
|
type CloudflareWorkspaceGrepMatch = Awaited<ReturnType<CloudflareWorkspaceFilesystem["grep"]>>[number];
|
|
21
|
-
declare const WorkspaceFsError_base: Schema.Class<WorkspaceFsError, Schema.TaggedStruct<"WorkspaceFsError", {
|
|
22
|
-
readonly operation: Schema.String;
|
|
23
|
-
readonly path: Schema.String;
|
|
24
|
-
readonly message: Schema.String;
|
|
25
|
-
readonly code: Schema.optionalKey<Schema.String>;
|
|
26
|
-
readonly cause: Schema.optionalKey<Schema.Defect>;
|
|
26
|
+
declare const WorkspaceFsError_base: Schema$1.Class<WorkspaceFsError, Schema$1.TaggedStruct<"WorkspaceFsError", {
|
|
27
|
+
readonly operation: Schema$1.String;
|
|
28
|
+
readonly path: Schema$1.String;
|
|
29
|
+
readonly message: Schema$1.String;
|
|
30
|
+
readonly code: Schema$1.optionalKey<Schema$1.String>;
|
|
31
|
+
readonly cause: Schema$1.optionalKey<Schema$1.Defect>;
|
|
27
32
|
}>, import("effect/Cause").YieldableError>;
|
|
28
33
|
/**
|
|
29
34
|
* Workspace errors use `Schema.TaggedError`, unlike most local binding errors,
|
|
@@ -31,36 +36,36 @@ declare const WorkspaceFsError_base: Schema.Class<WorkspaceFsError, Schema.Tagge
|
|
|
31
36
|
* The schema form preserves the operation-family tags across that boundary.
|
|
32
37
|
*/
|
|
33
38
|
declare class WorkspaceFsError extends WorkspaceFsError_base {}
|
|
34
|
-
declare const WorkspaceGitError_base: Schema.Class<WorkspaceGitError, Schema.TaggedStruct<"WorkspaceGitError", {
|
|
35
|
-
readonly operation: Schema.String;
|
|
36
|
-
readonly message: Schema.String;
|
|
37
|
-
readonly code: Schema.optionalKey<Schema.String>;
|
|
38
|
-
readonly cause: Schema.optionalKey<Schema.Defect>;
|
|
39
|
+
declare const WorkspaceGitError_base: Schema$1.Class<WorkspaceGitError, Schema$1.TaggedStruct<"WorkspaceGitError", {
|
|
40
|
+
readonly operation: Schema$1.String;
|
|
41
|
+
readonly message: Schema$1.String;
|
|
42
|
+
readonly code: Schema$1.optionalKey<Schema$1.String>;
|
|
43
|
+
readonly cause: Schema$1.optionalKey<Schema$1.Defect>;
|
|
39
44
|
}>, import("effect/Cause").YieldableError>;
|
|
40
45
|
/** Schema-serializable error for a workspace Git operation. */
|
|
41
46
|
declare class WorkspaceGitError extends WorkspaceGitError_base {}
|
|
42
|
-
declare const WorkspaceExecError_base: Schema.Class<WorkspaceExecError, Schema.TaggedStruct<"WorkspaceExecError", {
|
|
43
|
-
readonly operation: Schema.String;
|
|
44
|
-
readonly message: Schema.String;
|
|
45
|
-
readonly code: Schema.optionalKey<Schema.String>;
|
|
46
|
-
readonly cause: Schema.optionalKey<Schema.Defect>;
|
|
47
|
+
declare const WorkspaceExecError_base: Schema$1.Class<WorkspaceExecError, Schema$1.TaggedStruct<"WorkspaceExecError", {
|
|
48
|
+
readonly operation: Schema$1.String;
|
|
49
|
+
readonly message: Schema$1.String;
|
|
50
|
+
readonly code: Schema$1.optionalKey<Schema$1.String>;
|
|
51
|
+
readonly cause: Schema$1.optionalKey<Schema$1.Defect>;
|
|
47
52
|
}>, import("effect/Cause").YieldableError>;
|
|
48
53
|
/** Schema-serializable error for a workspace runtime operation. */
|
|
49
54
|
declare class WorkspaceExecError extends WorkspaceExecError_base {}
|
|
50
|
-
declare const WorkspaceAssetsError_base: Schema.Class<WorkspaceAssetsError, Schema.TaggedStruct<"WorkspaceAssetsError", {
|
|
51
|
-
readonly operation: Schema.String;
|
|
52
|
-
readonly path: Schema.String;
|
|
53
|
-
readonly message: Schema.String;
|
|
54
|
-
readonly code: Schema.optionalKey<Schema.String>;
|
|
55
|
-
readonly cause: Schema.optionalKey<Schema.Defect>;
|
|
55
|
+
declare const WorkspaceAssetsError_base: Schema$1.Class<WorkspaceAssetsError, Schema$1.TaggedStruct<"WorkspaceAssetsError", {
|
|
56
|
+
readonly operation: Schema$1.String;
|
|
57
|
+
readonly path: Schema$1.String;
|
|
58
|
+
readonly message: Schema$1.String;
|
|
59
|
+
readonly code: Schema$1.optionalKey<Schema$1.String>;
|
|
60
|
+
readonly cause: Schema$1.optionalKey<Schema$1.Defect>;
|
|
56
61
|
}>, import("effect/Cause").YieldableError>;
|
|
57
62
|
/** Schema-serializable error for a workspace Assets operation. */
|
|
58
63
|
declare class WorkspaceAssetsError extends WorkspaceAssetsError_base {}
|
|
59
|
-
declare const WorkspaceAcquireError_base: Schema.Class<WorkspaceAcquireError, Schema.TaggedStruct<"WorkspaceAcquireError", {
|
|
60
|
-
readonly operation: Schema.String;
|
|
61
|
-
readonly message: Schema.String;
|
|
62
|
-
readonly code: Schema.optionalKey<Schema.String>;
|
|
63
|
-
readonly cause: Schema.optionalKey<Schema.Defect>;
|
|
64
|
+
declare const WorkspaceAcquireError_base: Schema$1.Class<WorkspaceAcquireError, Schema$1.TaggedStruct<"WorkspaceAcquireError", {
|
|
65
|
+
readonly operation: Schema$1.String;
|
|
66
|
+
readonly message: Schema$1.String;
|
|
67
|
+
readonly code: Schema$1.optionalKey<Schema$1.String>;
|
|
68
|
+
readonly cause: Schema$1.optionalKey<Schema$1.Defect>;
|
|
64
69
|
}>, import("effect/Cause").YieldableError>;
|
|
65
70
|
/** Schema-serializable error while acquiring the Computer workspace client. */
|
|
66
71
|
declare class WorkspaceAcquireError extends WorkspaceAcquireError_base {}
|
|
@@ -266,13 +271,13 @@ interface ComputerWorkspaceService {
|
|
|
266
271
|
* every runtime handle are disposed by Effect `Scope`.
|
|
267
272
|
*/
|
|
268
273
|
declare const fromWorkspaceClient: (client: WorkspaceClient) => ComputerWorkspaceService;
|
|
269
|
-
declare const ComputerWorkspace_base: Context.ServiceClass<ComputerWorkspace, "effect-cf/ComputerWorkspace", ComputerWorkspaceService>;
|
|
274
|
+
declare const ComputerWorkspace_base: Context$1.ServiceClass<ComputerWorkspace, "effect-cf/ComputerWorkspace", ComputerWorkspaceService>;
|
|
270
275
|
declare class ComputerWorkspace extends ComputerWorkspace_base {
|
|
271
276
|
/**
|
|
272
277
|
* Acquires the single workspace registered by `withComputerWorkspace` and
|
|
273
278
|
* releases its RPC client when the layer scope closes.
|
|
274
279
|
*/
|
|
275
|
-
static readonly layer: Layer.Layer<ComputerWorkspace, WorkspaceAcquireError, DurableObjectState>;
|
|
280
|
+
static readonly layer: Layer$1.Layer<ComputerWorkspace, WorkspaceAcquireError, DurableObjectState>;
|
|
276
281
|
}
|
|
277
282
|
//#endregion
|
|
278
283
|
export { ComputerWorkspace, ComputerWorkspaceAssets, ComputerWorkspaceFilesystem, ComputerWorkspaceGit, ComputerWorkspaceRuntime, ComputerWorkspaceService, type ComputerWorkspaceService as ComputerWorkspaceShape, ComputerWorkspaceThink, ListDirectoryOptions, ReadTextFileOptions, RemovePathOptions, WorkspaceAcquireError, WorkspaceAssetsError, WorkspaceDirectoryEntry, WorkspaceEntryStat, WorkspaceExec, WorkspaceExecChunk, WorkspaceExecCollect, WorkspaceExecEncoding, WorkspaceExecError, WorkspaceExecEvent, WorkspaceExecOptions, WorkspaceExecResult, WorkspaceExecRun, WorkspaceExecSignal, WorkspaceExecSkippedEntry, WorkspaceExecSyncResult, WorkspaceFindOptions, WorkspaceFoundEntry, WorkspaceFsError, WorkspaceGetExec, WorkspaceGetExecOptions, WorkspaceGitCheckoutOptions, WorkspaceGitCloneOptions, WorkspaceGitCommit, WorkspaceGitCommitOptions, WorkspaceGitDiffOptions, WorkspaceGitError, WorkspaceGitFetchOptions, WorkspaceGitFetchResult, WorkspaceGitLogOptions, WorkspaceGitPerson, WorkspaceGitUpdateRefOptions, WorkspaceGrepMatch, WorkspaceGrepOptions, WorkspaceMkdirOptions, WorkspaceReadEncoding, WorkspaceReadFile, WorkspaceReadFileOptions, WorkspaceRuntimeValue, WorkspaceWriteFileContent, WorkspaceWriteFileOptions, fromWorkspaceClient };
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DurableObjectState } from "./DurableObjectState.mjs";
|
|
2
2
|
import { fromClient } from "./ComputerArtifacts.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { lookup } from "./internal/ComputerWorkspaceHostRegistry.mjs";
|
|
4
|
+
import * as Context from "effect/Context";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
import * as Layer from "effect/Layer";
|
|
8
|
+
import * as Predicate from "effect/Predicate";
|
|
9
|
+
import * as Stream from "effect/Stream";
|
|
5
10
|
//#region src/ComputerWorkspace.ts
|
|
6
11
|
/**
|
|
7
12
|
* Workspace errors use `Schema.TaggedError`, unlike most local binding errors,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArtifactsBinding } from "./Artifacts.mjs";
|
|
2
2
|
import { GitClientFactory } from "@cloudflare/computer/git";
|
|
3
3
|
import { DurableObjectStorageLike, SyncRetryIntent, SyncRetryOptions, SyncRetryScheduler, WithWorkspaceCtor, WorkspaceAttributeValue, WorkspaceAttributes, WorkspaceObserver, WorkspaceOptions, WorkspaceRegisteredBackend, WorkspaceRetryPendingSyncResult, WorkspaceServiceProxy, WorkspaceSpan } from "@cloudflare/computer";
|
|
4
4
|
import { ShellModuleGroup, WorkerShellBackendOptions, WorkerShellLoader, WorkspaceEgressPolicy } from "@cloudflare/computer/backends/worker-shell";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { register } from "./internal/ComputerWorkspaceHostRegistry.mjs";
|
|
2
2
|
import { createGitClient } from "@cloudflare/computer/git";
|
|
3
3
|
import { WorkspaceServiceProxy, withWorkspace } from "@cloudflare/computer";
|
|
4
4
|
import { WorkerShellBackend } from "@cloudflare/computer/backends/worker-shell";
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { WorkerEnvironment } from "./Environment.mjs";
|
|
2
|
+
import { BindingNotFoundError, BindingValidationError } from "./Binding.mjs";
|
|
3
|
+
import * as Context$1 from "effect/Context";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as S from "effect/Schema";
|
|
6
|
+
import { Layer } from "effect";
|
|
3
7
|
declare namespace ContainerNamespace_d_exports {
|
|
4
8
|
export { ContainerInstanceClient, ContainerNamespace, ContainerNamespaceClient, ContainerNamespaceDefinition, ContainerNamespaceResource, ContainerNamespaceService, ContainerNamespaceStaticClient, ContainerOperationError, ContainerReadinessOptions, ContainerSignal, ContainerStartAndWaitForPortsOptions, ContainerStartOptions, ContainerState, ContainerStopSignal, ContainerStub, ContainerStubOf, ContainerWaitOptions, LayerOptions, Tag, TagClass, isContainerNamespaceResource, layer, make, makeClient };
|
|
5
9
|
}
|
|
@@ -29,13 +33,13 @@ interface ContainerStartAndWaitForPortsOptions {
|
|
|
29
33
|
readonly cancellationOptions?: ContainerReadinessOptions;
|
|
30
34
|
}
|
|
31
35
|
/** Serializable state reported by a Cloudflare Container instance. */
|
|
32
|
-
declare const ContainerState:
|
|
33
|
-
readonly lastChange:
|
|
34
|
-
readonly status:
|
|
35
|
-
}>,
|
|
36
|
-
readonly lastChange:
|
|
37
|
-
readonly status:
|
|
38
|
-
readonly exitCode:
|
|
36
|
+
declare const ContainerState: S.Union<readonly [S.Struct<{
|
|
37
|
+
readonly lastChange: S.Finite;
|
|
38
|
+
readonly status: S.Literals<readonly ["running", "stopping", "stopped", "healthy"]>;
|
|
39
|
+
}>, S.Struct<{
|
|
40
|
+
readonly lastChange: S.Finite;
|
|
41
|
+
readonly status: S.Literal<"stopped_with_code">;
|
|
42
|
+
readonly exitCode: S.optionalKey<S.Int>;
|
|
39
43
|
}>]>;
|
|
40
44
|
type ContainerState = typeof ContainerState.Type;
|
|
41
45
|
/**
|
|
@@ -122,13 +126,13 @@ type ContainerNamespaceStaticClient<R, Namespace extends ContainerNamespaceResou
|
|
|
122
126
|
type LayerOptions = {
|
|
123
127
|
readonly binding: string;
|
|
124
128
|
};
|
|
125
|
-
interface TagClass<Self, Id extends string, Namespace extends ContainerNamespaceResource = ContainerNamespaceResource> extends Context.ServiceClass<Self, `effect-cf/Container/${Id}`, ContainerNamespaceClient<Namespace>>, ContainerNamespaceStaticClient<Self, Namespace> {
|
|
129
|
+
interface TagClass<Self, Id extends string, Namespace extends ContainerNamespaceResource = ContainerNamespaceResource> extends Context$1.ServiceClass<Self, `effect-cf/Container/${Id}`, ContainerNamespaceClient<Namespace>>, ContainerNamespaceStaticClient<Self, Namespace> {
|
|
126
130
|
readonly id: Id;
|
|
127
131
|
readonly layer: (options: LayerOptions) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
128
132
|
}
|
|
129
133
|
declare const isContainerNamespaceResource: <Candidate>(value: Candidate) => value is Candidate & ContainerNamespaceResource;
|
|
130
134
|
declare const makeClient: (definition: ContainerNamespaceDefinition) => <Namespace extends ContainerNamespaceResource>(namespace: Namespace) => ContainerNamespaceClient<Namespace>;
|
|
131
|
-
declare const layer: <Self, Namespace extends ContainerNamespaceResource>(tag: Context.Service<Self, ContainerNamespaceClient<Namespace>>, definition: ContainerNamespaceDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
135
|
+
declare const layer: <Self, Namespace extends ContainerNamespaceResource>(tag: Context$1.Service<Self, ContainerNamespaceClient<Namespace>>, definition: ContainerNamespaceDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
132
136
|
declare const make: <Id extends string>(id: Id) => TagClass<ContainerNamespaceService<Id>, Id, ContainerNamespaceResource>;
|
|
133
137
|
declare const ContainerNamespaceServiceTypeId: unique symbol;
|
|
134
138
|
interface ContainerNamespaceService<Id extends string> {
|
|
@@ -139,4 +143,4 @@ interface ContainerNamespaceService<Id extends string> {
|
|
|
139
143
|
declare const Tag: <Self, Namespace extends ContainerNamespaceResource = ContainerNamespaceResource>() => <Id extends string>(id: Id) => TagClass<Self, Id, Namespace>;
|
|
140
144
|
declare const ContainerNamespace: typeof Tag;
|
|
141
145
|
//#endregion
|
|
142
|
-
export {
|
|
146
|
+
export { ContainerInstanceClient, ContainerNamespace, ContainerNamespaceClient, ContainerNamespaceDefinition, ContainerNamespaceResource, ContainerNamespaceService, ContainerNamespaceStaticClient, ContainerNamespace_d_exports, ContainerOperationError, ContainerReadinessOptions, ContainerSignal, ContainerStartAndWaitForPortsOptions, ContainerStartOptions, ContainerState, ContainerStopSignal, ContainerStub, ContainerStubOf, ContainerWaitOptions, LayerOptions, Tag, TagClass, isContainerNamespaceResource, layer, make, makeClient };
|