effect-cf 0.33.0 → 0.35.0
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 +22 -0
- package/README.md +31 -1079
- package/dist/{Artifacts-DnHQA-Ax.d.mts → Artifacts-B3r3RuTB.d.mts} +1 -48
- package/dist/{Artifacts-CSIk1Oml.mjs → Artifacts-CBxWGeZB.mjs} +2 -7
- package/dist/{Binding-pfilNJmP.mjs → Binding-C82jRhdr.mjs} +1 -2
- package/dist/{Binding-xJJJPmiD.d.mts → Binding-DKcLrQCM.d.mts} +0 -45
- package/dist/ComputerArtifacts.d.mts +1 -3
- package/dist/ComputerArtifacts.mjs +1 -2
- package/dist/ComputerWorkspace.d.mts +11 -12
- package/dist/ComputerWorkspace.mjs +31 -10
- package/dist/ComputerWorkspaceHost.d.mts +1 -9
- package/dist/{ContainerNamespace-CFjiLw8b.d.mts → ContainerNamespace-DbLaeFhN.d.mts} +1 -14
- package/dist/{DurableObjectState-CVLLse69.mjs → DurableObjectState-DcqElJ4e.mjs} +82 -89
- package/dist/{DurableObjectState-BpRjz6-q.d.mts → DurableObjectState-DpYdNZgT.d.mts} +102 -266
- package/dist/{ErrorMessage-BM0K-Nik.mjs → ErrorMessage-Byx2OgNd.mjs} +0 -1
- package/dist/{Hyperdrive-z-9fFz15.d.mts → Hyperdrive-HrwFlZ6x.d.mts} +1 -4
- package/dist/HyperdrivePg.d.mts +2 -11
- package/dist/HyperdrivePg.mjs +0 -8
- package/dist/Sandbox.d.mts +2 -32
- package/dist/Sandbox.mjs +2 -11
- package/dist/Vitest.d.mts +3 -31
- package/dist/Vitest.mjs +8 -26
- package/dist/{WorkflowBinding-lBR4_-op.d.mts → WorkflowBinding-Cn3AuUyP.d.mts} +2 -5
- package/dist/index.d.mts +42 -480
- package/dist/index.mjs +267 -380
- package/package.json +1 -1
- package/src/AiGateway.ts +0 -6
- package/src/AnalyticsEngine.ts +8 -10
- package/src/Artifacts.ts +0 -47
- package/src/Binding.ts +0 -8
- package/src/BrowserRendering.ts +0 -4
- package/src/Cache.ts +0 -19
- package/src/CloudflareOtlp.ts +6 -39
- package/src/ComputerArtifacts.ts +0 -2
- package/src/ComputerWorkspace.ts +53 -35
- package/src/ComputerWorkspaceHost.ts +0 -8
- package/src/ContainerNamespace.ts +0 -13
- package/src/D1.ts +0 -22
- package/src/DurableObject.ts +51 -32
- package/src/DurableObjectAlarm.ts +6 -210
- package/src/DurableObjectDefinition.ts +8 -20
- package/src/DurableObjectNamespace.ts +88 -115
- package/src/DurableObjectRpcWebSocket.ts +5 -46
- package/src/DurableObjectSqlite.ts +0 -12
- package/src/DurableObjectState.ts +18 -38
- package/src/DurableObjectStorage.ts +55 -70
- package/src/DurableObjectWebSocket.ts +23 -72
- package/src/Email.ts +0 -12
- package/src/Environment.ts +0 -37
- package/src/Hyperdrive.ts +0 -3
- package/src/HyperdrivePg.ts +0 -9
- package/src/Images.ts +0 -5
- package/src/Kv.ts +0 -15
- package/src/QueueBinding.ts +0 -2
- package/src/R2.ts +0 -5
- package/src/RpcDefinition.ts +5 -17
- package/src/RpcTracing.ts +133 -0
- package/src/Sandbox.ts +0 -30
- package/src/ServiceBinding.ts +83 -128
- package/src/Vectorize.ts +0 -5
- package/src/Vitest.ts +18 -43
- package/src/WebTransport.ts +0 -15
- package/src/Worker.ts +140 -108
- package/src/WorkerDefinition.ts +5 -14
- package/src/WorkersAi.ts +21 -18
- package/src/Workflow.ts +45 -54
- package/src/WorkflowBinding.ts +0 -3
- package/src/index.ts +1 -0
- package/src/internal/Entrypoint.ts +23 -4
- package/src/internal/ErrorMessage.ts +0 -1
- package/src/internal/NativeCallback.ts +55 -0
- package/src/internal/RpcInvocation.ts +18 -1
- package/src/internal/Runtime.ts +12 -7
- package/src/internal/WorkerContext.ts +5 -14
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { c as WorkerEnvironment, r as BindingValidationError, t as BindingNotFoundError } from "./Binding-
|
|
1
|
+
import { c as WorkerEnvironment, r as BindingValidationError, t as BindingNotFoundError } from "./Binding-DKcLrQCM.mjs";
|
|
2
2
|
import { Context, Effect, Layer } from "effect";
|
|
3
3
|
declare namespace Artifacts_d_exports {
|
|
4
4
|
export { ArtifactsBinding, ArtifactsClient, ArtifactsCommit, ArtifactsCommitIdentity, ArtifactsCreateOptions, ArtifactsCreateRepoResult, ArtifactsCreateTokenResult, ArtifactsDefinition, ArtifactsErrorCode, ArtifactsForkOptions, ArtifactsImportParams, ArtifactsImportSource, ArtifactsImportTarget, ArtifactsImportTargetOptions, ArtifactsListOptions, ArtifactsLogOptions, ArtifactsLogResult, ArtifactsOperation, ArtifactsOperationError, ArtifactsRepoBinding, ArtifactsRepoClient, ArtifactsRepoInfo, ArtifactsRepoListEntry, ArtifactsRepoListResult, ArtifactsRepoStatus, ArtifactsService, ArtifactsTokenInfo, ArtifactsTokenListResult, ArtifactsTokenScope, ArtifactsTokenState, ArtifactsTree, Cursor, LayerOptions, RepoName, Tag, TagClass, artifactsErrorCodes, artifactsErrorNumericCodes, isArtifactsBinding, isArtifactsRepoBinding, layer, make, makeClient };
|
|
5
5
|
}
|
|
6
|
-
/** Artifacts operation represented by {@link ArtifactsOperationError}. */
|
|
7
6
|
type ArtifactsOperation = "createClient" | "create" | "get" | "import" | "list" | "delete" | "createToken" | "listTokens" | "getToken" | "revokeToken" | "fork" | "info" | "log" | "readCommit" | "readTree" | "cli";
|
|
8
|
-
/** Documented string error codes returned by Cloudflare Artifacts. */
|
|
9
7
|
declare const artifactsErrorCodes: readonly ["ALREADY_EXISTS", "NOT_FOUND", "IMPORT_IN_PROGRESS", "FORK_IN_PROGRESS", "INVALID_INPUT", "INVALID_REPO_NAME", "INVALID_TTL", "INVALID_URL", "REMOTE_AUTH_REQUIRED", "UPSTREAM_UNAVAILABLE", "MEMORY_LIMIT", "INTERNAL_ERROR"];
|
|
10
|
-
/** Documented numeric error codes returned by Cloudflare Artifacts. */
|
|
11
8
|
declare const artifactsErrorNumericCodes: {
|
|
12
9
|
readonly ALREADY_EXISTS: 10201;
|
|
13
10
|
readonly NOT_FOUND: 10200;
|
|
@@ -22,47 +19,34 @@ declare const artifactsErrorNumericCodes: {
|
|
|
22
19
|
readonly MEMORY_LIMIT: 10402;
|
|
23
20
|
readonly INTERNAL_ERROR: 10400;
|
|
24
21
|
};
|
|
25
|
-
/** A documented Cloudflare Artifacts string error code. */
|
|
26
22
|
type ArtifactsErrorCode = CloudflareArtifactsErrorCode;
|
|
27
23
|
declare const ArtifactsOperationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
28
24
|
readonly _tag: "ArtifactsOperationError";
|
|
29
25
|
} & Readonly<A>;
|
|
30
|
-
/** Error raised when a Cloudflare Artifacts operation fails. */
|
|
31
26
|
declare class ArtifactsOperationError extends ArtifactsOperationError_base<{
|
|
32
27
|
readonly binding: string;
|
|
33
28
|
readonly operation: ArtifactsOperation;
|
|
34
29
|
readonly cause: unknown;
|
|
35
|
-
/** Cloudflare string error code, when retained by the runtime. */
|
|
36
30
|
readonly code?: ArtifactsErrorCode | (string & {});
|
|
37
|
-
/** Cloudflare REST-compatible numeric error code, when retained by the runtime. */
|
|
38
31
|
readonly numericCode?: number;
|
|
39
32
|
}> {
|
|
40
33
|
get message(): string;
|
|
41
34
|
}
|
|
42
|
-
/** Typed Cloudflare Artifacts binding definition. */
|
|
43
35
|
interface ArtifactsDefinition {
|
|
44
|
-
/** Binding name from an `artifacts` entry in `wrangler.jsonc`. */
|
|
45
36
|
readonly binding: string;
|
|
46
37
|
}
|
|
47
|
-
/** Repository name containing alphanumeric characters, dots, hyphens, or underscores. */
|
|
48
38
|
type RepoName = string;
|
|
49
|
-
/** Cursor used by repository list pagination. */
|
|
50
39
|
type Cursor = string;
|
|
51
40
|
/** Scope granted to a repository token. */
|
|
52
41
|
type ArtifactsTokenScope = "read" | "write";
|
|
53
42
|
/** Lifecycle state of a repository token. */
|
|
54
43
|
type ArtifactsTokenState = "active" | "expired" | "revoked";
|
|
55
|
-
/** Lifecycle state included with repositories returned by `list()`. */
|
|
56
44
|
type ArtifactsRepoStatus = "ready" | "importing" | "forking";
|
|
57
|
-
/** Stable repository metadata returned by Cloudflare Artifacts. */
|
|
58
45
|
type ArtifactsRepoInfo = CloudflareArtifactsRepoInfo;
|
|
59
|
-
/** Result of creating, importing, or forking a repository. */
|
|
60
46
|
type ArtifactsCreateRepoResult = Readonly<CloudflareArtifactsCreateRepoResult>;
|
|
61
|
-
/** Repository metadata returned by `list()`. */
|
|
62
47
|
interface ArtifactsRepoListEntry extends ArtifactsRepoInfo {
|
|
63
48
|
readonly status: ArtifactsRepoStatus;
|
|
64
49
|
}
|
|
65
|
-
/** Cursor-paginated repository list result. */
|
|
66
50
|
interface ArtifactsRepoListResult {
|
|
67
51
|
readonly repos: ReadonlyArray<ArtifactsRepoListEntry>;
|
|
68
52
|
readonly total: number;
|
|
@@ -87,12 +71,9 @@ interface ArtifactsCommit {
|
|
|
87
71
|
readonly author: ArtifactsCommitIdentity;
|
|
88
72
|
readonly committer: ArtifactsCommitIdentity;
|
|
89
73
|
readonly parents: ReadonlyArray<string>;
|
|
90
|
-
/** Unix timestamp in seconds. */
|
|
91
74
|
readonly authoredAt: number;
|
|
92
|
-
/** Unix timestamp in seconds. */
|
|
93
75
|
readonly committedAt: number;
|
|
94
76
|
}
|
|
95
|
-
/** Bare commit array returned by `log()`. */
|
|
96
77
|
type ArtifactsLogResult = ReadonlyArray<ArtifactsCommit>;
|
|
97
78
|
/**
|
|
98
79
|
* Parsed Git tree returned by `readTree()`.
|
|
@@ -103,60 +84,44 @@ type ArtifactsLogResult = ReadonlyArray<ArtifactsCommit>;
|
|
|
103
84
|
interface ArtifactsTree<Field = unknown> {
|
|
104
85
|
readonly [field: string]: Field;
|
|
105
86
|
}
|
|
106
|
-
/** Options for `Artifacts.create()`. */
|
|
107
87
|
interface ArtifactsCreateOptions {
|
|
108
|
-
/** Prevent pushes to the repository. */
|
|
109
88
|
readonly readOnly?: boolean;
|
|
110
89
|
readonly description?: string;
|
|
111
|
-
/** Initial default branch name. */
|
|
112
90
|
readonly setDefaultBranch?: string;
|
|
113
91
|
}
|
|
114
|
-
/** Options for cursor-paginating `Artifacts.list()`. */
|
|
115
92
|
interface ArtifactsListOptions {
|
|
116
|
-
/** Page size from 1 through 200. Defaults to 50. */
|
|
117
93
|
readonly limit?: number;
|
|
118
|
-
/** Cursor returned by a previous list result. */
|
|
119
94
|
readonly cursor?: Cursor;
|
|
120
95
|
}
|
|
121
96
|
/** External Git source used by `Artifacts.import()`. */
|
|
122
97
|
interface ArtifactsImportSource {
|
|
123
98
|
/** Full HTTPS URL of the Git repository. */
|
|
124
99
|
readonly url: string;
|
|
125
|
-
/** Source branch. Defaults to the remote's default branch. */
|
|
126
100
|
readonly branch?: string;
|
|
127
|
-
/** Shallow clone depth. */
|
|
128
101
|
readonly depth?: number;
|
|
129
102
|
}
|
|
130
|
-
/** Options for the target of `Artifacts.import()`. */
|
|
131
103
|
interface ArtifactsImportTargetOptions {
|
|
132
104
|
readonly description?: string;
|
|
133
105
|
readonly readOnly?: boolean;
|
|
134
106
|
}
|
|
135
|
-
/** Target repository used by `Artifacts.import()`. */
|
|
136
107
|
interface ArtifactsImportTarget {
|
|
137
108
|
readonly name: RepoName;
|
|
138
109
|
readonly opts?: ArtifactsImportTargetOptions;
|
|
139
110
|
}
|
|
140
|
-
/** Parameters for `Artifacts.import()`. */
|
|
141
111
|
interface ArtifactsImportParams {
|
|
142
112
|
readonly source: ArtifactsImportSource;
|
|
143
113
|
readonly target: ArtifactsImportTarget;
|
|
144
114
|
}
|
|
145
|
-
/** Options for `ArtifactsRepoClient.fork()`. */
|
|
146
115
|
interface ArtifactsForkOptions {
|
|
147
116
|
readonly description?: string;
|
|
148
117
|
readonly readOnly?: boolean;
|
|
149
|
-
/** Only copy the default branch. Defaults to `true`. */
|
|
150
118
|
readonly defaultBranchOnly?: boolean;
|
|
151
119
|
}
|
|
152
|
-
/** Options for `ArtifactsRepoClient.log()`. */
|
|
153
120
|
interface ArtifactsLogOptions {
|
|
154
|
-
/** Branch, tag, or commit hash. */
|
|
155
121
|
readonly ref?: string;
|
|
156
122
|
readonly limit?: number;
|
|
157
123
|
readonly offset?: number;
|
|
158
124
|
}
|
|
159
|
-
/** Runtime repository handle, including methods absent from current shipped Workers types. */
|
|
160
125
|
interface ArtifactsRepoBinding extends Partial<ArtifactsRepoInfo> {
|
|
161
126
|
/**
|
|
162
127
|
* Read repository metadata.
|
|
@@ -180,7 +145,6 @@ interface ArtifactsRepoBinding extends Partial<ArtifactsRepoInfo> {
|
|
|
180
145
|
readonly readCommit: (hash: string) => Promise<ArtifactsCommit>;
|
|
181
146
|
readonly readTree: (hash: string) => Promise<ArtifactsTree>;
|
|
182
147
|
}
|
|
183
|
-
/** Cloudflare Artifacts namespace binding. */
|
|
184
148
|
interface ArtifactsBinding {
|
|
185
149
|
readonly create: (name: RepoName, options?: ArtifactsCreateOptions) => Promise<ArtifactsCreateRepoResult>;
|
|
186
150
|
readonly get: (name: RepoName) => Promise<ArtifactsRepoBinding>;
|
|
@@ -188,14 +152,7 @@ interface ArtifactsBinding {
|
|
|
188
152
|
readonly list: (options?: ArtifactsListOptions) => Promise<ArtifactsRepoListResult>;
|
|
189
153
|
readonly delete: (name: RepoName) => Promise<boolean>;
|
|
190
154
|
}
|
|
191
|
-
/**
|
|
192
|
-
* Effect wrapper around a repository handle returned by `Artifacts.get()`.
|
|
193
|
-
*
|
|
194
|
-
* The inherited metadata is the snapshot read while resolving the client.
|
|
195
|
-
* Use `info()` to refresh it from the repository handle.
|
|
196
|
-
*/
|
|
197
155
|
interface ArtifactsRepoClient extends ArtifactsRepoInfo {
|
|
198
|
-
/** Read and validate the repository's current metadata. */
|
|
199
156
|
readonly info: () => Effect.Effect<ArtifactsRepoInfo, ArtifactsOperationError>;
|
|
200
157
|
/**
|
|
201
158
|
* Create a Git token for the repository.
|
|
@@ -212,7 +169,6 @@ interface ArtifactsRepoClient extends ArtifactsRepoInfo {
|
|
|
212
169
|
readonly readTree: (hash: string) => Effect.Effect<ArtifactsTree, ArtifactsOperationError>;
|
|
213
170
|
readonly raw: ArtifactsRepoBinding;
|
|
214
171
|
}
|
|
215
|
-
/** Effect wrapper around a Cloudflare Artifacts namespace binding. */
|
|
216
172
|
interface ArtifactsClient {
|
|
217
173
|
readonly create: (name: RepoName, options?: ArtifactsCreateOptions) => Effect.Effect<ArtifactsCreateRepoResult, ArtifactsOperationError>;
|
|
218
174
|
readonly get: (name: RepoName) => Effect.Effect<ArtifactsRepoClient, ArtifactsOperationError>;
|
|
@@ -223,7 +179,6 @@ interface ArtifactsClient {
|
|
|
223
179
|
readonly definition: ArtifactsDefinition;
|
|
224
180
|
}
|
|
225
181
|
declare const ArtifactsServiceTypeId: unique symbol;
|
|
226
|
-
/** Nominal service marker for Artifacts services created with {@link make}. */
|
|
227
182
|
interface ArtifactsService<Id extends string> {
|
|
228
183
|
readonly [ArtifactsServiceTypeId]: {
|
|
229
184
|
readonly id: Id;
|
|
@@ -236,9 +191,7 @@ interface TagClass<Self, Id extends string> extends Context.ServiceClass<Self, I
|
|
|
236
191
|
readonly id: Id;
|
|
237
192
|
readonly layer: (options: LayerOptions) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
238
193
|
}
|
|
239
|
-
/** Tests whether a value exposes the complete documented Artifacts repo handle API. */
|
|
240
194
|
declare const isArtifactsRepoBinding: <Candidate>(value: Candidate) => value is Candidate & ArtifactsRepoBinding;
|
|
241
|
-
/** Tests whether a value exposes the complete documented Artifacts namespace API. */
|
|
242
195
|
declare const isArtifactsBinding: <Candidate>(value: Candidate) => value is Candidate & ArtifactsBinding;
|
|
243
196
|
declare const makeClient: (definition: ArtifactsDefinition) => (artifacts: ArtifactsBinding) => ArtifactsClient;
|
|
244
197
|
declare const layer: <Self>(tag: Context.Service<Self, ArtifactsClient>, definition: ArtifactsDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { t as causeMessage } from "./ErrorMessage-
|
|
3
|
-
import { r as layer$1 } from "./Binding-
|
|
2
|
+
import { t as causeMessage } from "./ErrorMessage-Byx2OgNd.mjs";
|
|
3
|
+
import { r as layer$1 } from "./Binding-C82jRhdr.mjs";
|
|
4
4
|
import { Context, Data, Effect, Predicate, Schema } from "effect";
|
|
5
5
|
//#region src/Artifacts.ts
|
|
6
6
|
var Artifacts_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -16,7 +16,6 @@ var Artifacts_exports = /* @__PURE__ */ __exportAll({
|
|
|
16
16
|
});
|
|
17
17
|
const expectedArtifactsBinding = "Artifacts binding with create(), get(), import(), list(), and delete()";
|
|
18
18
|
const expectedArtifactsRepo = "Artifacts repo handle with createToken(), listTokens(), revokeToken(), fork(), log(), readCommit(), and readTree()";
|
|
19
|
-
/** Documented string error codes returned by Cloudflare Artifacts. */
|
|
20
19
|
const artifactsErrorCodes = [
|
|
21
20
|
"ALREADY_EXISTS",
|
|
22
21
|
"NOT_FOUND",
|
|
@@ -31,7 +30,6 @@ const artifactsErrorCodes = [
|
|
|
31
30
|
"MEMORY_LIMIT",
|
|
32
31
|
"INTERNAL_ERROR"
|
|
33
32
|
];
|
|
34
|
-
/** Documented numeric error codes returned by Cloudflare Artifacts. */
|
|
35
33
|
const artifactsErrorNumericCodes = {
|
|
36
34
|
ALREADY_EXISTS: 10201,
|
|
37
35
|
NOT_FOUND: 10200,
|
|
@@ -46,7 +44,6 @@ const artifactsErrorNumericCodes = {
|
|
|
46
44
|
MEMORY_LIMIT: 10402,
|
|
47
45
|
INTERNAL_ERROR: 10400
|
|
48
46
|
};
|
|
49
|
-
/** Error raised when a Cloudflare Artifacts operation fails. */
|
|
50
47
|
var ArtifactsOperationError = class extends Data.TaggedError("ArtifactsOperationError") {
|
|
51
48
|
get message() {
|
|
52
49
|
const code = this.code === void 0 ? "" : ` (${this.code})`;
|
|
@@ -94,9 +91,7 @@ const readRepoInfo = (binding, repo) => {
|
|
|
94
91
|
if (hasFunction(repo, "info")) return tryArtifactsPromise(binding, "info", () => repo.info()).pipe(Effect.flatMap((info) => decodeRepoInfo(binding, info)), Effect.withSpan("Artifacts.info", spanOptions(binding, "info")));
|
|
95
92
|
return decodeRepoInfo(binding, repo).pipe(Effect.withSpan("Artifacts.info", spanOptions(binding, "info")));
|
|
96
93
|
};
|
|
97
|
-
/** Tests whether a value exposes the complete documented Artifacts repo handle API. */
|
|
98
94
|
const isArtifactsRepoBinding = (value) => hasFunction(value, "createToken") && hasFunction(value, "listTokens") && hasFunction(value, "revokeToken") && hasFunction(value, "fork") && hasFunction(value, "log") && hasFunction(value, "readCommit") && hasFunction(value, "readTree");
|
|
99
|
-
/** Tests whether a value exposes the complete documented Artifacts namespace API. */
|
|
100
95
|
const isArtifactsBinding = (value) => hasFunction(value, "create") && hasFunction(value, "get") && hasFunction(value, "import") && hasFunction(value, "list") && hasFunction(value, "delete");
|
|
101
96
|
const wrapRepo = (binding, repo, info) => ({
|
|
102
97
|
...info,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { a as WorkerEnvironment } from "./ErrorMessage-
|
|
2
|
+
import { a as WorkerEnvironment } from "./ErrorMessage-Byx2OgNd.mjs";
|
|
3
3
|
import { Context, Data, Effect, Layer, Predicate } from "effect";
|
|
4
4
|
//#region src/Binding.ts
|
|
5
5
|
var Binding_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -9,7 +9,6 @@ var Binding_exports = /* @__PURE__ */ __exportAll({
|
|
|
9
9
|
TypeId: () => TypeId,
|
|
10
10
|
layer: () => layer
|
|
11
11
|
});
|
|
12
|
-
/** Internal type id marker used by binding helper services. */
|
|
13
12
|
const TypeId = "~effect-cf/Binding";
|
|
14
13
|
/** Error raised when a configured binding does not exist on `env`. */
|
|
15
14
|
var BindingNotFoundError = class extends Data.TaggedError("BindingNotFoundError") {};
|
|
@@ -2,7 +2,6 @@ import { Config, ConfigProvider, Context, Effect, Layer, Predicate } from "effec
|
|
|
2
2
|
declare namespace Environment_d_exports {
|
|
3
3
|
export { WorkerConfig, WorkerEnv, WorkerEnvironment };
|
|
4
4
|
}
|
|
5
|
-
/** Cloudflare worker environment object (`env`). */
|
|
6
5
|
type WorkerEnv = Cloudflare.Env;
|
|
7
6
|
declare const WorkerEnvironment_base: Context.ServiceClass<WorkerEnvironment, "effect-cf/WorkerEnvironment", Cloudflare.Env>;
|
|
8
7
|
/**
|
|
@@ -11,37 +10,8 @@ declare const WorkerEnvironment_base: Context.ServiceClass<WorkerEnvironment, "e
|
|
|
11
10
|
declare class WorkerEnvironment extends WorkerEnvironment_base {}
|
|
12
11
|
type ScalarConfigValue = string | number | boolean;
|
|
13
12
|
type ScalarConfigKey = Extract<{ readonly [Key in keyof Cloudflare.Env]-?: NonNullable<Cloudflare.Env[Key]> extends ScalarConfigValue ? Key : never; }[keyof Cloudflare.Env], string>;
|
|
14
|
-
/**
|
|
15
|
-
* Effect `Config` helpers for scalar Cloudflare vars and secrets declared on
|
|
16
|
-
* `Cloudflare.Env`.
|
|
17
|
-
*
|
|
18
|
-
* Users still author their app config explicitly with Effect `Config`:
|
|
19
|
-
*
|
|
20
|
-
* ```ts
|
|
21
|
-
* import { Config, Effect } from "effect";
|
|
22
|
-
* import { WorkerConfig } from "effect-cf";
|
|
23
|
-
*
|
|
24
|
-
* const AppConfig = Config.all({
|
|
25
|
-
* databaseUrl: WorkerConfig.redacted("DATABASE_URL"),
|
|
26
|
-
* port: WorkerConfig.integer("PORT").pipe(Config.withDefault(8787)),
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* const program = Effect.gen(function* () {
|
|
30
|
-
* const config = yield* AppConfig;
|
|
31
|
-
* // ...
|
|
32
|
-
* }).pipe(Effect.provide(WorkerConfig.providerLayer));
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* Keys are constrained to scalar `Cloudflare.Env` properties (`string`,
|
|
36
|
-
* `number`, or `boolean`, including optional scalar properties). Binding
|
|
37
|
-
* objects such as `KVNamespace`, `DurableObjectNamespace`, and service
|
|
38
|
-
* bindings are intentionally excluded; keep using the package binding helpers
|
|
39
|
-
* for those live resources.
|
|
40
|
-
*/
|
|
41
13
|
declare namespace WorkerConfig {
|
|
42
|
-
/** Scalar env value types supported by the typed config key helpers. */
|
|
43
14
|
type Scalar = ScalarConfigValue;
|
|
44
|
-
/** Scalar keys available on the current consumer's `Cloudflare.Env`. */
|
|
45
15
|
type Key = ScalarConfigKey;
|
|
46
16
|
/** Read a scalar Cloudflare var or secret as a string. */
|
|
47
17
|
const string: <const Name extends Key>(name: Name) => Config.Config<string>;
|
|
@@ -53,7 +23,6 @@ declare namespace WorkerConfig {
|
|
|
53
23
|
const integer: <const Name extends Key>(name: Name) => Config.Config<number>;
|
|
54
24
|
/** Read a scalar Cloudflare var or secret as a boolean. */
|
|
55
25
|
const boolean: <const Name extends Key>(name: Name) => Config.Config<boolean>;
|
|
56
|
-
/** Options for building a `ConfigProvider` from a Cloudflare worker `env` object. */
|
|
57
26
|
interface ProviderOptions {
|
|
58
27
|
/**
|
|
59
28
|
* Keep empty-string env values as explicit `""` config values.
|
|
@@ -73,27 +42,19 @@ declare namespace WorkerConfig {
|
|
|
73
42
|
* `{ preserveEmptyStrings: true }` to keep them as explicit values.
|
|
74
43
|
*/
|
|
75
44
|
const providerFromEnv: (env: WorkerEnv, options?: ProviderOptions) => ConfigProvider.ConfigProvider;
|
|
76
|
-
/**
|
|
77
|
-
* Build a `ConfigProvider` from the current `WorkerEnvironment` with a custom
|
|
78
|
-
* conversion function.
|
|
79
|
-
*/
|
|
80
45
|
const providerWith: (makeProvider: (env: WorkerEnv) => ConfigProvider.ConfigProvider) => Effect.Effect<ConfigProvider.ConfigProvider, never, WorkerEnvironment>;
|
|
81
|
-
/** Build a `ConfigProvider` from the current `WorkerEnvironment`. */
|
|
82
46
|
const provider: Effect.Effect<ConfigProvider.ConfigProvider, never, WorkerEnvironment>;
|
|
83
47
|
/**
|
|
84
48
|
* Replace the active Effect `ConfigProvider` with one backed by the current
|
|
85
49
|
* Cloudflare worker `env` object.
|
|
86
50
|
*/
|
|
87
51
|
const providerLayer: Layer.Layer<never, never, WorkerEnvironment>;
|
|
88
|
-
/** Build a `ConfigProvider` layer with a custom `env` conversion function. */
|
|
89
52
|
const layerWith: (makeProvider: (env: WorkerEnv) => ConfigProvider.ConfigProvider) => Layer.Layer<never, never, WorkerEnvironment>;
|
|
90
53
|
}
|
|
91
54
|
declare namespace Binding_d_exports {
|
|
92
55
|
export { BindingNotFoundError, BindingService, BindingValidationError, Service, TypeId, ValidationOptions, layer };
|
|
93
56
|
}
|
|
94
|
-
/** Internal type id marker used by binding helper services. */
|
|
95
57
|
declare const TypeId: "~effect-cf/Binding";
|
|
96
|
-
/** Internal type id marker used by binding helper services. */
|
|
97
58
|
type TypeId = typeof TypeId;
|
|
98
59
|
declare const BindingNotFoundError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
99
60
|
readonly _tag: "BindingNotFoundError";
|
|
@@ -117,12 +78,6 @@ interface ValidationOptions {
|
|
|
117
78
|
readonly expected?: string;
|
|
118
79
|
}
|
|
119
80
|
type BindingCandidate = Parameters<typeof Predicate.isUnknown>[0];
|
|
120
|
-
/**
|
|
121
|
-
* Creates a Context tag + layer for reading and validating a Cloudflare binding.
|
|
122
|
-
*
|
|
123
|
-
* The Context key is namespaced as `effect-cf/Binding/<id>`; `id` stays the
|
|
124
|
-
* bare user-supplied identifier.
|
|
125
|
-
*/
|
|
126
81
|
interface BindingService<Self, Id extends string, Service> extends Context.ServiceClass<Self, `effect-cf/Binding/${Id}`, Service> {
|
|
127
82
|
readonly [TypeId]: TypeId;
|
|
128
83
|
readonly id: Id;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ArtifactsOperationError, c as ArtifactsTokenListResult, i as ArtifactsCreateTokenResult, n as ArtifactsCreateOptions, o as ArtifactsRepoInfo, r as ArtifactsCreateRepoResult, s as ArtifactsTokenInfo, t as ArtifactsBinding, u as RepoName } from "./Artifacts-
|
|
1
|
+
import { a as ArtifactsOperationError, c as ArtifactsTokenListResult, i as ArtifactsCreateTokenResult, n as ArtifactsCreateOptions, o as ArtifactsRepoInfo, r as ArtifactsCreateRepoResult, s as ArtifactsTokenInfo, t as ArtifactsBinding, u as RepoName } from "./Artifacts-B3r3RuTB.mjs";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
import { ArtifactClient, ArtifactImportOptions, ArtifactImportSource, ArtifactRepoSummary, ArtifactScope, ArtifactsCLIInput, ArtifactsCLIResult, RemoteAddFn } from "@cloudflare/computer/artifacts";
|
|
4
4
|
//#region src/ComputerArtifacts.d.ts
|
|
@@ -18,7 +18,6 @@ type ComputerArtifactsCliInput = ArtifactsCLIInput;
|
|
|
18
18
|
type ComputerArtifactsCliResult = Readonly<ArtifactsCLIResult>;
|
|
19
19
|
/** Options used when wrapping a session-scoped Artifacts client. */
|
|
20
20
|
interface ComputerArtifactsClientOptions {
|
|
21
|
-
/** Binding name attached to errors and tracing spans. Defaults to `ARTIFACTS`. */
|
|
22
21
|
readonly binding?: string;
|
|
23
22
|
}
|
|
24
23
|
/**
|
|
@@ -43,7 +42,6 @@ interface ComputerArtifactsClient {
|
|
|
43
42
|
readonly cli: (input: ComputerArtifactsCliInput) => Effect.Effect<ComputerArtifactsCliResult, ArtifactsOperationError>;
|
|
44
43
|
readonly rawUnsafe: Effect.Effect<ArtifactClient>;
|
|
45
44
|
}
|
|
46
|
-
/** Wraps an already-created upstream session client. */
|
|
47
45
|
declare const fromClient: (client: ArtifactClient, options?: ComputerArtifactsClientOptions) => ComputerArtifactsClient;
|
|
48
46
|
/**
|
|
49
47
|
* Creates an Effect-native session client directly from a Worker Artifacts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ArtifactsOperationError } from "./Artifacts-
|
|
1
|
+
import { t as ArtifactsOperationError } from "./Artifacts-CBxWGeZB.mjs";
|
|
2
2
|
import { Effect, Predicate } from "effect";
|
|
3
3
|
//#region src/ComputerArtifacts.ts
|
|
4
4
|
const artifactsErrorDetails = (cause) => {
|
|
@@ -25,7 +25,6 @@ const spanOptions = (binding, sessionId, operation) => ({ attributes: {
|
|
|
25
25
|
sessionId,
|
|
26
26
|
operation
|
|
27
27
|
} });
|
|
28
|
-
/** Wraps an already-created upstream session client. */
|
|
29
28
|
const fromClient = (client, options = {}) => {
|
|
30
29
|
const binding = options.binding ?? "ARTIFACTS";
|
|
31
30
|
const { sessionId } = client;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComputerArtifactsClient } from "./ComputerArtifacts.mjs";
|
|
2
|
-
import { t as DurableObjectState } from "./DurableObjectState-
|
|
2
|
+
import { t as DurableObjectState } from "./DurableObjectState-DpYdNZgT.mjs";
|
|
3
3
|
import { Context, Effect, Layer, Schema, Scope, Stream } from "effect";
|
|
4
4
|
import { CommitView, GitClient, GitCloneOptions, GitCommitOptions, GitDiffOptions, GitFetchOptions, GitLogOptions, GitUpdateRefOptions } from "@cloudflare/computer/git";
|
|
5
5
|
import { ExecSyncResult, RuntimeExecOptions, RuntimeGetOptions, RuntimeKillOptions, ShellValue, SkippedEntry, ThinkWorkspaceCompatibility, WorkspaceClient, WorkspaceRuntimeResult, WorkspaceRuntimeValue as WorkspaceRuntimeValue$1 } from "@cloudflare/computer";
|
|
@@ -56,6 +56,14 @@ declare const WorkspaceAssetsError_base: Schema.Class<WorkspaceAssetsError, Sche
|
|
|
56
56
|
}>, import("effect/Cause").YieldableError>;
|
|
57
57
|
/** Schema-serializable error for a workspace Assets operation. */
|
|
58
58
|
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
|
+
}>, import("effect/Cause").YieldableError>;
|
|
65
|
+
/** Schema-serializable error while acquiring the Computer workspace client. */
|
|
66
|
+
declare class WorkspaceAcquireError extends WorkspaceAcquireError_base {}
|
|
59
67
|
type WorkspaceReadFileOptions = Omit<CloudflareReadFileOptions, "encoding">;
|
|
60
68
|
type ReadTextFileOptions = WorkspaceReadFileOptions;
|
|
61
69
|
type ListDirectoryOptions = CloudflareReaddirOptions;
|
|
@@ -79,7 +87,6 @@ interface WorkspaceReadFile {
|
|
|
79
87
|
readonly encoding: "stream";
|
|
80
88
|
}): Effect.Effect<ReadableStream<Uint8Array>, WorkspaceFsError>;
|
|
81
89
|
}
|
|
82
|
-
/** Complete Effect wrapper of `WorkspaceClient.fs`. */
|
|
83
90
|
interface ComputerWorkspaceFilesystem {
|
|
84
91
|
readonly readFile: WorkspaceReadFile;
|
|
85
92
|
readonly stat: (path: string) => Effect.Effect<WorkspaceEntryStat, WorkspaceFsError>;
|
|
@@ -104,7 +111,6 @@ type WorkspaceGitUpdateRefOptions = GitUpdateRefOptions;
|
|
|
104
111
|
type WorkspaceGitDiffOptions = GitDiffOptions;
|
|
105
112
|
type WorkspaceGitCommitOptions = GitCommitOptions;
|
|
106
113
|
interface WorkspaceGitLogOptions extends Omit<GitLogOptions, "depth"> {
|
|
107
|
-
/** Preferred upstream name for the history bound. */
|
|
108
114
|
readonly depth?: number;
|
|
109
115
|
/** Consumer-port compatibility alias for `depth`. */
|
|
110
116
|
readonly maxCount?: number;
|
|
@@ -142,7 +148,6 @@ type CloudflareEncoding<Encoding extends WorkspaceExecEncoding> = Encoding exten
|
|
|
142
148
|
type WorkspaceExecChunk<Encoding extends WorkspaceExecEncoding> = Encoding extends "utf8" ? string : Uint8Array;
|
|
143
149
|
type WorkspaceExecOptions<Encoding extends WorkspaceExecEncoding = "utf8"> = Omit<RuntimeExecOptions, "encoding" | "timeoutMs"> & {
|
|
144
150
|
readonly encoding?: Encoding;
|
|
145
|
-
/** Upstream runtime option name. */
|
|
146
151
|
readonly timeoutMs?: number;
|
|
147
152
|
/** Consumer-port compatibility alias for `timeoutMs`. */
|
|
148
153
|
readonly timeoutMillis?: number;
|
|
@@ -211,7 +216,6 @@ interface WorkspaceExecCollect {
|
|
|
211
216
|
(command: string, options?: WorkspaceExecOptions<"utf8">): Effect.Effect<WorkspaceExecResult<"utf8">, WorkspaceExecError>;
|
|
212
217
|
(command: string, options: WorkspaceExecOptions<"binary">): Effect.Effect<WorkspaceExecResult<"binary">, WorkspaceExecError>;
|
|
213
218
|
}
|
|
214
|
-
/** Complete Effect wrapper of `WorkspaceClient.runtime`. */
|
|
215
219
|
interface ComputerWorkspaceRuntime {
|
|
216
220
|
readonly exec: WorkspaceExec;
|
|
217
221
|
readonly execCollect: WorkspaceExecCollect;
|
|
@@ -221,14 +225,12 @@ interface ComputerWorkspaceRuntime {
|
|
|
221
225
|
readonly backend?: string;
|
|
222
226
|
}) => Effect.Effect<void, WorkspaceExecError>;
|
|
223
227
|
}
|
|
224
|
-
/** Effect wrapper over a configured local `Workspace.assets` client. */
|
|
225
228
|
interface ComputerWorkspaceAssets {
|
|
226
229
|
readonly share: (path: string, options: ShareOptions) => Effect.Effect<string, WorkspaceAssetsError>;
|
|
227
230
|
}
|
|
228
231
|
type EffectThinkMethod<Method> = Method extends ((...args: infer Args) => Promise<infer Success>) ? (...args: Args) => Effect.Effect<Success, WorkspaceFsError> : never;
|
|
229
232
|
/** Effect wrapper of the optional Think compatibility surface. */
|
|
230
233
|
type ComputerWorkspaceThink = { readonly [Name in keyof ThinkWorkspaceCompatibility]: EffectThinkMethod<ThinkWorkspaceCompatibility[Name]>; };
|
|
231
|
-
/** Effect service over every client surface exposed by Cloudflare Computer. */
|
|
232
234
|
interface ComputerWorkspaceService {
|
|
233
235
|
readonly fs: ComputerWorkspaceFilesystem;
|
|
234
236
|
readonly git: ComputerWorkspaceGit;
|
|
@@ -236,7 +238,6 @@ interface ComputerWorkspaceService {
|
|
|
236
238
|
readonly artifacts: ComputerArtifactsClient;
|
|
237
239
|
readonly assets: ComputerWorkspaceAssets | undefined;
|
|
238
240
|
readonly think: ComputerWorkspaceThink | undefined;
|
|
239
|
-
/** Flat filesystem aliases retained for mechanical consumer migration. */
|
|
240
241
|
readonly readFile: WorkspaceReadFile;
|
|
241
242
|
readonly stat: ComputerWorkspaceFilesystem["stat"];
|
|
242
243
|
readonly lstat: ComputerWorkspaceFilesystem["lstat"];
|
|
@@ -253,7 +254,6 @@ interface ComputerWorkspaceService {
|
|
|
253
254
|
readonly removePath: ComputerWorkspaceFilesystem["rm"];
|
|
254
255
|
readonly chmod: ComputerWorkspaceFilesystem["chmod"];
|
|
255
256
|
readonly symlink: ComputerWorkspaceFilesystem["symlink"];
|
|
256
|
-
/** Flat runtime aliases retained for mechanical consumer migration. */
|
|
257
257
|
readonly exec: WorkspaceExec;
|
|
258
258
|
readonly execCollect: WorkspaceExecCollect;
|
|
259
259
|
readonly getExec: WorkspaceGetExec;
|
|
@@ -267,13 +267,12 @@ interface ComputerWorkspaceService {
|
|
|
267
267
|
*/
|
|
268
268
|
declare const fromWorkspaceClient: (client: WorkspaceClient) => ComputerWorkspaceService;
|
|
269
269
|
declare const ComputerWorkspace_base: Context.ServiceClass<ComputerWorkspace, "effect-cf/ComputerWorkspace", ComputerWorkspaceService>;
|
|
270
|
-
/** Effect service for the workspace owned by the enclosing Durable Object. */
|
|
271
270
|
declare class ComputerWorkspace extends ComputerWorkspace_base {
|
|
272
271
|
/**
|
|
273
272
|
* Acquires the single workspace registered by `withComputerWorkspace` and
|
|
274
273
|
* releases its RPC client when the layer scope closes.
|
|
275
274
|
*/
|
|
276
|
-
static readonly layer: Layer.Layer<ComputerWorkspace,
|
|
275
|
+
static readonly layer: Layer.Layer<ComputerWorkspace, WorkspaceAcquireError, DurableObjectState>;
|
|
277
276
|
}
|
|
278
277
|
//#endregion
|
|
279
|
-
export { ComputerWorkspace, ComputerWorkspaceAssets, ComputerWorkspaceFilesystem, ComputerWorkspaceGit, ComputerWorkspaceRuntime, ComputerWorkspaceService, type ComputerWorkspaceService as ComputerWorkspaceShape, ComputerWorkspaceThink, ListDirectoryOptions, ReadTextFileOptions, RemovePathOptions, 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 };
|
|
278
|
+
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,4 +1,4 @@
|
|
|
1
|
-
import { t as DurableObjectState } from "./DurableObjectState-
|
|
1
|
+
import { t as DurableObjectState } from "./DurableObjectState-DcqElJ4e.mjs";
|
|
2
2
|
import { fromClient } from "./ComputerArtifacts.mjs";
|
|
3
3
|
import { t as lookup } from "./ComputerWorkspaceHostRegistry-CY5Fv4Ng.mjs";
|
|
4
4
|
import { Context, Effect, Layer, Predicate, Schema, Stream } from "effect";
|
|
@@ -37,6 +37,13 @@ var WorkspaceAssetsError = class extends Schema.TaggedError()("WorkspaceAssetsEr
|
|
|
37
37
|
code: Schema.optionalKey(Schema.String),
|
|
38
38
|
cause: Schema.optionalKey(Schema.Defect({ includeStack: true }))
|
|
39
39
|
}) {};
|
|
40
|
+
/** Schema-serializable error while acquiring the Computer workspace client. */
|
|
41
|
+
var WorkspaceAcquireError = class extends Schema.TaggedError()("WorkspaceAcquireError", {
|
|
42
|
+
operation: Schema.String,
|
|
43
|
+
message: Schema.String,
|
|
44
|
+
code: Schema.optionalKey(Schema.String),
|
|
45
|
+
cause: Schema.optionalKey(Schema.Defect({ includeStack: true }))
|
|
46
|
+
}) {};
|
|
40
47
|
const errorMessage = (cause) => cause instanceof Error ? cause.message : String(cause);
|
|
41
48
|
const errorCode = (cause) => {
|
|
42
49
|
if (Predicate.hasProperty(cause, "code") && Predicate.isString(cause.code)) return cause.code;
|
|
@@ -72,6 +79,16 @@ const execError = (operation, cause) => {
|
|
|
72
79
|
if (code !== void 0) properties.code = code;
|
|
73
80
|
return WorkspaceExecError.make(properties);
|
|
74
81
|
};
|
|
82
|
+
const acquireError = (operation, cause) => {
|
|
83
|
+
const properties = {
|
|
84
|
+
operation,
|
|
85
|
+
message: errorMessage(cause),
|
|
86
|
+
cause
|
|
87
|
+
};
|
|
88
|
+
const code = errorCode(cause);
|
|
89
|
+
if (code !== void 0) properties.code = code;
|
|
90
|
+
return WorkspaceAcquireError.make(properties);
|
|
91
|
+
};
|
|
75
92
|
const assetsError = (operation, path, cause) => {
|
|
76
93
|
const properties = {
|
|
77
94
|
operation,
|
|
@@ -404,7 +421,6 @@ const wrapRun = (handle) => {
|
|
|
404
421
|
kill
|
|
405
422
|
};
|
|
406
423
|
};
|
|
407
|
-
const releaseRun = (handle) => Effect.sync(() => handle[Symbol.dispose]());
|
|
408
424
|
const makeRuntime = (client) => {
|
|
409
425
|
const execImplementation = Effect.fn("ComputerWorkspace.runtime.exec", { attributes: {
|
|
410
426
|
family: "runtime",
|
|
@@ -415,14 +431,14 @@ const makeRuntime = (client) => {
|
|
|
415
431
|
backend: options?.backend,
|
|
416
432
|
runId: options?.id
|
|
417
433
|
});
|
|
418
|
-
const handle = yield* Effect.
|
|
434
|
+
const handle = yield* Effect.acquireDisposable(Effect.tryPromise({
|
|
419
435
|
try: () => {
|
|
420
436
|
if (Predicate.isString(source)) return client.runtime.exec(source, runtimeExecOptions(options));
|
|
421
437
|
const values = optionsOrValue === void 0 ? remainingValues : [optionsOrValue, ...remainingValues];
|
|
422
438
|
return client.runtime.exec(source, ...values);
|
|
423
439
|
},
|
|
424
440
|
catch: (cause) => execError("exec", cause)
|
|
425
|
-
})
|
|
441
|
+
}));
|
|
426
442
|
return wrapRun(handle);
|
|
427
443
|
});
|
|
428
444
|
const exec = execImplementation;
|
|
@@ -434,10 +450,10 @@ const makeRuntime = (client) => {
|
|
|
434
450
|
backend: options?.backend,
|
|
435
451
|
runId: id
|
|
436
452
|
});
|
|
437
|
-
const handle = yield* Effect.
|
|
453
|
+
const handle = yield* Effect.acquireDisposable(Effect.tryPromise({
|
|
438
454
|
try: () => client.runtime.getExec(id, runtimeGetOptions(options)),
|
|
439
455
|
catch: (cause) => execError("getExec", cause)
|
|
440
|
-
})
|
|
456
|
+
}));
|
|
441
457
|
return wrapRun(handle);
|
|
442
458
|
});
|
|
443
459
|
const killExec = Effect.fn("ComputerWorkspace.runtime.killExec", { attributes: {
|
|
@@ -559,7 +575,6 @@ const fromWorkspaceClient = (client) => {
|
|
|
559
575
|
disposeExec: runtime.disposeExec
|
|
560
576
|
};
|
|
561
577
|
};
|
|
562
|
-
/** Effect service for the workspace owned by the enclosing Durable Object. */
|
|
563
578
|
var ComputerWorkspace = class ComputerWorkspace extends Context.Service()("effect-cf/ComputerWorkspace") {
|
|
564
579
|
/**
|
|
565
580
|
* Acquires the single workspace registered by `withComputerWorkspace` and
|
|
@@ -568,10 +583,16 @@ var ComputerWorkspace = class ComputerWorkspace extends Context.Service()("effec
|
|
|
568
583
|
static layer = Layer.effect(ComputerWorkspace, Effect.gen(function* () {
|
|
569
584
|
const host = lookup((yield* DurableObjectState).raw);
|
|
570
585
|
if (host === void 0) return yield* Effect.die("ComputerWorkspace.layer requires a Durable Object class built with withComputerWorkspace");
|
|
571
|
-
const computer = yield* Effect.
|
|
572
|
-
|
|
586
|
+
const computer = yield* Effect.tryPromise({
|
|
587
|
+
try: () => import("@cloudflare/computer"),
|
|
588
|
+
catch: (cause) => acquireError("import", cause)
|
|
589
|
+
});
|
|
590
|
+
const client = yield* Effect.acquireDisposable(Effect.tryPromise({
|
|
591
|
+
try: () => computer.getWorkspace(host),
|
|
592
|
+
catch: (cause) => acquireError("getWorkspace", cause)
|
|
593
|
+
}));
|
|
573
594
|
return ComputerWorkspace.of(fromWorkspaceClient(client));
|
|
574
595
|
}));
|
|
575
596
|
};
|
|
576
597
|
//#endregion
|
|
577
|
-
export { ComputerWorkspace, WorkspaceAssetsError, WorkspaceExecError, WorkspaceFsError, WorkspaceGitError, fromWorkspaceClient };
|
|
598
|
+
export { ComputerWorkspace, WorkspaceAcquireError, WorkspaceAssetsError, WorkspaceExecError, WorkspaceFsError, WorkspaceGitError, fromWorkspaceClient };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { t as ArtifactsBinding } from "./Artifacts-
|
|
1
|
+
import { t as ArtifactsBinding } from "./Artifacts-B3r3RuTB.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";
|
|
5
5
|
//#region src/ComputerWorkspaceHost.d.ts
|
|
6
|
-
/** The value of a `worker_loaders` binding. */
|
|
7
6
|
type DynamicWorkerLoader = WorkerShellLoader;
|
|
8
7
|
/** Default author and committer identity for workspace Git operations. */
|
|
9
8
|
interface ComputerWorkspaceGitIdentity {
|
|
@@ -25,20 +24,13 @@ interface ComputerWorkspaceArtifactsOptions {
|
|
|
25
24
|
*/
|
|
26
25
|
interface ComputerWorkspaceShellOptions extends Omit<WorkerShellBackendOptions, "source" | "loader" | "workspace" | "ctx" | "egress"> {
|
|
27
26
|
readonly loader: DynamicWorkerLoader;
|
|
28
|
-
/** Durable Object namespace binding that points back to the wrapped class. */
|
|
29
27
|
readonly hostBinding: string;
|
|
30
|
-
/** Current Durable Object id, normally `ctx.id.toString()`. */
|
|
31
28
|
readonly hostId: string;
|
|
32
|
-
/** Current Durable Object execution context, normally `ctx`. */
|
|
33
29
|
readonly executionContext: unknown;
|
|
34
|
-
/** Dynamic Worker egress policy. Defaults to `{ mode: "none" }`. */
|
|
35
30
|
readonly egress?: WorkspaceEgressPolicy;
|
|
36
31
|
}
|
|
37
|
-
/** Configuration accepted by {@link withComputerWorkspace}. */
|
|
38
32
|
interface ComputerWorkspaceHostConfig {
|
|
39
|
-
/** Native SQLite-backed Durable Object storage (`ctx.storage`). */
|
|
40
33
|
readonly storage: globalThis.DurableObjectStorage | DurableObjectStorageLike;
|
|
41
|
-
/** Stable workspace id used by mounts and as the default Artifacts session. */
|
|
42
34
|
readonly sessionId?: string;
|
|
43
35
|
readonly gitIdentity?: ComputerWorkspaceGitIdentity;
|
|
44
36
|
/** Override the default `createGitClient()` factory. */
|