effect-cf 0.7.0 → 0.8.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 +8 -0
- package/README.md +91 -0
- package/dist/Hyperdrive-By6DrSS_.d.mts +140 -0
- package/dist/Hyperdrive-LuQaVhXU.mjs +86 -0
- package/dist/HyperdrivePg.d.mts +14 -0
- package/dist/HyperdrivePg.mjs +13 -0
- package/dist/index.d.mts +257 -200
- package/dist/index.mjs +251 -190
- package/package.json +13 -1
- package/src/D1.ts +3 -59
- package/src/Hyperdrive.ts +82 -0
- package/src/HyperdrivePg.ts +27 -0
- package/src/Images.ts +332 -0
- package/src/Kv.ts +0 -62
- package/src/R2.ts +230 -0
- package/src/index.ts +3 -0
package/dist/index.mjs
CHANGED
|
@@ -1,103 +1,32 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { a as WorkerConfig, i as layer$8, n as Binding_exports, o as WorkerEnvironment, r as Service$2, t as Hyperdrive_exports } from "./Hyperdrive-LuQaVhXU.mjs";
|
|
3
|
+
import { Cause, Clock, ConfigProvider, Context, Data, DateTime, Duration, Effect, Exit, Layer, ManagedRuntime, Option, Queue, Schema } from "effect";
|
|
3
4
|
import { D1Client } from "@effect/sql-d1";
|
|
4
5
|
import { DurableObject, RpcStub, RpcTarget, WorkerEntrypoint, WorkflowEntrypoint } from "cloudflare:workers";
|
|
5
6
|
import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
6
7
|
import * as RpcMessage from "effect/unstable/rpc/RpcMessage";
|
|
7
8
|
import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization";
|
|
8
9
|
import * as RpcServer from "effect/unstable/rpc/RpcServer";
|
|
9
|
-
//#region src/Environment.ts
|
|
10
|
-
/**
|
|
11
|
-
* Context service for reading worker bindings from the current `env` object.
|
|
12
|
-
*/
|
|
13
|
-
var WorkerEnvironment = class extends Context.Service()("effect-cf/WorkerEnvironment") {};
|
|
14
|
-
let WorkerConfig;
|
|
15
|
-
(function(_WorkerConfig) {
|
|
16
|
-
_WorkerConfig.string = (name) => Config.string(name);
|
|
17
|
-
_WorkerConfig.redacted = (name) => Config.redacted(name);
|
|
18
|
-
_WorkerConfig.number = (name) => Config.number(name);
|
|
19
|
-
_WorkerConfig.integer = (name) => Config.int(name);
|
|
20
|
-
_WorkerConfig.boolean = (name) => Config.boolean(name);
|
|
21
|
-
const providerFromEnv = _WorkerConfig.providerFromEnv = (env) => ConfigProvider.fromUnknown(env);
|
|
22
|
-
const providerWith = _WorkerConfig.providerWith = (makeProvider) => Effect.map(WorkerEnvironment.asEffect(), makeProvider);
|
|
23
|
-
const provider = _WorkerConfig.provider = providerWith(providerFromEnv);
|
|
24
|
-
_WorkerConfig.layer = _WorkerConfig.providerLayer = ConfigProvider.layer(provider);
|
|
25
|
-
_WorkerConfig.layerWith = (makeProvider) => ConfigProvider.layer(providerWith(makeProvider));
|
|
26
|
-
})(WorkerConfig || (WorkerConfig = {}));
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/Binding.ts
|
|
29
|
-
var Binding_exports = /* @__PURE__ */ __exportAll({
|
|
30
|
-
BindingNotFoundError: () => BindingNotFoundError,
|
|
31
|
-
BindingValidationError: () => BindingValidationError,
|
|
32
|
-
Service: () => Service$2,
|
|
33
|
-
TypeId: () => TypeId$2,
|
|
34
|
-
layer: () => layer$6
|
|
35
|
-
});
|
|
36
|
-
/** Internal type id marker used by binding helper services. */
|
|
37
|
-
const TypeId$2 = "effect-cf/Binding";
|
|
38
|
-
/** Error raised when a configured binding does not exist on `env`. */
|
|
39
|
-
var BindingNotFoundError = class extends Data.TaggedError("BindingNotFoundError") {};
|
|
40
|
-
/** Error raised when a binding exists but does not match the expected shape. */
|
|
41
|
-
var BindingValidationError = class extends Data.TaggedError("BindingValidationError") {};
|
|
42
|
-
const isPropertyTarget$1 = (value) => (typeof value === "object" || typeof value === "function") && value !== null;
|
|
43
|
-
const getBinding = (env, binding, isResource) => Effect.gen(function* () {
|
|
44
|
-
if (!isPropertyTarget$1(env)) return yield* Effect.fail(new BindingValidationError({ binding }));
|
|
45
|
-
const resource = Reflect.get(env, binding);
|
|
46
|
-
if (resource === void 0) return yield* Effect.fail(new BindingNotFoundError({ binding }));
|
|
47
|
-
if (!isResource(resource)) return yield* Effect.fail(new BindingValidationError({ binding }));
|
|
48
|
-
return resource;
|
|
49
|
-
});
|
|
50
|
-
const layer$6 = (tag, binding, isResource, wrap) => Layer.effect(tag, Effect.gen(function* () {
|
|
51
|
-
const resource = yield* getBinding(yield* WorkerEnvironment, binding, isResource);
|
|
52
|
-
return wrap === void 0 ? resource : wrap(resource);
|
|
53
|
-
}));
|
|
54
|
-
const Service$2 = () => (id, binding, isResource, wrap) => {
|
|
55
|
-
const tag = Context.Service()(id);
|
|
56
|
-
const serviceLayer = layer$6(tag, binding, isResource, wrap);
|
|
57
|
-
return Object.assign(tag, {
|
|
58
|
-
[TypeId$2]: TypeId$2,
|
|
59
|
-
binding,
|
|
60
|
-
layer: serviceLayer
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
//#endregion
|
|
64
10
|
//#region src/D1.ts
|
|
65
11
|
var D1_exports = /* @__PURE__ */ __exportAll({
|
|
66
|
-
D1OperationError: () => D1OperationError,
|
|
67
12
|
Service: () => Service$1,
|
|
68
|
-
make: () => make$
|
|
13
|
+
make: () => make$10
|
|
69
14
|
});
|
|
70
|
-
const TypeId$
|
|
71
|
-
/** Error raised when a D1 operation fails. */
|
|
72
|
-
var D1OperationError = class extends Data.TaggedError("D1OperationError") {};
|
|
15
|
+
const TypeId$2 = "effect-cf/D1";
|
|
73
16
|
const isD1Database = (value) => {
|
|
74
17
|
if (typeof value !== "object" || value === null) return false;
|
|
75
18
|
const resource = value;
|
|
76
19
|
return typeof resource.prepare === "function" && typeof resource.batch === "function" && typeof resource.exec === "function";
|
|
77
20
|
};
|
|
78
|
-
const d1Error = (binding, operation, cause) => new D1OperationError({
|
|
79
|
-
binding,
|
|
80
|
-
operation,
|
|
81
|
-
cause
|
|
82
|
-
});
|
|
83
|
-
const tryD1Promise = (binding, operation, evaluate) => Effect.tryPromise({
|
|
84
|
-
try: evaluate,
|
|
85
|
-
catch: (cause) => d1Error(binding, operation, cause)
|
|
86
|
-
});
|
|
87
|
-
const tryD1Sync = (binding, operation, evaluate) => Effect.try({
|
|
88
|
-
try: evaluate,
|
|
89
|
-
catch: (cause) => d1Error(binding, operation, cause)
|
|
90
|
-
});
|
|
91
21
|
/**
|
|
92
22
|
* Creates a typed D1 service tag plus Effect helpers.
|
|
93
23
|
*/
|
|
94
|
-
const make$
|
|
24
|
+
const make$10 = (id, definition) => Service$1()(id, definition);
|
|
95
25
|
/**
|
|
96
26
|
* Builds a D1 service around a Cloudflare D1 database binding.
|
|
97
27
|
*
|
|
98
|
-
* The returned service exposes the raw `D1Database` binding
|
|
99
|
-
*
|
|
100
|
-
* `@effect/sql-d1`.
|
|
28
|
+
* The returned service exposes the raw `D1Database` binding and `sqlLayer(...)`
|
|
29
|
+
* for providing `effect/unstable/sql` via `@effect/sql-d1`.
|
|
101
30
|
*
|
|
102
31
|
* @example
|
|
103
32
|
* ```ts
|
|
@@ -117,29 +46,10 @@ const Service$1 = () => (id, definition) => {
|
|
|
117
46
|
db
|
|
118
47
|
});
|
|
119
48
|
})).pipe(Layer.provide(tag.layer));
|
|
120
|
-
const prepare = Effect.fnUntraced(function* (query) {
|
|
121
|
-
const db = yield* tag;
|
|
122
|
-
return yield* tryD1Sync(definition.binding, "prepare", () => db.prepare(query));
|
|
123
|
-
});
|
|
124
|
-
const batch = Effect.fnUntraced(function* (statements) {
|
|
125
|
-
const db = yield* tag;
|
|
126
|
-
return yield* tryD1Promise(definition.binding, "batch", () => db.batch([...statements]));
|
|
127
|
-
});
|
|
128
|
-
const exec = Effect.fnUntraced(function* (query) {
|
|
129
|
-
const db = yield* tag;
|
|
130
|
-
return yield* tryD1Promise(definition.binding, "exec", () => db.exec(query));
|
|
131
|
-
});
|
|
132
|
-
const unsafeRaw = Effect.fnUntraced(function* () {
|
|
133
|
-
return yield* tag;
|
|
134
|
-
});
|
|
135
49
|
return Object.assign(tag, {
|
|
136
|
-
[TypeId$
|
|
50
|
+
[TypeId$2]: TypeId$2,
|
|
137
51
|
definition,
|
|
138
|
-
sqlLayer
|
|
139
|
-
prepare,
|
|
140
|
-
batch,
|
|
141
|
-
exec,
|
|
142
|
-
unsafeRaw
|
|
52
|
+
sqlLayer
|
|
143
53
|
});
|
|
144
54
|
};
|
|
145
55
|
//#endregion
|
|
@@ -147,8 +57,8 @@ const Service$1 = () => (id, definition) => {
|
|
|
147
57
|
var QueueBinding_exports = /* @__PURE__ */ __exportAll({
|
|
148
58
|
QueueOperationError: () => QueueOperationError,
|
|
149
59
|
isQueue: () => isQueue,
|
|
150
|
-
layer: () => layer$
|
|
151
|
-
makeClient: () => makeClient$
|
|
60
|
+
layer: () => layer$7,
|
|
61
|
+
makeClient: () => makeClient$6
|
|
152
62
|
});
|
|
153
63
|
var QueueOperationError = class extends Data.TaggedError("QueueOperationError") {};
|
|
154
64
|
const queueError = (binding, operation, cause) => new QueueOperationError({
|
|
@@ -165,7 +75,7 @@ const isQueue = (value) => {
|
|
|
165
75
|
const resource = value;
|
|
166
76
|
return typeof resource.send === "function" && typeof resource.sendBatch === "function" && typeof resource.metrics === "function";
|
|
167
77
|
};
|
|
168
|
-
const makeClient$
|
|
78
|
+
const makeClient$6 = (definition) => {
|
|
169
79
|
const encodeMessage = Schema.encodeEffect(definition.message);
|
|
170
80
|
return (queue) => ({
|
|
171
81
|
send: Effect.fnUntraced(function* (message, options) {
|
|
@@ -184,30 +94,30 @@ const makeClient$4 = (definition) => {
|
|
|
184
94
|
unsafeRaw: Effect.succeed(queue)
|
|
185
95
|
});
|
|
186
96
|
};
|
|
187
|
-
const layer$
|
|
97
|
+
const layer$7 = (tag, definition) => layer$8(tag, definition.binding, (value) => isQueue(value), makeClient$6(definition));
|
|
188
98
|
//#endregion
|
|
189
99
|
//#region src/QueueDefinition.ts
|
|
190
100
|
var QueueDefinition_exports = /* @__PURE__ */ __exportAll({
|
|
191
101
|
Queue: () => Queue$1,
|
|
192
|
-
Tag: () => Tag$
|
|
102
|
+
Tag: () => Tag$10,
|
|
193
103
|
implement: () => implement$7,
|
|
194
|
-
make: () => make$
|
|
104
|
+
make: () => make$9
|
|
195
105
|
});
|
|
196
106
|
const makeDefinition$4 = (id, definition) => {
|
|
197
107
|
const queueDefinition = {
|
|
198
108
|
id,
|
|
199
109
|
message: definition.message
|
|
200
110
|
};
|
|
201
|
-
return Object.assign(queueDefinition, { make: (layer, options) => make$
|
|
111
|
+
return Object.assign(queueDefinition, { make: (layer, options) => make$6(layer, {
|
|
202
112
|
...options,
|
|
203
113
|
queue: wrapHandler$1(queueDefinition, options.queue)
|
|
204
114
|
}) });
|
|
205
115
|
};
|
|
206
|
-
const make$
|
|
207
|
-
const Tag$
|
|
116
|
+
const make$9 = (id, definition) => Tag$10()(id, definition);
|
|
117
|
+
const Tag$10 = () => (id, definition) => {
|
|
208
118
|
const queueDefinition = makeDefinition$4(id, definition);
|
|
209
119
|
const tag = Context.Service()(id);
|
|
210
|
-
const layer = (binding) => layer$
|
|
120
|
+
const layer = (binding) => layer$7(tag, {
|
|
211
121
|
...binding,
|
|
212
122
|
message: definition.message
|
|
213
123
|
});
|
|
@@ -234,7 +144,7 @@ const Tag$8 = () => (id, definition) => {
|
|
|
234
144
|
unsafeRaw
|
|
235
145
|
});
|
|
236
146
|
};
|
|
237
|
-
const Queue$1 = Tag$
|
|
147
|
+
const Queue$1 = Tag$10;
|
|
238
148
|
const wrapHandler$1 = (definition, handler) => {
|
|
239
149
|
const decodeBody = Schema.decodeUnknownEffect(definition.message);
|
|
240
150
|
return (batch) => Effect.gen(function* () {
|
|
@@ -246,7 +156,7 @@ const implement$7 = (_definition, handler) => handler;
|
|
|
246
156
|
//#region src/Queue.ts
|
|
247
157
|
var Queue_exports = /* @__PURE__ */ __exportAll({
|
|
248
158
|
QueueMessageDecodeError: () => QueueMessageDecodeError,
|
|
249
|
-
Tag: () => Tag$
|
|
159
|
+
Tag: () => Tag$9,
|
|
250
160
|
decodeBatch: () => decodeBatch,
|
|
251
161
|
fromMessage: () => fromMessage,
|
|
252
162
|
fromMessageBatch: () => fromMessageBatch,
|
|
@@ -284,7 +194,7 @@ const decodeBatch = (batch, decodeBody) => Effect.gen(function* () {
|
|
|
284
194
|
}
|
|
285
195
|
return fromMessageBatch(batch, messages);
|
|
286
196
|
});
|
|
287
|
-
const Tag$
|
|
197
|
+
const Tag$9 = Tag$10;
|
|
288
198
|
const implement$6 = implement$7;
|
|
289
199
|
//#endregion
|
|
290
200
|
//#region src/RpcDefinition.ts
|
|
@@ -302,7 +212,7 @@ var RpcDefinition_exports = /* @__PURE__ */ __exportAll({
|
|
|
302
212
|
decodeSuccess: () => decodeSuccess,
|
|
303
213
|
encodeArgs: () => encodeArgs,
|
|
304
214
|
encodeSuccess: () => encodeSuccess,
|
|
305
|
-
make: () => make$
|
|
215
|
+
make: () => make$8,
|
|
306
216
|
method: () => method$4,
|
|
307
217
|
reservedMethodNames: () => reservedMethodNames$4
|
|
308
218
|
});
|
|
@@ -405,7 +315,7 @@ const decodeSuccess = (definition, methodName, value) => {
|
|
|
405
315
|
cause
|
|
406
316
|
})));
|
|
407
317
|
};
|
|
408
|
-
const make$
|
|
318
|
+
const make$8 = (id, methods) => {
|
|
409
319
|
const definition = {
|
|
410
320
|
id,
|
|
411
321
|
methods
|
|
@@ -463,11 +373,11 @@ var ServiceBinding_exports = /* @__PURE__ */ __exportAll({
|
|
|
463
373
|
ServiceBindingFetchError: () => ServiceBindingFetchError,
|
|
464
374
|
ServiceBindingRpcError: () => ServiceBindingRpcError,
|
|
465
375
|
isServiceBindingClient: () => isServiceBindingClient,
|
|
466
|
-
layer: () => layer$
|
|
467
|
-
makeClient: () => makeClient$
|
|
376
|
+
layer: () => layer$6,
|
|
377
|
+
makeClient: () => makeClient$5,
|
|
468
378
|
makeDirectMethods: () => makeDirectMethods$1
|
|
469
379
|
});
|
|
470
|
-
const TypeId = "effect-cf/ServiceBinding";
|
|
380
|
+
const TypeId$1 = "effect-cf/ServiceBinding";
|
|
471
381
|
/**
|
|
472
382
|
* Failure raised when calling `fetch` on a service binding.
|
|
473
383
|
*/
|
|
@@ -477,7 +387,7 @@ var ServiceBindingFetchError = class extends Data.TaggedError("ServiceBindingFet
|
|
|
477
387
|
*/
|
|
478
388
|
var ServiceBindingRpcError = class extends Data.TaggedError("ServiceBindingRpcError") {};
|
|
479
389
|
const isServiceBindingClient = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "fetch") === "function";
|
|
480
|
-
const makeClient$
|
|
390
|
+
const makeClient$5 = (definition) => {
|
|
481
391
|
return (service) => {
|
|
482
392
|
const fetch = (input, init) => Effect.tryPromise({
|
|
483
393
|
try: () => service.fetch(input, init),
|
|
@@ -526,7 +436,7 @@ const makeClient$3 = (definition) => {
|
|
|
526
436
|
});
|
|
527
437
|
};
|
|
528
438
|
};
|
|
529
|
-
const layer$
|
|
439
|
+
const layer$6 = (tag, definition) => layer$8(tag, definition.binding, (value) => isServiceBindingClient(value), makeClient$5(definition));
|
|
530
440
|
/**
|
|
531
441
|
* Creates a typed Effect service for a Worker service binding.
|
|
532
442
|
*
|
|
@@ -557,7 +467,7 @@ const layer$4 = (tag, definition) => layer$6(tag, definition.binding, (value) =>
|
|
|
557
467
|
* ```
|
|
558
468
|
*/
|
|
559
469
|
const Service = () => (id, definition) => {
|
|
560
|
-
const tag = Service$2()(id, definition.binding, (value) => isServiceBindingClient(value), makeClient$
|
|
470
|
+
const tag = Service$2()(id, definition.binding, (value) => isServiceBindingClient(value), makeClient$5(definition));
|
|
561
471
|
const fetch = (input, init) => Effect.gen(function* () {
|
|
562
472
|
return yield* (yield* tag).fetch(input, init);
|
|
563
473
|
});
|
|
@@ -572,7 +482,7 @@ const Service = () => (id, definition) => {
|
|
|
572
482
|
});
|
|
573
483
|
const directMethods = makeDirectMethods$1(definition.definition, call);
|
|
574
484
|
return Object.assign(tag, directMethods, {
|
|
575
|
-
[TypeId]: TypeId,
|
|
485
|
+
[TypeId$1]: TypeId$1,
|
|
576
486
|
definition,
|
|
577
487
|
fetch,
|
|
578
488
|
rpc,
|
|
@@ -588,10 +498,10 @@ const makeDirectMethods$1 = (rpcDefinition, call) => {
|
|
|
588
498
|
//#endregion
|
|
589
499
|
//#region src/WorkerDefinition.ts
|
|
590
500
|
var WorkerDefinition_exports = /* @__PURE__ */ __exportAll({
|
|
591
|
-
Tag: () => Tag$
|
|
501
|
+
Tag: () => Tag$8,
|
|
592
502
|
Worker: () => Worker,
|
|
593
503
|
implement: () => implement$5,
|
|
594
|
-
make: () => make$
|
|
504
|
+
make: () => make$7,
|
|
595
505
|
method: () => method$3
|
|
596
506
|
});
|
|
597
507
|
const reservedMethodNames$3 = new Set([
|
|
@@ -629,21 +539,21 @@ const method$3 = method$4;
|
|
|
629
539
|
*/
|
|
630
540
|
const makeDefinition$3 = (id, methods) => {
|
|
631
541
|
assertNoReservedMethods("Worker", methods, reservedMethodNames$3);
|
|
632
|
-
const definition = make$
|
|
633
|
-
return Object.assign(definition, { make: (layer, options) => make$
|
|
542
|
+
const definition = make$8(id, methods);
|
|
543
|
+
return Object.assign(definition, { make: (layer, options) => make$6(layer, {
|
|
634
544
|
...options,
|
|
635
545
|
rpc: wrapHandlers$1(definition, options.rpc)
|
|
636
546
|
}) });
|
|
637
547
|
};
|
|
638
|
-
const make$
|
|
639
|
-
const Tag$
|
|
548
|
+
const make$7 = (id, methods) => Tag$8()(id, methods);
|
|
549
|
+
const Tag$8 = () => (id, methods) => {
|
|
640
550
|
const definition = makeDefinition$3(id, methods);
|
|
641
551
|
const tag = Context.Service()(id);
|
|
642
552
|
const bindingDefinition = (binding) => ({
|
|
643
553
|
...binding,
|
|
644
554
|
definition
|
|
645
555
|
});
|
|
646
|
-
const layer = (binding) => layer$
|
|
556
|
+
const layer = (binding) => layer$6(tag, bindingDefinition(binding));
|
|
647
557
|
const fetch = (input, init) => Effect.gen(function* () {
|
|
648
558
|
return yield* (yield* tag).fetch(input, init);
|
|
649
559
|
});
|
|
@@ -668,7 +578,7 @@ const Tag$6 = () => (id, methods) => {
|
|
|
668
578
|
scopedCall
|
|
669
579
|
});
|
|
670
580
|
};
|
|
671
|
-
const Worker = Tag$
|
|
581
|
+
const Worker = Tag$8;
|
|
672
582
|
const wrapHandlers$1 = (definition, handlers) => {
|
|
673
583
|
const wrapped = {};
|
|
674
584
|
for (const key of Object.keys(definition.methods)) {
|
|
@@ -724,11 +634,11 @@ const fromExecutionContext = (ctx, runPromiseExit) => {
|
|
|
724
634
|
var Worker_exports = /* @__PURE__ */ __exportAll({
|
|
725
635
|
ExecutionContext: () => ExecutionContext,
|
|
726
636
|
NativeRequest: () => NativeRequest,
|
|
727
|
-
Tag: () => Tag$
|
|
637
|
+
Tag: () => Tag$7,
|
|
728
638
|
WorkerContext: () => WorkerContext,
|
|
729
639
|
implement: () => implement$4,
|
|
730
640
|
isWebSocketUpgrade: () => isWebSocketUpgrade,
|
|
731
|
-
make: () => make$
|
|
641
|
+
make: () => make$6,
|
|
732
642
|
makeFetchHandler: () => makeFetchHandler,
|
|
733
643
|
method: () => method$2,
|
|
734
644
|
renderHttpResponse: () => renderHttpResponse
|
|
@@ -757,7 +667,7 @@ const RunSymbol$1 = Symbol.for("effect-cf/Worker/run");
|
|
|
757
667
|
const renderHttpResponse = (effect) => Effect.flatMap(effect, (response) => Effect.map(Effect.context(), (context) => HttpServerResponse.toWeb(response, { context })));
|
|
758
668
|
const renderFetchSuccess = (effect) => Effect.flatMap(effect, (response) => response instanceof Response ? Effect.succeed(response) : Effect.map(Effect.context(), (context) => HttpServerResponse.toWeb(response, { context })));
|
|
759
669
|
const isWorkerOptions = (options) => typeof options === "object" && options !== null && ("fetch" in options || "queue" in options || "rpc" in options);
|
|
760
|
-
function make$
|
|
670
|
+
function make$6(layer, optionsOrFetch) {
|
|
761
671
|
const options = isWorkerOptions(optionsOrFetch) ? optionsOrFetch : { fetch: optionsOrFetch };
|
|
762
672
|
class EffectWorker extends WorkerEntrypoint {
|
|
763
673
|
runtime;
|
|
@@ -788,10 +698,10 @@ function make$4(layer, optionsOrFetch) {
|
|
|
788
698
|
return assumeEntrypointClass(EffectWorker);
|
|
789
699
|
}
|
|
790
700
|
const makeFetchHandler = (layer, options) => {
|
|
791
|
-
const WorkerClass = make$
|
|
701
|
+
const WorkerClass = make$6(layer, options);
|
|
792
702
|
return { fetch: (request, env, ctx) => Promise.resolve(new WorkerClass(ctx, env).fetch(request)) };
|
|
793
703
|
};
|
|
794
|
-
const Tag$
|
|
704
|
+
const Tag$7 = Tag$8;
|
|
795
705
|
const method$2 = method$3;
|
|
796
706
|
const implement$4 = implement$5;
|
|
797
707
|
//#endregion
|
|
@@ -1089,8 +999,8 @@ var DurableObjectNamespace_exports = /* @__PURE__ */ __exportAll({
|
|
|
1089
999
|
DurableObjectFetchError: () => DurableObjectFetchError,
|
|
1090
1000
|
DurableObjectRpcError: () => DurableObjectRpcError,
|
|
1091
1001
|
isDurableObjectNamespaceClient: () => isDurableObjectNamespaceClient,
|
|
1092
|
-
layer: () => layer$
|
|
1093
|
-
makeClient: () => makeClient$
|
|
1002
|
+
layer: () => layer$5,
|
|
1003
|
+
makeClient: () => makeClient$4,
|
|
1094
1004
|
makeDirectMethods: () => makeDirectMethods
|
|
1095
1005
|
});
|
|
1096
1006
|
/**
|
|
@@ -1101,9 +1011,9 @@ var DurableObjectRpcError = class extends Data.TaggedError("DurableObjectRpcErro
|
|
|
1101
1011
|
* Failure raised when forwarding a request to a Durable Object stub.
|
|
1102
1012
|
*/
|
|
1103
1013
|
var DurableObjectFetchError = class extends Data.TaggedError("DurableObjectFetchError") {};
|
|
1104
|
-
const hasFunction = (value, key) => typeof Reflect.get(value, key) === "function";
|
|
1105
|
-
const isDurableObjectNamespaceClient = (value) => typeof value === "object" && value !== null && hasFunction(value, "getByName") && hasFunction(value, "get") && hasFunction(value, "idFromName") && hasFunction(value, "idFromString") && hasFunction(value, "newUniqueId") && hasFunction(value, "jurisdiction");
|
|
1106
|
-
const makeClient$
|
|
1014
|
+
const hasFunction$1 = (value, key) => typeof Reflect.get(value, key) === "function";
|
|
1015
|
+
const isDurableObjectNamespaceClient = (value) => typeof value === "object" && value !== null && hasFunction$1(value, "getByName") && hasFunction$1(value, "get") && hasFunction$1(value, "idFromName") && hasFunction$1(value, "idFromString") && hasFunction$1(value, "newUniqueId") && hasFunction$1(value, "jurisdiction");
|
|
1016
|
+
const makeClient$4 = (definition) => {
|
|
1107
1017
|
return (namespace) => {
|
|
1108
1018
|
const newUniqueId = (options) => Effect.sync(() => namespace.newUniqueId(options));
|
|
1109
1019
|
const idFromName = (name) => Effect.sync(() => namespace.idFromName(name));
|
|
@@ -1170,7 +1080,7 @@ const makeClient$2 = (definition) => {
|
|
|
1170
1080
|
});
|
|
1171
1081
|
};
|
|
1172
1082
|
};
|
|
1173
|
-
const layer$
|
|
1083
|
+
const layer$5 = (tag, definition) => layer$8(tag, definition.binding, (value) => isDurableObjectNamespaceClient(value), makeClient$4(definition));
|
|
1174
1084
|
const makeDirectMethods = (rpcDefinition, helpers) => {
|
|
1175
1085
|
const methods = {};
|
|
1176
1086
|
if (rpcDefinition !== void 0) {
|
|
@@ -1195,9 +1105,9 @@ const makeDirectMethods = (rpcDefinition, helpers) => {
|
|
|
1195
1105
|
//#region src/DurableObjectDefinition.ts
|
|
1196
1106
|
var DurableObjectDefinition_exports = /* @__PURE__ */ __exportAll({
|
|
1197
1107
|
DurableObject: () => DurableObject$1,
|
|
1198
|
-
Tag: () => Tag$
|
|
1108
|
+
Tag: () => Tag$6,
|
|
1199
1109
|
implement: () => implement$3,
|
|
1200
|
-
make: () => make$
|
|
1110
|
+
make: () => make$5,
|
|
1201
1111
|
method: () => method$1
|
|
1202
1112
|
});
|
|
1203
1113
|
const reservedMethodNames$1 = new Set([
|
|
@@ -1228,21 +1138,21 @@ const method$1 = method$4;
|
|
|
1228
1138
|
*/
|
|
1229
1139
|
const makeDefinition$2 = (id, methods) => {
|
|
1230
1140
|
assertNoReservedMethods("Durable Object", methods, reservedMethodNames$1);
|
|
1231
|
-
const definition = make$
|
|
1232
|
-
return Object.assign(definition, { make: (layer, options) => make$
|
|
1141
|
+
const definition = make$8(id, methods);
|
|
1142
|
+
return Object.assign(definition, { make: (layer, options) => make$4(layer, {
|
|
1233
1143
|
...options,
|
|
1234
1144
|
rpc: wrapHandlers(definition, options.rpc)
|
|
1235
1145
|
}) });
|
|
1236
1146
|
};
|
|
1237
|
-
const make$
|
|
1238
|
-
const Tag$
|
|
1147
|
+
const make$5 = (id, methods) => Tag$6()(id, methods);
|
|
1148
|
+
const Tag$6 = () => (id, methods) => {
|
|
1239
1149
|
const definition = makeDefinition$2(id, methods);
|
|
1240
1150
|
const tag = Context.Service()(id);
|
|
1241
1151
|
const bindingDefinition = (binding) => ({
|
|
1242
1152
|
...binding,
|
|
1243
1153
|
definition
|
|
1244
1154
|
});
|
|
1245
|
-
const layer = (binding) => layer$
|
|
1155
|
+
const layer = (binding) => layer$5(tag, bindingDefinition(binding));
|
|
1246
1156
|
const newUniqueId = Effect.fnUntraced(function* (options) {
|
|
1247
1157
|
return yield* (yield* tag).newUniqueId(options);
|
|
1248
1158
|
});
|
|
@@ -1300,7 +1210,7 @@ const Tag$4 = () => (id, methods) => {
|
|
|
1300
1210
|
unsafeRaw
|
|
1301
1211
|
});
|
|
1302
1212
|
};
|
|
1303
|
-
const DurableObject$1 = Tag$
|
|
1213
|
+
const DurableObject$1 = Tag$6;
|
|
1304
1214
|
const wrapHandlers = (definition, handlers) => {
|
|
1305
1215
|
const wrapped = {};
|
|
1306
1216
|
for (const key of Object.keys(definition.methods)) {
|
|
@@ -1318,9 +1228,9 @@ const implement$3 = (_definition, handlers) => handlers;
|
|
|
1318
1228
|
//#endregion
|
|
1319
1229
|
//#region src/DurableObject.ts
|
|
1320
1230
|
var DurableObject_exports = /* @__PURE__ */ __exportAll({
|
|
1321
|
-
Tag: () => Tag$
|
|
1231
|
+
Tag: () => Tag$5,
|
|
1322
1232
|
implement: () => implement$2,
|
|
1323
|
-
make: () => make$
|
|
1233
|
+
make: () => make$4,
|
|
1324
1234
|
method: () => method
|
|
1325
1235
|
});
|
|
1326
1236
|
const reservedMethodNames = new Set([
|
|
@@ -1336,7 +1246,7 @@ const RunSymbol = Symbol.for("effect-cf/DurableObject/run");
|
|
|
1336
1246
|
/**
|
|
1337
1247
|
* Creates a Durable Object class backed by a single managed Effect runtime.
|
|
1338
1248
|
*/
|
|
1339
|
-
const make$
|
|
1249
|
+
const make$4 = (layer, options = {}) => {
|
|
1340
1250
|
class EffectDurableObject extends DurableObject {
|
|
1341
1251
|
runtime;
|
|
1342
1252
|
constructor(state, env) {
|
|
@@ -1375,7 +1285,7 @@ const make$2 = (layer, options = {}) => {
|
|
|
1375
1285
|
defineEntrypointRpcMethods("Durable Object", EffectDurableObject.prototype, options.rpc, reservedMethodNames, (self, effect) => self[RunSymbol](effect));
|
|
1376
1286
|
return assumeEntrypointClass(EffectDurableObject);
|
|
1377
1287
|
};
|
|
1378
|
-
const Tag$
|
|
1288
|
+
const Tag$5 = Tag$6;
|
|
1379
1289
|
const method = method$1;
|
|
1380
1290
|
const implement$2 = implement$3;
|
|
1381
1291
|
//#endregion
|
|
@@ -1704,7 +1614,7 @@ var DurableObjectAlarm = class DurableObjectAlarm extends Context.Service()("eff
|
|
|
1704
1614
|
//#region src/DurableObjectRpcWebSocket.ts
|
|
1705
1615
|
var DurableObjectRpcWebSocket_exports = /* @__PURE__ */ __exportAll({
|
|
1706
1616
|
DurableObjectRpcWebSocket: () => DurableObjectRpcWebSocket,
|
|
1707
|
-
layer: () => layer$
|
|
1617
|
+
layer: () => layer$4
|
|
1708
1618
|
});
|
|
1709
1619
|
const defaultAttachmentKey = "effectCloudflareRpcClientId";
|
|
1710
1620
|
const defaultTag = "effect-cf-rpc";
|
|
@@ -1715,7 +1625,7 @@ var DurableObjectRpcWebSocket = class extends Context.Service()("effect-cf/Durab
|
|
|
1715
1625
|
/**
|
|
1716
1626
|
* Builds a layer that bridges Durable Object websocket events to `RpcServer.Protocol`.
|
|
1717
1627
|
*/
|
|
1718
|
-
const layer$
|
|
1628
|
+
const layer$4 = (options = {}) => Layer.effectContext(Effect.gen(function* () {
|
|
1719
1629
|
const tag = options.tag ?? defaultTag;
|
|
1720
1630
|
const attachmentKey = options.attachmentKey ?? defaultAttachmentKey;
|
|
1721
1631
|
const durableObjectState = yield* DurableObjectState;
|
|
@@ -1827,13 +1737,119 @@ const writeAttachment = (socket, key, clientId) => {
|
|
|
1827
1737
|
});
|
|
1828
1738
|
};
|
|
1829
1739
|
//#endregion
|
|
1740
|
+
//#region src/Images.ts
|
|
1741
|
+
var Images_exports = /* @__PURE__ */ __exportAll({
|
|
1742
|
+
ImagesOperationError: () => ImagesOperationError,
|
|
1743
|
+
Tag: () => Tag$4,
|
|
1744
|
+
draw: () => draw,
|
|
1745
|
+
empty: () => empty,
|
|
1746
|
+
isImagesBinding: () => isImagesBinding,
|
|
1747
|
+
layer: () => layer$3,
|
|
1748
|
+
make: () => make$3,
|
|
1749
|
+
makeClient: () => makeClient$3,
|
|
1750
|
+
transform: () => transform
|
|
1751
|
+
});
|
|
1752
|
+
const TypeId = "effect-cf/Images/Steps";
|
|
1753
|
+
/** Error raised when a Cloudflare Images operation fails. */
|
|
1754
|
+
var ImagesOperationError = class extends Data.TaggedError("ImagesOperationError") {};
|
|
1755
|
+
const makeSteps = (steps) => ({
|
|
1756
|
+
[TypeId]: TypeId,
|
|
1757
|
+
steps
|
|
1758
|
+
});
|
|
1759
|
+
/** Empty Images transformation pipeline. */
|
|
1760
|
+
const empty = makeSteps([]);
|
|
1761
|
+
function transform(stepsOrTransform, transformValue) {
|
|
1762
|
+
if (transformValue === void 0) return (steps) => transform(steps, stepsOrTransform);
|
|
1763
|
+
return makeSteps([...stepsOrTransform.steps, {
|
|
1764
|
+
_tag: "Transform",
|
|
1765
|
+
transform: transformValue
|
|
1766
|
+
}]);
|
|
1767
|
+
}
|
|
1768
|
+
function draw(stepsOrDraw, drawValue) {
|
|
1769
|
+
if (drawValue === void 0) return (steps) => draw(steps, stepsOrDraw);
|
|
1770
|
+
return makeSteps([...stepsOrDraw.steps, {
|
|
1771
|
+
_tag: "Draw",
|
|
1772
|
+
...drawValue
|
|
1773
|
+
}]);
|
|
1774
|
+
}
|
|
1775
|
+
const imagesError = (binding, operation, cause) => new ImagesOperationError({
|
|
1776
|
+
binding,
|
|
1777
|
+
operation,
|
|
1778
|
+
cause
|
|
1779
|
+
});
|
|
1780
|
+
const tryImagesPromise = (binding, operation, evaluate) => Effect.tryPromise({
|
|
1781
|
+
try: evaluate,
|
|
1782
|
+
catch: (cause) => imagesError(binding, operation, cause)
|
|
1783
|
+
});
|
|
1784
|
+
const tryImagesSync = (binding, operation, evaluate) => Effect.try({
|
|
1785
|
+
try: evaluate,
|
|
1786
|
+
catch: (cause) => imagesError(binding, operation, cause)
|
|
1787
|
+
});
|
|
1788
|
+
const maybe$1 = (value) => value === null ? Option.none() : Option.some(value);
|
|
1789
|
+
const hasFunction = (value, key) => typeof Reflect.get(value, key) === "function";
|
|
1790
|
+
const isHostedImagesBinding = (value) => typeof value === "object" && value !== null && hasFunction(value, "image") && hasFunction(value, "upload") && hasFunction(value, "list");
|
|
1791
|
+
const isImagesBinding = (value) => typeof value === "object" && value !== null && hasFunction(value, "info") && hasFunction(value, "input");
|
|
1792
|
+
const wrapResult = (binding, result) => ({
|
|
1793
|
+
raw: result,
|
|
1794
|
+
response: tryImagesSync(binding, "response", () => result.response()),
|
|
1795
|
+
contentType: tryImagesSync(binding, "contentType", () => result.contentType()),
|
|
1796
|
+
image: (options) => tryImagesSync(binding, "image", () => result.image(options))
|
|
1797
|
+
});
|
|
1798
|
+
const wrapHandle = (binding, handle) => ({
|
|
1799
|
+
raw: handle,
|
|
1800
|
+
details: tryImagesPromise(binding, "details", () => handle.details()).pipe(Effect.map(maybe$1)),
|
|
1801
|
+
bytes: tryImagesPromise(binding, "bytes", () => handle.bytes()).pipe(Effect.map(maybe$1)),
|
|
1802
|
+
update: (options) => tryImagesPromise(binding, "update", () => handle.update(options)),
|
|
1803
|
+
delete: tryImagesPromise(binding, "delete", () => handle.delete())
|
|
1804
|
+
});
|
|
1805
|
+
const wrapHosted = (binding, hosted) => ({
|
|
1806
|
+
image: (imageId) => wrapHandle(binding, hosted.image(imageId)),
|
|
1807
|
+
upload: (image, options) => tryImagesPromise(binding, "upload", () => hosted.upload(image, options)),
|
|
1808
|
+
list: (options) => tryImagesPromise(binding, "list", () => hosted.list(options)),
|
|
1809
|
+
unsafeRaw: Effect.succeed(hosted)
|
|
1810
|
+
});
|
|
1811
|
+
const makeClient$3 = (definition) => (images) => {
|
|
1812
|
+
const input = (image, options) => tryImagesSync(definition.binding, "input", () => images.input(image, options));
|
|
1813
|
+
const process = (steps, options) => Effect.gen(function* () {
|
|
1814
|
+
let transformer = yield* input(options.stream, options.inputOptions);
|
|
1815
|
+
for (const step of steps.steps) switch (step._tag) {
|
|
1816
|
+
case "Draw":
|
|
1817
|
+
transformer = yield* tryImagesSync(definition.binding, "draw", () => transformer.draw(step.image, step.options));
|
|
1818
|
+
break;
|
|
1819
|
+
case "Transform":
|
|
1820
|
+
transformer = yield* tryImagesSync(definition.binding, "transform", () => transformer.transform(step.transform));
|
|
1821
|
+
break;
|
|
1822
|
+
}
|
|
1823
|
+
const result = yield* tryImagesPromise(definition.binding, "output", () => transformer.output(options.outputOptions));
|
|
1824
|
+
return wrapResult(definition.binding, result);
|
|
1825
|
+
});
|
|
1826
|
+
return {
|
|
1827
|
+
definition,
|
|
1828
|
+
info: (image, options) => tryImagesPromise(definition.binding, "info", () => images.info(image, options)),
|
|
1829
|
+
input,
|
|
1830
|
+
process,
|
|
1831
|
+
hosted: isHostedImagesBinding(images.hosted) ? Option.some(wrapHosted(definition.binding, images.hosted)) : Option.none(),
|
|
1832
|
+
unsafeRaw: Effect.succeed(images)
|
|
1833
|
+
};
|
|
1834
|
+
};
|
|
1835
|
+
const layer$3 = (tag, definition) => layer$8(tag, definition.binding, isImagesBinding, makeClient$3(definition));
|
|
1836
|
+
const make$3 = (id) => Tag$4()(id);
|
|
1837
|
+
const Tag$4 = () => (id) => {
|
|
1838
|
+
const tag = Context.Service()(id);
|
|
1839
|
+
const makeLayer = (definition) => layer$3(tag, definition);
|
|
1840
|
+
return Object.assign(tag, {
|
|
1841
|
+
id,
|
|
1842
|
+
layer: makeLayer
|
|
1843
|
+
});
|
|
1844
|
+
};
|
|
1845
|
+
//#endregion
|
|
1830
1846
|
//#region src/Kv.ts
|
|
1831
1847
|
var Kv_exports = /* @__PURE__ */ __exportAll({
|
|
1832
1848
|
KvOperationError: () => KvOperationError,
|
|
1833
|
-
Tag: () => Tag$
|
|
1849
|
+
Tag: () => Tag$3,
|
|
1834
1850
|
isKvNamespace: () => isKvNamespace,
|
|
1835
|
-
layer: () => layer$
|
|
1836
|
-
makeClient: () => makeClient$
|
|
1851
|
+
layer: () => layer$2,
|
|
1852
|
+
makeClient: () => makeClient$2
|
|
1837
1853
|
});
|
|
1838
1854
|
/** Error raised when a KV operation fails. */
|
|
1839
1855
|
var KvOperationError = class extends Data.TaggedError("KvOperationError") {};
|
|
@@ -1853,7 +1869,7 @@ const isKvNamespace = (value) => {
|
|
|
1853
1869
|
const resource = value;
|
|
1854
1870
|
return typeof resource.get === "function" && typeof resource.put === "function" && typeof resource.delete === "function" && typeof resource.getWithMetadata === "function" && typeof resource.list === "function";
|
|
1855
1871
|
};
|
|
1856
|
-
const makeClient$
|
|
1872
|
+
const makeClient$2 = (definition) => {
|
|
1857
1873
|
const encodeKey = Schema.encodeEffect(definition.key);
|
|
1858
1874
|
const decodeKey = Schema.decodeUnknownEffect(definition.key);
|
|
1859
1875
|
const encodeValue = Schema.encodeEffect(Schema.fromJsonString(Schema.toCodecJson(definition.value)));
|
|
@@ -1910,52 +1926,97 @@ const makeClient$1 = (definition) => {
|
|
|
1910
1926
|
unsafeRaw: Effect.succeed(kv)
|
|
1911
1927
|
});
|
|
1912
1928
|
};
|
|
1913
|
-
const layer$
|
|
1929
|
+
const layer$2 = (tag, definition) => layer$8(tag, definition.binding, isKvNamespace, makeClient$2(definition));
|
|
1914
1930
|
const makeDefinition$1 = (id, definition) => {
|
|
1915
1931
|
const kvDefinition = {
|
|
1916
1932
|
id,
|
|
1917
1933
|
key: definition.key,
|
|
1918
1934
|
value: definition.value
|
|
1919
1935
|
};
|
|
1920
|
-
return Object.assign(kvDefinition, { layer: (tag, binding) => layer$
|
|
1936
|
+
return Object.assign(kvDefinition, { layer: (tag, binding) => layer$2(tag, {
|
|
1921
1937
|
...binding,
|
|
1922
1938
|
key: definition.key,
|
|
1923
1939
|
value: definition.value
|
|
1924
1940
|
}) });
|
|
1925
1941
|
};
|
|
1926
|
-
const Tag$
|
|
1942
|
+
const Tag$3 = () => (id, definition) => {
|
|
1927
1943
|
const kvDefinition = makeDefinition$1(id, definition);
|
|
1928
1944
|
const tag = Context.Service()(id);
|
|
1929
1945
|
const makeLayer = (binding) => kvDefinition.layer(tag, binding);
|
|
1930
|
-
const put = Effect.fnUntraced(function* (key, value, options) {
|
|
1931
|
-
yield* (yield* tag).put(key, value, options);
|
|
1932
|
-
});
|
|
1933
|
-
const get = Effect.fnUntraced(function* (key) {
|
|
1934
|
-
return yield* (yield* tag).get(key);
|
|
1935
|
-
});
|
|
1936
|
-
const getWithMetadata = Effect.fnUntraced(function* (key, metadataSchema) {
|
|
1937
|
-
return yield* (yield* tag).getWithMetadata(key, metadataSchema);
|
|
1938
|
-
});
|
|
1939
|
-
const list = Effect.fnUntraced(function* (options) {
|
|
1940
|
-
return yield* (yield* tag).list(options);
|
|
1941
|
-
});
|
|
1942
|
-
const remove = Effect.fnUntraced(function* (key) {
|
|
1943
|
-
yield* (yield* tag).remove(key);
|
|
1944
|
-
});
|
|
1945
|
-
const unsafeRaw = Effect.fnUntraced(function* () {
|
|
1946
|
-
return yield* (yield* tag).unsafeRaw;
|
|
1947
|
-
});
|
|
1948
1946
|
return Object.assign(tag, {
|
|
1949
1947
|
id: kvDefinition.id,
|
|
1950
1948
|
keySchema: kvDefinition.key,
|
|
1951
1949
|
valueSchema: kvDefinition.value,
|
|
1952
|
-
layer: makeLayer
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1950
|
+
layer: makeLayer
|
|
1951
|
+
});
|
|
1952
|
+
};
|
|
1953
|
+
//#endregion
|
|
1954
|
+
//#region src/R2.ts
|
|
1955
|
+
var R2_exports = /* @__PURE__ */ __exportAll({
|
|
1956
|
+
R2OperationError: () => R2OperationError,
|
|
1957
|
+
Tag: () => Tag$2,
|
|
1958
|
+
isR2Bucket: () => isR2Bucket,
|
|
1959
|
+
layer: () => layer$1,
|
|
1960
|
+
make: () => make$2,
|
|
1961
|
+
makeClient: () => makeClient$1
|
|
1962
|
+
});
|
|
1963
|
+
/** Error raised when an R2 operation fails. */
|
|
1964
|
+
var R2OperationError = class extends Data.TaggedError("R2OperationError") {};
|
|
1965
|
+
const r2Error = (binding, operation, cause) => new R2OperationError({
|
|
1966
|
+
binding,
|
|
1967
|
+
operation,
|
|
1968
|
+
cause
|
|
1969
|
+
});
|
|
1970
|
+
const tryR2Promise = (binding, operation, evaluate) => Effect.tryPromise({
|
|
1971
|
+
try: evaluate,
|
|
1972
|
+
catch: (cause) => r2Error(binding, operation, cause)
|
|
1973
|
+
});
|
|
1974
|
+
const tryR2Sync = (binding, operation, evaluate) => Effect.try({
|
|
1975
|
+
try: evaluate,
|
|
1976
|
+
catch: (cause) => r2Error(binding, operation, cause)
|
|
1977
|
+
});
|
|
1978
|
+
const maybe = (value) => value === null ? Option.none() : Option.some(value);
|
|
1979
|
+
const isR2Bucket = (value) => {
|
|
1980
|
+
if (typeof value !== "object" || value === null) return false;
|
|
1981
|
+
const resource = value;
|
|
1982
|
+
return typeof resource.head === "function" && typeof resource.get === "function" && typeof resource.put === "function" && typeof resource.createMultipartUpload === "function" && typeof resource.resumeMultipartUpload === "function" && typeof resource.delete === "function" && typeof resource.list === "function";
|
|
1983
|
+
};
|
|
1984
|
+
const makeClient$1 = (definition) => {
|
|
1985
|
+
const wrapUpload = (upload) => ({
|
|
1986
|
+
raw: upload,
|
|
1987
|
+
key: upload.key,
|
|
1988
|
+
uploadId: upload.uploadId,
|
|
1989
|
+
uploadPart: (partNumber, value, options) => tryR2Promise(definition.binding, "uploadPart", () => upload.uploadPart(partNumber, value, options)),
|
|
1990
|
+
abort: tryR2Promise(definition.binding, "abortMultipartUpload", () => upload.abort()),
|
|
1991
|
+
complete: (uploadedParts) => tryR2Promise(definition.binding, "completeMultipartUpload", () => upload.complete([...uploadedParts]))
|
|
1992
|
+
});
|
|
1993
|
+
return (bucket) => ({
|
|
1994
|
+
definition,
|
|
1995
|
+
head: (key) => tryR2Promise(definition.binding, "head", () => bucket.head(key)).pipe(Effect.map(maybe)),
|
|
1996
|
+
get: ((key, options) => tryR2Promise(definition.binding, "get", () => bucket.get(key, options)).pipe(Effect.map(maybe))),
|
|
1997
|
+
put: ((key, value, options) => tryR2Promise(definition.binding, "put", () => bucket.put(key, value, options)).pipe(Effect.map((object) => {
|
|
1998
|
+
if (object === null) return Option.none();
|
|
1999
|
+
if (options !== void 0 && "onlyIf" in options) return Option.some(object);
|
|
2000
|
+
return object;
|
|
2001
|
+
}))),
|
|
2002
|
+
createMultipartUpload: (key, options) => tryR2Promise(definition.binding, "createMultipartUpload", () => bucket.createMultipartUpload(key, options)).pipe(Effect.map(wrapUpload)),
|
|
2003
|
+
resumeMultipartUpload: (key, uploadId) => tryR2Sync(definition.binding, "resumeMultipartUpload", () => wrapUpload(bucket.resumeMultipartUpload(key, uploadId))),
|
|
2004
|
+
delete: (keys) => {
|
|
2005
|
+
const nativeKeys = typeof keys === "string" ? keys : [...keys];
|
|
2006
|
+
return tryR2Promise(definition.binding, "delete", () => bucket.delete(nativeKeys));
|
|
2007
|
+
},
|
|
2008
|
+
list: (options) => tryR2Promise(definition.binding, "list", () => bucket.list(options)),
|
|
2009
|
+
unsafeRaw: Effect.succeed(bucket)
|
|
2010
|
+
});
|
|
2011
|
+
};
|
|
2012
|
+
const layer$1 = (tag, definition) => layer$8(tag, definition.binding, isR2Bucket, makeClient$1(definition));
|
|
2013
|
+
const make$2 = (id) => Tag$2()(id);
|
|
2014
|
+
const Tag$2 = () => (id) => {
|
|
2015
|
+
const tag = Context.Service()(id);
|
|
2016
|
+
const makeLayer = (definition) => layer$1(tag, definition);
|
|
2017
|
+
return Object.assign(tag, {
|
|
2018
|
+
id,
|
|
2019
|
+
layer: makeLayer
|
|
1959
2020
|
});
|
|
1960
2021
|
};
|
|
1961
2022
|
//#endregion
|
|
@@ -2033,7 +2094,7 @@ const makeClient = (definition) => {
|
|
|
2033
2094
|
unsafeRaw: Effect.succeed(workflow)
|
|
2034
2095
|
});
|
|
2035
2096
|
};
|
|
2036
|
-
const layer = (tag, definition) => layer$
|
|
2097
|
+
const layer = (tag, definition) => layer$8(tag, definition.binding, (value) => isWorkflow(value), makeClient(definition));
|
|
2037
2098
|
//#endregion
|
|
2038
2099
|
//#region src/WorkflowDefinition.ts
|
|
2039
2100
|
var WorkflowDefinition_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -2054,7 +2115,7 @@ const make$1 = (id, definition) => Tag$1()(id, definition);
|
|
|
2054
2115
|
const Tag$1 = () => (id, definition) => {
|
|
2055
2116
|
const workflowDefinition = makeDefinition(id, definition);
|
|
2056
2117
|
const tag = Context.Service()(id);
|
|
2057
|
-
const layer$
|
|
2118
|
+
const layer$9 = (binding) => layer(tag, {
|
|
2058
2119
|
...binding,
|
|
2059
2120
|
payload: definition.payload,
|
|
2060
2121
|
result: definition.result
|
|
@@ -2076,7 +2137,7 @@ const Tag$1 = () => (id, definition) => {
|
|
|
2076
2137
|
payload: workflowDefinition.payload,
|
|
2077
2138
|
result: workflowDefinition.result,
|
|
2078
2139
|
make: workflowDefinition.make,
|
|
2079
|
-
layer: layer$
|
|
2140
|
+
layer: layer$9,
|
|
2080
2141
|
create,
|
|
2081
2142
|
createBatch,
|
|
2082
2143
|
get,
|
|
@@ -2167,4 +2228,4 @@ const waitForEvent = (name, options) => Effect.flatMap(WorkflowStep$1.asEffect()
|
|
|
2167
2228
|
const Tag = Tag$1;
|
|
2168
2229
|
const implement = implement$1;
|
|
2169
2230
|
//#endregion
|
|
2170
|
-
export { Binding_exports as Binding, D1_exports as D1, DurableObject_exports as DurableObject, DurableObjectAlarm_exports as DurableObjectAlarm, DurableObjectDefinition_exports as DurableObjectDefinition, DurableObjectNamespace_exports as DurableObjectNamespace, DurableObjectRpcWebSocket_exports as DurableObjectRpcWebSocket, DurableObjectState_exports as DurableObjectState, DurableObjectStorage_exports as DurableObjectStorage, DurableObjectWebSocket_exports as DurableObjectWebSocket, Kv_exports as Kv, Queue_exports as Queue, QueueBinding_exports as QueueBinding, QueueDefinition_exports as QueueDefinition, Rpc_exports as Rpc, RpcDefinition_exports as RpcDefinition, ServiceBinding_exports as ServiceBinding, Worker_exports as Worker, WorkerConfig, WorkerDefinition_exports as WorkerDefinition, WorkerEnvironment, Workflow_exports as Workflow, WorkflowBinding_exports as WorkflowBinding, WorkflowDefinition_exports as WorkflowDefinition };
|
|
2231
|
+
export { Binding_exports as Binding, D1_exports as D1, DurableObject_exports as DurableObject, DurableObjectAlarm_exports as DurableObjectAlarm, DurableObjectDefinition_exports as DurableObjectDefinition, DurableObjectNamespace_exports as DurableObjectNamespace, DurableObjectRpcWebSocket_exports as DurableObjectRpcWebSocket, DurableObjectState_exports as DurableObjectState, DurableObjectStorage_exports as DurableObjectStorage, DurableObjectWebSocket_exports as DurableObjectWebSocket, Hyperdrive_exports as Hyperdrive, Images_exports as Images, Kv_exports as Kv, Queue_exports as Queue, QueueBinding_exports as QueueBinding, QueueDefinition_exports as QueueDefinition, R2_exports as R2, Rpc_exports as Rpc, RpcDefinition_exports as RpcDefinition, ServiceBinding_exports as ServiceBinding, Worker_exports as Worker, WorkerConfig, WorkerDefinition_exports as WorkerDefinition, WorkerEnvironment, Workflow_exports as Workflow, WorkflowBinding_exports as WorkflowBinding, WorkflowDefinition_exports as WorkflowDefinition };
|