apps 0.0.1-beta.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/README.md +191 -0
- package/check-publish.mjs +10 -0
- package/framework-reference.json +1 -0
- package/js/chunk-22WRQZT7.js +389 -0
- package/js/chunk-2OTCEKL2.js +29480 -0
- package/js/chunk-36DNRFZQ.js +34 -0
- package/js/chunk-3ANFZFCV.js +1799 -0
- package/js/chunk-7JXHF5IF.js +138 -0
- package/js/chunk-BCSNKUAC.js +0 -0
- package/js/chunk-BKVL7XAJ.js +47 -0
- package/js/chunk-BPEFS4YF.js +1323 -0
- package/js/chunk-C24KEZXR.js +59 -0
- package/js/chunk-D6BKYP2L.js +877 -0
- package/js/chunk-EP6AEUZO.js +19 -0
- package/js/chunk-HP7E42X6.js +1719 -0
- package/js/chunk-KWTCHVLT.js +284 -0
- package/js/chunk-LOKGDT6B.js +28 -0
- package/js/chunk-MLKGABMK.js +9 -0
- package/js/chunk-OWD2YICM.js +2486 -0
- package/js/chunk-Q2FD5IBM.js +899 -0
- package/js/chunk-R6JMJSVT.js +590 -0
- package/js/chunk-SBKHUC5L.js +56 -0
- package/js/chunk-VFUZI3NY.js +75 -0
- package/js/chunk-W7Q5EOTS.js +4375 -0
- package/js/chunk-WIDTG42X.js +171 -0
- package/js/chunk-X3YBZCJW.js +246 -0
- package/js/chunk-YDR4CPJA.js +2357 -0
- package/js/client.js +1023 -0
- package/js/contracts.js +163 -0
- package/js/effect.js +44 -0
- package/js/graphql.js +392 -0
- package/js/host.js +193 -0
- package/js/index.js +284 -0
- package/js/mcp/effect.js +23 -0
- package/js/mcp/stdio.js +123 -0
- package/js/mcp.js +37 -0
- package/js/openapi.js +246 -0
- package/js/operations/approval.js +9 -0
- package/js/react.js +37 -0
- package/js/storage/facet.js +546 -0
- package/js/ui/auth/contracts.js +19 -0
- package/js/ui/auth.js +28 -0
- package/js/ui/contracts.js +24 -0
- package/js/ui/serving.js +286 -0
- package/package.json +116 -0
- package/runtime.json +1 -0
- package/types/app-data/src/contracts/database.d.ts +193 -0
- package/types/app-data/src/implementation/cursor.d.ts +10 -0
- package/types/app-data/src/implementation/index-key.d.ts +7 -0
- package/types/app-data/src/implementation/promise.d.ts +68 -0
- package/types/app-data/src/implementation/range.d.ts +8 -0
- package/types/app-data/src/implementation/schema.d.ts +33 -0
- package/types/app-data/src/implementation/sqlite.d.ts +11 -0
- package/types/app-data/src/index.d.ts +4 -0
- package/types/apps/src/approval.d.ts +10 -0
- package/types/apps/src/client.d.ts +5 -0
- package/types/apps/src/contracts/app.d.ts +58 -0
- package/types/apps/src/contracts/approval.d.ts +14 -0
- package/types/apps/src/contracts/context.d.ts +25 -0
- package/types/apps/src/contracts/elicitation.d.ts +86 -0
- package/types/apps/src/contracts/graphql.d.ts +102 -0
- package/types/apps/src/contracts/host.d.ts +568 -0
- package/types/apps/src/contracts/http.d.ts +20 -0
- package/types/apps/src/contracts/live.d.ts +26 -0
- package/types/apps/src/contracts/mcp.d.ts +93 -0
- package/types/apps/src/contracts/openapi.d.ts +105 -0
- package/types/apps/src/contracts/operations.d.ts +30 -0
- package/types/apps/src/contracts/optimistic.d.ts +22 -0
- package/types/apps/src/contracts/provider.d.ts +96 -0
- package/types/apps/src/contracts/schedules.d.ts +51 -0
- package/types/apps/src/contracts/schema.d.ts +20 -0
- package/types/apps/src/contracts/storage.d.ts +68 -0
- package/types/apps/src/contracts/tools.d.ts +11 -0
- package/types/apps/src/contracts/ui-auth.d.ts +28 -0
- package/types/apps/src/contracts/ui.d.ts +90 -0
- package/types/apps/src/contracts/webhook-protocol.d.ts +102 -0
- package/types/apps/src/contracts/webhooks.d.ts +53 -0
- package/types/apps/src/contracts/workflows.d.ts +277 -0
- package/types/apps/src/effect.d.ts +10 -0
- package/types/apps/src/facet.d.ts +5 -0
- package/types/apps/src/graphql.d.ts +10 -0
- package/types/apps/src/host.d.ts +16 -0
- package/types/apps/src/implementation/account-operations.d.ts +32 -0
- package/types/apps/src/implementation/app.d.ts +40 -0
- package/types/apps/src/implementation/authoring.d.ts +12 -0
- package/types/apps/src/implementation/elicitation.d.ts +103 -0
- package/types/apps/src/implementation/graphql.d.ts +5 -0
- package/types/apps/src/implementation/host.d.ts +3 -0
- package/types/apps/src/implementation/http.d.ts +5 -0
- package/types/apps/src/implementation/live.d.ts +18 -0
- package/types/apps/src/implementation/mcp-call.d.ts +19 -0
- package/types/apps/src/implementation/mcp-client.d.ts +50 -0
- package/types/apps/src/implementation/mcp-stdio.d.ts +4 -0
- package/types/apps/src/implementation/mcp-tools.d.ts +6 -0
- package/types/apps/src/implementation/mcp.d.ts +4 -0
- package/types/apps/src/implementation/openapi-request.d.ts +11 -0
- package/types/apps/src/implementation/openapi.d.ts +5 -0
- package/types/apps/src/implementation/operations.d.ts +65 -0
- package/types/apps/src/implementation/optimistic.d.ts +30 -0
- package/types/apps/src/implementation/protocol-operations.d.ts +24 -0
- package/types/apps/src/implementation/provider.d.ts +16 -0
- package/types/apps/src/implementation/query-commit.d.ts +10 -0
- package/types/apps/src/implementation/schedules.d.ts +16 -0
- package/types/apps/src/implementation/schema.d.ts +93 -0
- package/types/apps/src/implementation/storage.d.ts +13 -0
- package/types/apps/src/implementation/ui-auth.d.ts +13 -0
- package/types/apps/src/implementation/ui-client.d.ts +16 -0
- package/types/apps/src/implementation/ui-errors.d.ts +2 -0
- package/types/apps/src/implementation/ui-serving.d.ts +16 -0
- package/types/apps/src/implementation/ui-watch.d.ts +2 -0
- package/types/apps/src/implementation/webhooks.d.ts +29 -0
- package/types/apps/src/implementation/workflow-context.d.ts +8 -0
- package/types/apps/src/implementation/workflow-rpc.d.ts +5 -0
- package/types/apps/src/implementation/workflows.d.ts +27 -0
- package/types/apps/src/index.d.ts +58 -0
- package/types/apps/src/mcp-stdio.d.ts +8 -0
- package/types/apps/src/mcp.d.ts +10 -0
- package/types/apps/src/openapi.d.ts +10 -0
- package/types/apps/src/react.d.ts +7 -0
- package/types/apps/src/ui-auth.d.ts +3 -0
- package/types/apps/src/ui-serving.d.ts +3 -0
- package/types/telemetry/src/browser-operations.d.ts +16 -0
- package/types/telemetry/src/browser-performance.d.ts +11 -0
- package/types/telemetry/src/browser-request-timing.d.ts +2 -0
- package/types/telemetry/src/browser.d.ts +27 -0
- package/types/telemetry/src/config.d.ts +83 -0
- package/types/telemetry/src/context.d.ts +14 -0
- package/types/telemetry/src/index.d.ts +9 -0
- package/types/telemetry/src/layer.d.ts +7 -0
- package/types/telemetry/src/measurements.d.ts +8 -0
- package/types/telemetry/src/pending-span.d.ts +7 -0
- package/types/telemetry/src/relay.d.ts +28 -0
- package/types/telemetry/src/span-attributes.d.ts +29 -0
- package/types/telemetry/src/trace-context.d.ts +20 -0
- package/types/telemetry/src/transport.d.ts +6 -0
|
@@ -0,0 +1,4375 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseProto,
|
|
3
|
+
Class,
|
|
4
|
+
Clock,
|
|
5
|
+
CurrentMemoMap,
|
|
6
|
+
CurrentRedactedNames,
|
|
7
|
+
Defect,
|
|
8
|
+
DisablePropagation,
|
|
9
|
+
Done,
|
|
10
|
+
Error as Error2,
|
|
11
|
+
Error2 as Error3,
|
|
12
|
+
FileSystem,
|
|
13
|
+
Int,
|
|
14
|
+
JsonFromUrlParamsField,
|
|
15
|
+
Literals,
|
|
16
|
+
NodeInspectSymbol,
|
|
17
|
+
Path,
|
|
18
|
+
PipeInspectableProto,
|
|
19
|
+
RecordFromUrlParams,
|
|
20
|
+
Reference,
|
|
21
|
+
Scope,
|
|
22
|
+
Service,
|
|
23
|
+
String as String2,
|
|
24
|
+
Struct,
|
|
25
|
+
TaggedError,
|
|
26
|
+
TaggedError2,
|
|
27
|
+
Union,
|
|
28
|
+
addFinalizer2 as addFinalizer,
|
|
29
|
+
andThen,
|
|
30
|
+
append,
|
|
31
|
+
appendAll2 as appendAll,
|
|
32
|
+
as,
|
|
33
|
+
assignProperty,
|
|
34
|
+
badArgument,
|
|
35
|
+
buildWithMemoMap,
|
|
36
|
+
cached,
|
|
37
|
+
catchCause,
|
|
38
|
+
catchCauseFilter,
|
|
39
|
+
catchIf,
|
|
40
|
+
catchTag,
|
|
41
|
+
catchTags,
|
|
42
|
+
catch_,
|
|
43
|
+
close,
|
|
44
|
+
constFalse,
|
|
45
|
+
constTrue,
|
|
46
|
+
constVoid,
|
|
47
|
+
constant,
|
|
48
|
+
context,
|
|
49
|
+
contextWith,
|
|
50
|
+
decodeEffect,
|
|
51
|
+
decodeTo,
|
|
52
|
+
decodeUnknownEffect2 as decodeUnknownEffect,
|
|
53
|
+
delay,
|
|
54
|
+
done,
|
|
55
|
+
dual,
|
|
56
|
+
effect,
|
|
57
|
+
effectContext,
|
|
58
|
+
effectDiscard,
|
|
59
|
+
empty,
|
|
60
|
+
empty2,
|
|
61
|
+
empty4 as empty3,
|
|
62
|
+
empty5 as empty4,
|
|
63
|
+
empty6 as empty5,
|
|
64
|
+
empty7 as empty6,
|
|
65
|
+
encodeText,
|
|
66
|
+
encodeUnknownEffect,
|
|
67
|
+
ensuring,
|
|
68
|
+
ensuring2,
|
|
69
|
+
equals2 as equals,
|
|
70
|
+
expireCookie,
|
|
71
|
+
expireCookieUnsafe,
|
|
72
|
+
externalSpan,
|
|
73
|
+
fail,
|
|
74
|
+
fail3 as fail2,
|
|
75
|
+
fail4 as fail3,
|
|
76
|
+
fail5 as fail4,
|
|
77
|
+
failCause,
|
|
78
|
+
failCause2,
|
|
79
|
+
filterNoDone,
|
|
80
|
+
filterOrElse,
|
|
81
|
+
filterOrFail,
|
|
82
|
+
flatMap2 as flatMap,
|
|
83
|
+
flatMap3 as flatMap2,
|
|
84
|
+
flow,
|
|
85
|
+
fnUntraced,
|
|
86
|
+
forEach,
|
|
87
|
+
forever2 as forever,
|
|
88
|
+
fork,
|
|
89
|
+
forkIn,
|
|
90
|
+
format,
|
|
91
|
+
fromChannel,
|
|
92
|
+
fromInput,
|
|
93
|
+
fromInput2,
|
|
94
|
+
fromInput3,
|
|
95
|
+
fromInputUnsafe,
|
|
96
|
+
fromInputUnsafe2,
|
|
97
|
+
fromIterable,
|
|
98
|
+
fromIterable2,
|
|
99
|
+
fromJsonString,
|
|
100
|
+
fromNullishOr,
|
|
101
|
+
fromPull,
|
|
102
|
+
fromReadableStream,
|
|
103
|
+
fromRecordUnsafe,
|
|
104
|
+
fromResult,
|
|
105
|
+
fromSetCookie,
|
|
106
|
+
fromTransform,
|
|
107
|
+
gen,
|
|
108
|
+
get,
|
|
109
|
+
get3 as get2,
|
|
110
|
+
get4 as get3,
|
|
111
|
+
getCurrent,
|
|
112
|
+
getOrElse,
|
|
113
|
+
getOrUndefined,
|
|
114
|
+
getOrUndefinedUnsafe,
|
|
115
|
+
getUnsafe,
|
|
116
|
+
hasInterrupts,
|
|
117
|
+
hasProperty,
|
|
118
|
+
identity,
|
|
119
|
+
ignore2 as ignore,
|
|
120
|
+
isDoneCause,
|
|
121
|
+
isEffect,
|
|
122
|
+
isEmpty,
|
|
123
|
+
isExit,
|
|
124
|
+
isFailure,
|
|
125
|
+
isNone,
|
|
126
|
+
isOption,
|
|
127
|
+
isReadonlyArrayNonEmpty,
|
|
128
|
+
isRedactedName,
|
|
129
|
+
isSchedule,
|
|
130
|
+
isSome,
|
|
131
|
+
isStream,
|
|
132
|
+
isSuccess,
|
|
133
|
+
isTimeoutError,
|
|
134
|
+
isZero,
|
|
135
|
+
makeUnsafe,
|
|
136
|
+
map3 as map,
|
|
137
|
+
map4 as map2,
|
|
138
|
+
mapEffect,
|
|
139
|
+
mapError,
|
|
140
|
+
mapError2,
|
|
141
|
+
mapError3,
|
|
142
|
+
match,
|
|
143
|
+
matchCauseEffect,
|
|
144
|
+
matchEffect,
|
|
145
|
+
max,
|
|
146
|
+
mebibytes,
|
|
147
|
+
merge,
|
|
148
|
+
merge2,
|
|
149
|
+
merge3,
|
|
150
|
+
millis,
|
|
151
|
+
mkUint8Array,
|
|
152
|
+
mkUint8Array2,
|
|
153
|
+
none,
|
|
154
|
+
onInterrupt,
|
|
155
|
+
optional,
|
|
156
|
+
or,
|
|
157
|
+
parseHeader,
|
|
158
|
+
passthrough,
|
|
159
|
+
pipeArguments,
|
|
160
|
+
pipeThroughChannel,
|
|
161
|
+
provide,
|
|
162
|
+
provide2,
|
|
163
|
+
provideContext2 as provideContext,
|
|
164
|
+
provideMerge,
|
|
165
|
+
redact,
|
|
166
|
+
remove2 as remove,
|
|
167
|
+
remove3 as remove2,
|
|
168
|
+
repeat,
|
|
169
|
+
retry,
|
|
170
|
+
run,
|
|
171
|
+
runForEach,
|
|
172
|
+
runSync,
|
|
173
|
+
seconds,
|
|
174
|
+
set2 as set,
|
|
175
|
+
set3 as set2,
|
|
176
|
+
set4 as set3,
|
|
177
|
+
setAll,
|
|
178
|
+
setAll2,
|
|
179
|
+
setAll3,
|
|
180
|
+
setAllUnsafe,
|
|
181
|
+
setUnsafe,
|
|
182
|
+
sleep,
|
|
183
|
+
some,
|
|
184
|
+
stringOrRedacted,
|
|
185
|
+
succeed,
|
|
186
|
+
succeed4 as succeed2,
|
|
187
|
+
succeed5 as succeed3,
|
|
188
|
+
succeedContext,
|
|
189
|
+
suspend,
|
|
190
|
+
suspend2,
|
|
191
|
+
sync2 as sync,
|
|
192
|
+
tag,
|
|
193
|
+
tap,
|
|
194
|
+
tapError,
|
|
195
|
+
toCodecJson,
|
|
196
|
+
toCookieHeader,
|
|
197
|
+
toReadableStreamWith,
|
|
198
|
+
toSetCookieHeaders,
|
|
199
|
+
toString,
|
|
200
|
+
tryPromise,
|
|
201
|
+
try_,
|
|
202
|
+
try_2,
|
|
203
|
+
uninterruptibleMask,
|
|
204
|
+
unwrap2 as unwrap,
|
|
205
|
+
unwrap3 as unwrap2,
|
|
206
|
+
update,
|
|
207
|
+
updateContext,
|
|
208
|
+
useSpan,
|
|
209
|
+
void_,
|
|
210
|
+
void_2,
|
|
211
|
+
withFiber,
|
|
212
|
+
withParentSpan,
|
|
213
|
+
zero2 as zero
|
|
214
|
+
} from "./chunk-2OTCEKL2.js";
|
|
215
|
+
import {
|
|
216
|
+
__export
|
|
217
|
+
} from "./chunk-MLKGABMK.js";
|
|
218
|
+
|
|
219
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpClientRequest.js
|
|
220
|
+
var HttpClientRequest_exports = {};
|
|
221
|
+
__export(HttpClientRequest_exports, {
|
|
222
|
+
accept: () => accept,
|
|
223
|
+
acceptJson: () => acceptJson,
|
|
224
|
+
appendUrl: () => appendUrl,
|
|
225
|
+
appendUrlParam: () => appendUrlParam,
|
|
226
|
+
appendUrlParams: () => appendUrlParams,
|
|
227
|
+
basicAuth: () => basicAuth,
|
|
228
|
+
bearerToken: () => bearerToken,
|
|
229
|
+
bodyFile: () => bodyFile,
|
|
230
|
+
bodyFormData: () => bodyFormData,
|
|
231
|
+
bodyFormDataRecord: () => bodyFormDataRecord,
|
|
232
|
+
bodyJson: () => bodyJson,
|
|
233
|
+
bodyJsonUnsafe: () => bodyJsonUnsafe,
|
|
234
|
+
bodyStream: () => bodyStream,
|
|
235
|
+
bodyText: () => bodyText,
|
|
236
|
+
bodyUint8Array: () => bodyUint8Array,
|
|
237
|
+
bodyUrlParams: () => bodyUrlParams,
|
|
238
|
+
delete: () => del,
|
|
239
|
+
empty: () => empty8,
|
|
240
|
+
fromWeb: () => fromWeb,
|
|
241
|
+
get: () => get4,
|
|
242
|
+
head: () => head,
|
|
243
|
+
isHttpClientRequest: () => isHttpClientRequest,
|
|
244
|
+
make: () => make2,
|
|
245
|
+
makeWith: () => makeWith,
|
|
246
|
+
modify: () => modify,
|
|
247
|
+
options: () => options,
|
|
248
|
+
patch: () => patch,
|
|
249
|
+
post: () => post,
|
|
250
|
+
prependUrl: () => prependUrl,
|
|
251
|
+
put: () => put,
|
|
252
|
+
query: () => query,
|
|
253
|
+
removeHash: () => removeHash,
|
|
254
|
+
removeHeader: () => removeHeader,
|
|
255
|
+
schemaBodyJson: () => schemaBodyJson,
|
|
256
|
+
setBody: () => setBody,
|
|
257
|
+
setHash: () => setHash,
|
|
258
|
+
setHeader: () => setHeader,
|
|
259
|
+
setHeaders: () => setHeaders,
|
|
260
|
+
setMethod: () => setMethod,
|
|
261
|
+
setUrl: () => setUrl,
|
|
262
|
+
setUrlParam: () => setUrlParam,
|
|
263
|
+
setUrlParams: () => setUrlParams,
|
|
264
|
+
toUrl: () => toUrl,
|
|
265
|
+
toWeb: () => toWeb,
|
|
266
|
+
toWebResult: () => toWebResult,
|
|
267
|
+
trace: () => trace,
|
|
268
|
+
updateHeaders: () => updateHeaders2,
|
|
269
|
+
updateUrl: () => updateUrl
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpBody.js
|
|
273
|
+
var HttpBody_exports = {};
|
|
274
|
+
__export(HttpBody_exports, {
|
|
275
|
+
Empty: () => Empty,
|
|
276
|
+
FormData: () => FormData2,
|
|
277
|
+
HttpBodyError: () => HttpBodyError,
|
|
278
|
+
Raw: () => Raw,
|
|
279
|
+
Stream: () => Stream,
|
|
280
|
+
Uint8Array: () => Uint8Array2,
|
|
281
|
+
empty: () => empty7,
|
|
282
|
+
file: () => file,
|
|
283
|
+
fileFromInfo: () => fileFromInfo,
|
|
284
|
+
formData: () => formData,
|
|
285
|
+
formDataRecord: () => formDataRecord,
|
|
286
|
+
isHttpBody: () => isHttpBody,
|
|
287
|
+
json: () => json,
|
|
288
|
+
jsonSchema: () => jsonSchema,
|
|
289
|
+
jsonUnsafe: () => jsonUnsafe,
|
|
290
|
+
raw: () => raw,
|
|
291
|
+
stream: () => stream,
|
|
292
|
+
text: () => text,
|
|
293
|
+
uint8Array: () => uint8Array,
|
|
294
|
+
urlParams: () => urlParams
|
|
295
|
+
});
|
|
296
|
+
var TypeId = "~effect/http/HttpBody";
|
|
297
|
+
var isHttpBody = (u) => hasProperty(u, TypeId);
|
|
298
|
+
var HttpBodyErrorTypeId = "~effect/http/HttpBody/HttpBodyError";
|
|
299
|
+
var HttpBodyError = class extends (/* @__PURE__ */ TaggedError("HttpBodyError")) {
|
|
300
|
+
/**
|
|
301
|
+
* Marks this value as an HTTP body error for runtime guards.
|
|
302
|
+
*
|
|
303
|
+
* @since 4.0.0
|
|
304
|
+
*/
|
|
305
|
+
[HttpBodyErrorTypeId] = HttpBodyErrorTypeId;
|
|
306
|
+
};
|
|
307
|
+
var Proto = class {
|
|
308
|
+
[TypeId];
|
|
309
|
+
constructor() {
|
|
310
|
+
this[TypeId] = TypeId;
|
|
311
|
+
}
|
|
312
|
+
[NodeInspectSymbol]() {
|
|
313
|
+
return this.toJSON();
|
|
314
|
+
}
|
|
315
|
+
toString() {
|
|
316
|
+
return format(this, {
|
|
317
|
+
ignoreToString: true
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
var Empty = class extends Proto {
|
|
322
|
+
_tag = "Empty";
|
|
323
|
+
toJSON() {
|
|
324
|
+
return {
|
|
325
|
+
_id: "effect/HttpBody",
|
|
326
|
+
_tag: "Empty"
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
var empty7 = /* @__PURE__ */ new Empty();
|
|
331
|
+
var Raw = class extends Proto {
|
|
332
|
+
_tag = "Raw";
|
|
333
|
+
body;
|
|
334
|
+
contentType;
|
|
335
|
+
contentLength;
|
|
336
|
+
constructor(body, contentType, contentLength) {
|
|
337
|
+
super();
|
|
338
|
+
this.body = body;
|
|
339
|
+
this.contentType = contentType;
|
|
340
|
+
this.contentLength = contentLength;
|
|
341
|
+
}
|
|
342
|
+
toJSON() {
|
|
343
|
+
return {
|
|
344
|
+
_id: "effect/HttpBody",
|
|
345
|
+
_tag: "Raw",
|
|
346
|
+
body: this.body,
|
|
347
|
+
contentType: this.contentType,
|
|
348
|
+
contentLength: this.contentLength
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
var raw = (body, options3) => new Raw(body, options3?.contentType, options3?.contentLength);
|
|
353
|
+
var Uint8Array2 = class extends Proto {
|
|
354
|
+
_tag = "Uint8Array";
|
|
355
|
+
contentType;
|
|
356
|
+
contentLength;
|
|
357
|
+
/** Original text retained for adapters that can skip encoding. */
|
|
358
|
+
text;
|
|
359
|
+
_body;
|
|
360
|
+
constructor(body, contentType, contentLength, text3) {
|
|
361
|
+
super();
|
|
362
|
+
this._body = body;
|
|
363
|
+
this.text = text3;
|
|
364
|
+
this.contentType = contentType;
|
|
365
|
+
this.contentLength = contentLength;
|
|
366
|
+
}
|
|
367
|
+
get body() {
|
|
368
|
+
return this._body ??= encodeText2(this.text);
|
|
369
|
+
}
|
|
370
|
+
toJSON() {
|
|
371
|
+
const toString2 = this.contentType.startsWith("text/") || this.contentType.endsWith("json");
|
|
372
|
+
return {
|
|
373
|
+
_id: "effect/HttpBody",
|
|
374
|
+
_tag: "Uint8Array",
|
|
375
|
+
body: toString2 ? new TextDecoder().decode(this.body) : `Uint8Array(${this.body.length})`,
|
|
376
|
+
contentType: this.contentType,
|
|
377
|
+
contentLength: this.contentLength
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
var uint8Array = (body, contentType) => new Uint8Array2(body, contentType ?? "application/octet-stream", body.length);
|
|
382
|
+
var encoder = /* @__PURE__ */ new TextEncoder();
|
|
383
|
+
var buffer = globalThis.Buffer;
|
|
384
|
+
var encodeText2 = buffer !== void 0 ? (body) => buffer.from(body, "utf8") : (body) => encoder.encode(body);
|
|
385
|
+
var text = (body, contentType) => {
|
|
386
|
+
if (typeof body !== "string") {
|
|
387
|
+
body = body === void 0 ? "" : String(body);
|
|
388
|
+
}
|
|
389
|
+
if (buffer !== void 0) {
|
|
390
|
+
return new Uint8Array2(void 0, contentType ?? "text/plain", buffer.byteLength(body, "utf8"), body);
|
|
391
|
+
}
|
|
392
|
+
const bytes = encoder.encode(body);
|
|
393
|
+
return new Uint8Array2(bytes, contentType ?? "text/plain", bytes.length, body);
|
|
394
|
+
};
|
|
395
|
+
var jsonUnsafe = (body, contentType) => text(JSON.stringify(body), contentType ?? "application/json");
|
|
396
|
+
var json = (body, contentType) => try_2({
|
|
397
|
+
try: () => text(JSON.stringify(body), contentType ?? "application/json"),
|
|
398
|
+
catch: (cause) => new HttpBodyError({
|
|
399
|
+
reason: {
|
|
400
|
+
_tag: "JsonError"
|
|
401
|
+
},
|
|
402
|
+
cause
|
|
403
|
+
})
|
|
404
|
+
});
|
|
405
|
+
var jsonSchema = (schema, options3) => {
|
|
406
|
+
const encode = encodeUnknownEffect(toCodecJson(schema));
|
|
407
|
+
return (body, contentType) => encode(body, options3).pipe(mapError((issue) => new HttpBodyError({
|
|
408
|
+
reason: {
|
|
409
|
+
_tag: "SchemaError",
|
|
410
|
+
issue
|
|
411
|
+
},
|
|
412
|
+
cause: issue
|
|
413
|
+
})), flatMap((body2) => json(body2, contentType)));
|
|
414
|
+
};
|
|
415
|
+
var urlParams = (urlParams3, contentType) => text(toString(fromInput3(urlParams3)), contentType ?? "application/x-www-form-urlencoded");
|
|
416
|
+
var FormData2 = class extends Proto {
|
|
417
|
+
_tag = "FormData";
|
|
418
|
+
contentType = void 0;
|
|
419
|
+
contentLength = void 0;
|
|
420
|
+
formData;
|
|
421
|
+
constructor(formData3) {
|
|
422
|
+
super();
|
|
423
|
+
this.formData = formData3;
|
|
424
|
+
}
|
|
425
|
+
toJSON() {
|
|
426
|
+
return {
|
|
427
|
+
_id: "effect/HttpBody",
|
|
428
|
+
_tag: "FormData",
|
|
429
|
+
formData: this.formData
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
var formData = (body) => new FormData2(body);
|
|
434
|
+
var appendFormDataValue = (formData3, key, value) => {
|
|
435
|
+
if (value == null) {
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
if (typeof value === "object") {
|
|
439
|
+
formData3.append(key, value);
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
formData3.append(key, String(value));
|
|
443
|
+
};
|
|
444
|
+
var formDataRecord = (entries) => {
|
|
445
|
+
const data = new globalThis.FormData();
|
|
446
|
+
for (const [key, value] of Object.entries(entries)) {
|
|
447
|
+
if (Array.isArray(value)) {
|
|
448
|
+
for (const item of value) {
|
|
449
|
+
appendFormDataValue(data, key, item);
|
|
450
|
+
}
|
|
451
|
+
} else {
|
|
452
|
+
appendFormDataValue(data, key, value);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return formData(data);
|
|
456
|
+
};
|
|
457
|
+
var Stream = class extends Proto {
|
|
458
|
+
_tag = "Stream";
|
|
459
|
+
stream;
|
|
460
|
+
contentType;
|
|
461
|
+
contentLength;
|
|
462
|
+
constructor(stream4, contentType, contentLength) {
|
|
463
|
+
super();
|
|
464
|
+
this.stream = stream4;
|
|
465
|
+
this.contentType = contentType;
|
|
466
|
+
this.contentLength = contentLength;
|
|
467
|
+
}
|
|
468
|
+
toJSON() {
|
|
469
|
+
return {
|
|
470
|
+
_id: "effect/HttpBody",
|
|
471
|
+
_tag: "Stream",
|
|
472
|
+
contentType: this.contentType,
|
|
473
|
+
contentLength: this.contentLength
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
var stream = (body, contentType, contentLength) => new Stream(body, contentType ?? "application/octet-stream", contentLength);
|
|
478
|
+
var fileRangeSize = (input, field, method) => {
|
|
479
|
+
const size = fromInput(input);
|
|
480
|
+
return isSome(size) ? succeed2(size.value) : fail3(badArgument({
|
|
481
|
+
module: "HttpBody",
|
|
482
|
+
method,
|
|
483
|
+
description: `Invalid ${field}: ${input}`
|
|
484
|
+
}));
|
|
485
|
+
};
|
|
486
|
+
var fileContentLength = /* @__PURE__ */ fnUntraced(function* (size, method, options3) {
|
|
487
|
+
const offset = options3?.offset === void 0 ? zero : yield* fileRangeSize(options3.offset, "offset", method);
|
|
488
|
+
const bytesToRead = options3?.bytesToRead === void 0 ? void 0 : yield* fileRangeSize(options3.bytesToRead, "bytesToRead", method);
|
|
489
|
+
const available = offset >= size ? BigInt("0") : size - offset;
|
|
490
|
+
const length = bytesToRead === void 0 || bytesToRead > available ? available : bytesToRead;
|
|
491
|
+
if (length > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
492
|
+
return yield* fail3(badArgument({
|
|
493
|
+
module: "HttpBody",
|
|
494
|
+
method,
|
|
495
|
+
description: `Content length exceeds Number.MAX_SAFE_INTEGER: ${length}`
|
|
496
|
+
}));
|
|
497
|
+
}
|
|
498
|
+
return Number(length);
|
|
499
|
+
});
|
|
500
|
+
var file = (path, options3) => flatMap(FileSystem, (fs) => flatMap(fs.stat(path), (info) => map(fileContentLength(info.size, "file", options3), (contentLength) => stream(fs.stream(path, options3), options3?.contentType, contentLength))));
|
|
501
|
+
var fileFromInfo = (path, info, options3) => flatMap(FileSystem, (fs) => map(fileContentLength(info.size, "fileFromInfo", options3), (contentLength) => stream(fs.stream(path, options3), options3?.contentType, contentLength)));
|
|
502
|
+
|
|
503
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpMethod.js
|
|
504
|
+
var hasBody = (method) => method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE";
|
|
505
|
+
var allShort = [["GET", "get"], ["POST", "post"], ["PUT", "put"], ["DELETE", "del"], ["PATCH", "patch"], ["HEAD", "head"], ["OPTIONS", "options"], ["TRACE", "trace"], ["QUERY", "query"]];
|
|
506
|
+
|
|
507
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/internal/httpBody.js
|
|
508
|
+
var updateHeaders = (headers, body) => {
|
|
509
|
+
if (body._tag === "Empty" || body._tag === "FormData") {
|
|
510
|
+
return remove2(remove2(headers, "content-type"), "content-length");
|
|
511
|
+
}
|
|
512
|
+
headers = body.contentType === void 0 ? remove2(headers, "content-type") : set2(headers, "content-type", body.contentType);
|
|
513
|
+
return body.contentLength === void 0 ? remove2(headers, "content-length") : set2(headers, "content-length", body.contentLength.toString());
|
|
514
|
+
};
|
|
515
|
+
var parseContentLength = (contentLength) => {
|
|
516
|
+
if (contentLength === null || contentLength === void 0 || !/^\d+$/.test(contentLength)) {
|
|
517
|
+
return void 0;
|
|
518
|
+
}
|
|
519
|
+
const parsed = Number(contentLength);
|
|
520
|
+
return Number.isSafeInteger(parsed) ? parsed : void 0;
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/Url.js
|
|
524
|
+
var UrlError = class extends (/* @__PURE__ */ TaggedError("UrlError")) {
|
|
525
|
+
};
|
|
526
|
+
var make = (url, params, hash) => try_({
|
|
527
|
+
try: () => {
|
|
528
|
+
const urlInstance = new URL(url, baseUrl());
|
|
529
|
+
for (let i = 0; i < params.params.length; i++) {
|
|
530
|
+
const [key, value] = params.params[i];
|
|
531
|
+
if (value !== void 0) {
|
|
532
|
+
urlInstance.searchParams.append(key, value);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
if (hash !== void 0) {
|
|
536
|
+
urlInstance.hash = hash;
|
|
537
|
+
}
|
|
538
|
+
return urlInstance;
|
|
539
|
+
},
|
|
540
|
+
catch: (cause) => new UrlError({
|
|
541
|
+
cause
|
|
542
|
+
})
|
|
543
|
+
});
|
|
544
|
+
var baseUrl = () => {
|
|
545
|
+
if ("location" in globalThis && globalThis.location !== void 0 && globalThis.location.origin !== void 0 && globalThis.location.pathname !== void 0) {
|
|
546
|
+
return location.origin + location.pathname;
|
|
547
|
+
}
|
|
548
|
+
return void 0;
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpClientRequest.js
|
|
552
|
+
var TypeId2 = "~effect/http/HttpClientRequest";
|
|
553
|
+
var isHttpClientRequest = (u) => hasProperty(u, TypeId2);
|
|
554
|
+
var Proto2 = {
|
|
555
|
+
[TypeId2]: TypeId2,
|
|
556
|
+
...BaseProto,
|
|
557
|
+
toJSON() {
|
|
558
|
+
return {
|
|
559
|
+
_id: "HttpClientRequest",
|
|
560
|
+
method: this.method,
|
|
561
|
+
url: this.url,
|
|
562
|
+
urlParams: this.urlParams,
|
|
563
|
+
hash: this.hash,
|
|
564
|
+
headers: redact(this.headers),
|
|
565
|
+
body: this.body.toJSON()
|
|
566
|
+
};
|
|
567
|
+
},
|
|
568
|
+
pipe() {
|
|
569
|
+
return pipeArguments(this, arguments);
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
function makeWith(method, url, urlParams3, hash, headers, body) {
|
|
573
|
+
const self = Object.create(Proto2);
|
|
574
|
+
self.method = method;
|
|
575
|
+
self.url = url;
|
|
576
|
+
self.urlParams = urlParams3;
|
|
577
|
+
self.hash = hash;
|
|
578
|
+
self.headers = headers;
|
|
579
|
+
self.body = body;
|
|
580
|
+
return self;
|
|
581
|
+
}
|
|
582
|
+
var empty8 = /* @__PURE__ */ makeWith("GET", "", empty5, /* @__PURE__ */ none(), empty4, empty7);
|
|
583
|
+
var make2 = (method) => (url, options3) => modify(empty8, {
|
|
584
|
+
method,
|
|
585
|
+
url,
|
|
586
|
+
...options3 ?? void 0
|
|
587
|
+
});
|
|
588
|
+
var get4 = /* @__PURE__ */ make2("GET");
|
|
589
|
+
var query = /* @__PURE__ */ make2("QUERY");
|
|
590
|
+
var post = /* @__PURE__ */ make2("POST");
|
|
591
|
+
var patch = /* @__PURE__ */ make2("PATCH");
|
|
592
|
+
var put = /* @__PURE__ */ make2("PUT");
|
|
593
|
+
var del = /* @__PURE__ */ make2("DELETE");
|
|
594
|
+
var head = /* @__PURE__ */ make2("HEAD");
|
|
595
|
+
var options = /* @__PURE__ */ make2("OPTIONS");
|
|
596
|
+
var trace = /* @__PURE__ */ make2("TRACE");
|
|
597
|
+
var modify = /* @__PURE__ */ dual(2, (self, options3) => {
|
|
598
|
+
let result = self;
|
|
599
|
+
if (options3.method) {
|
|
600
|
+
result = setMethod(result, options3.method);
|
|
601
|
+
}
|
|
602
|
+
if (options3.url) {
|
|
603
|
+
result = setUrl(result, options3.url);
|
|
604
|
+
}
|
|
605
|
+
if (options3.headers) {
|
|
606
|
+
result = setHeaders(result, options3.headers);
|
|
607
|
+
}
|
|
608
|
+
if (options3.urlParams) {
|
|
609
|
+
result = setUrlParams(result, options3.urlParams);
|
|
610
|
+
}
|
|
611
|
+
if (options3.hash) {
|
|
612
|
+
result = setHash(result, options3.hash);
|
|
613
|
+
}
|
|
614
|
+
if (options3.body) {
|
|
615
|
+
result = setBody(result, options3.body);
|
|
616
|
+
}
|
|
617
|
+
if (options3.accept) {
|
|
618
|
+
result = accept(result, options3.accept);
|
|
619
|
+
}
|
|
620
|
+
if (options3.acceptJson) {
|
|
621
|
+
result = acceptJson(result);
|
|
622
|
+
}
|
|
623
|
+
return result;
|
|
624
|
+
});
|
|
625
|
+
var setMethod = /* @__PURE__ */ dual(2, (self, method) => makeWith(method, self.url, self.urlParams, self.hash, self.headers, self.body));
|
|
626
|
+
var setHeader = /* @__PURE__ */ dual(3, (self, key, value) => makeWith(self.method, self.url, self.urlParams, self.hash, set2(self.headers, key, value), self.body));
|
|
627
|
+
var setHeaders = /* @__PURE__ */ dual(2, (self, input) => makeWith(self.method, self.url, self.urlParams, self.hash, setAll2(self.headers, input), self.body));
|
|
628
|
+
var updateHeaders2 = /* @__PURE__ */ dual(2, (self, f) => makeWith(self.method, self.url, self.urlParams, self.hash, f(self.headers), self.body));
|
|
629
|
+
var removeHeader = /* @__PURE__ */ dual(2, (self, key) => updateHeaders2(self, remove2(key)));
|
|
630
|
+
var basicAuth = /* @__PURE__ */ dual(3, (self, username, password) => setHeader(self, "Authorization", `Basic ${btoa(`${stringOrRedacted(username)}:${stringOrRedacted(password)}`)}`));
|
|
631
|
+
var bearerToken = /* @__PURE__ */ dual(2, (self, token) => setHeader(self, "Authorization", `Bearer ${stringOrRedacted(token)}`));
|
|
632
|
+
var accept = /* @__PURE__ */ dual(2, (self, mediaType) => setHeader(self, "Accept", mediaType));
|
|
633
|
+
var acceptJson = /* @__PURE__ */ accept("application/json");
|
|
634
|
+
var setUrl = /* @__PURE__ */ dual(2, (self, url) => {
|
|
635
|
+
if (typeof url === "string") {
|
|
636
|
+
return makeWith(self.method, url, self.urlParams, self.hash, self.headers, self.body);
|
|
637
|
+
}
|
|
638
|
+
const clone = new URL(url.toString());
|
|
639
|
+
const urlParams3 = fromInput3(clone.searchParams);
|
|
640
|
+
const hash = fromNullishOr(clone.hash === "" ? void 0 : clone.hash.slice(1));
|
|
641
|
+
clone.search = "";
|
|
642
|
+
clone.hash = "";
|
|
643
|
+
return makeWith(self.method, clone.toString(), urlParams3, hash, self.headers, self.body);
|
|
644
|
+
});
|
|
645
|
+
var prependUrl = /* @__PURE__ */ dual(2, (self, path) => {
|
|
646
|
+
if (path === "") return self;
|
|
647
|
+
return makeWith(self.method, joinSegments(path, self.url), self.urlParams, self.hash, self.headers, self.body);
|
|
648
|
+
});
|
|
649
|
+
var appendUrl = /* @__PURE__ */ dual(2, (self, path) => {
|
|
650
|
+
if (path === "") return self;
|
|
651
|
+
return makeWith(self.method, joinSegments(self.url, path), self.urlParams, self.hash, self.headers, self.body);
|
|
652
|
+
});
|
|
653
|
+
var joinSegments = (first, second) => {
|
|
654
|
+
const endsWithSlash = first.endsWith("/");
|
|
655
|
+
const startsWithSlash = second.startsWith("/");
|
|
656
|
+
const needsTrim = endsWithSlash && startsWithSlash;
|
|
657
|
+
const needsSlash = !endsWithSlash && !startsWithSlash;
|
|
658
|
+
return needsTrim ? first + second.slice(1) : needsSlash ? first + "/" + second : first + second;
|
|
659
|
+
};
|
|
660
|
+
var updateUrl = /* @__PURE__ */ dual(2, (self, f) => makeWith(self.method, f(self.url), self.urlParams, self.hash, self.headers, self.body));
|
|
661
|
+
var setUrlParam = /* @__PURE__ */ dual(3, (self, key, value) => makeWith(self.method, self.url, set3(self.urlParams, key, value), self.hash, self.headers, self.body));
|
|
662
|
+
var setUrlParams = /* @__PURE__ */ dual(2, (self, input) => makeWith(self.method, self.url, setAll3(self.urlParams, input), self.hash, self.headers, self.body));
|
|
663
|
+
var appendUrlParam = /* @__PURE__ */ dual(3, (self, key, value) => makeWith(self.method, self.url, append(self.urlParams, key, value), self.hash, self.headers, self.body));
|
|
664
|
+
var appendUrlParams = /* @__PURE__ */ dual(2, (self, input) => makeWith(self.method, self.url, appendAll(self.urlParams, input), self.hash, self.headers, self.body));
|
|
665
|
+
var setHash = /* @__PURE__ */ dual(2, (self, hash) => makeWith(self.method, self.url, self.urlParams, some(hash), self.headers, self.body));
|
|
666
|
+
var removeHash = (self) => makeWith(self.method, self.url, self.urlParams, none(), self.headers, self.body);
|
|
667
|
+
var setBody = /* @__PURE__ */ dual(2, (self, body) => {
|
|
668
|
+
return makeWith(self.method, self.url, self.urlParams, self.hash, updateHeaders(self.headers, body), body);
|
|
669
|
+
});
|
|
670
|
+
var bodyUint8Array = /* @__PURE__ */ dual((args) => isHttpClientRequest(args[0]), (self, body, contentType) => setBody(self, uint8Array(body, contentType)));
|
|
671
|
+
var bodyText = /* @__PURE__ */ dual((args) => isHttpClientRequest(args[0]), (self, body, contentType) => setBody(self, text(body, contentType)));
|
|
672
|
+
var bodyJson = /* @__PURE__ */ dual(2, (self, body) => map(json(body), (body2) => setBody(self, body2)));
|
|
673
|
+
var bodyJsonUnsafe = /* @__PURE__ */ dual(2, (self, body) => setBody(self, jsonUnsafe(body)));
|
|
674
|
+
var schemaBodyJson = (schema, options3) => {
|
|
675
|
+
const encode = jsonSchema(schema, options3);
|
|
676
|
+
return dual(2, (self, body) => map(encode(body), (body2) => setBody(self, body2)));
|
|
677
|
+
};
|
|
678
|
+
var bodyUrlParams = /* @__PURE__ */ dual(2, (self, input) => setBody(self, urlParams(fromInput3(input))));
|
|
679
|
+
var bodyFormData = /* @__PURE__ */ dual(2, (self, body) => setBody(self, formData(body)));
|
|
680
|
+
var bodyFormDataRecord = /* @__PURE__ */ dual(2, (self, entries) => setBody(self, formDataRecord(entries)));
|
|
681
|
+
var bodyStream = /* @__PURE__ */ dual((args) => isHttpClientRequest(args[0]), (self, body, options3) => setBody(self, stream(body, options3?.contentType, options3?.contentLength)));
|
|
682
|
+
var bodyFile = /* @__PURE__ */ dual((args) => isHttpClientRequest(args[0]), (self, path, options3) => map(file(path, options3), (body) => setBody(self, body)));
|
|
683
|
+
function toUrl(self) {
|
|
684
|
+
const r = make(self.url, self.urlParams, getOrUndefined(self.hash));
|
|
685
|
+
if (isSuccess(r)) {
|
|
686
|
+
return some(r.success);
|
|
687
|
+
}
|
|
688
|
+
return none();
|
|
689
|
+
}
|
|
690
|
+
var fromWeb = (request) => {
|
|
691
|
+
const method = request.method.toUpperCase();
|
|
692
|
+
return modify(empty8, {
|
|
693
|
+
method,
|
|
694
|
+
url: new URL(request.url),
|
|
695
|
+
headers: request.headers,
|
|
696
|
+
body: fromWebBody(request, method)
|
|
697
|
+
});
|
|
698
|
+
};
|
|
699
|
+
var fromWebBody = (request, method) => {
|
|
700
|
+
if (!hasBody(method) || request.body === null) {
|
|
701
|
+
return empty7;
|
|
702
|
+
}
|
|
703
|
+
return raw(request.body, {
|
|
704
|
+
contentType: request.headers.get("content-type") ?? void 0,
|
|
705
|
+
contentLength: parseContentLength(request.headers.get("content-length"))
|
|
706
|
+
});
|
|
707
|
+
};
|
|
708
|
+
var toWebResult = (self, options3) => {
|
|
709
|
+
const url = make(self.url, self.urlParams, getOrUndefined(self.hash));
|
|
710
|
+
if (isFailure(url)) {
|
|
711
|
+
return fail(url.failure);
|
|
712
|
+
}
|
|
713
|
+
const requestInit = {
|
|
714
|
+
method: self.method,
|
|
715
|
+
headers: self.headers
|
|
716
|
+
};
|
|
717
|
+
if (options3?.signal) {
|
|
718
|
+
requestInit.signal = options3.signal;
|
|
719
|
+
}
|
|
720
|
+
if (hasBody(self.method)) {
|
|
721
|
+
switch (self.body._tag) {
|
|
722
|
+
case "Empty": {
|
|
723
|
+
break;
|
|
724
|
+
}
|
|
725
|
+
case "Raw": {
|
|
726
|
+
requestInit.body = self.body.body;
|
|
727
|
+
if (isReadableStream(self.body.body)) {
|
|
728
|
+
;
|
|
729
|
+
requestInit.duplex = "half";
|
|
730
|
+
}
|
|
731
|
+
break;
|
|
732
|
+
}
|
|
733
|
+
case "Uint8Array": {
|
|
734
|
+
requestInit.body = self.body.body;
|
|
735
|
+
break;
|
|
736
|
+
}
|
|
737
|
+
case "FormData": {
|
|
738
|
+
requestInit.body = self.body.formData;
|
|
739
|
+
break;
|
|
740
|
+
}
|
|
741
|
+
case "Stream": {
|
|
742
|
+
requestInit.body = toReadableStreamWith(self.body.stream, options3?.context ?? empty2());
|
|
743
|
+
requestInit.duplex = "half";
|
|
744
|
+
break;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
return try_({
|
|
749
|
+
try: () => new Request(url.success, requestInit),
|
|
750
|
+
catch: (cause) => new UrlError({
|
|
751
|
+
cause
|
|
752
|
+
})
|
|
753
|
+
});
|
|
754
|
+
};
|
|
755
|
+
var isReadableStream = (u) => typeof ReadableStream !== "undefined" && u instanceof ReadableStream;
|
|
756
|
+
var toWeb = (self, options3) => contextWith((context2) => fromResult(toWebResult(self, {
|
|
757
|
+
context: context2,
|
|
758
|
+
signal: options3?.signal
|
|
759
|
+
})));
|
|
760
|
+
|
|
761
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpClient.js
|
|
762
|
+
var HttpClient_exports = {};
|
|
763
|
+
__export(HttpClient_exports, {
|
|
764
|
+
HttpClient: () => HttpClient,
|
|
765
|
+
SpanNameGenerator: () => SpanNameGenerator,
|
|
766
|
+
TracerDisabledWhen: () => TracerDisabledWhen,
|
|
767
|
+
TracerHeaderFilter: () => TracerHeaderFilter,
|
|
768
|
+
TracerPropagationEnabled: () => TracerPropagationEnabled,
|
|
769
|
+
catch: () => catch_2,
|
|
770
|
+
catchTag: () => catchTag2,
|
|
771
|
+
catchTags: () => catchTags2,
|
|
772
|
+
del: () => del2,
|
|
773
|
+
execute: () => execute,
|
|
774
|
+
filterOrElse: () => filterOrElse2,
|
|
775
|
+
filterOrFail: () => filterOrFail2,
|
|
776
|
+
filterStatus: () => filterStatus2,
|
|
777
|
+
filterStatusOk: () => filterStatusOk2,
|
|
778
|
+
followRedirects: () => followRedirects,
|
|
779
|
+
get: () => get5,
|
|
780
|
+
head: () => head2,
|
|
781
|
+
isHttpClient: () => isHttpClient,
|
|
782
|
+
layerMergedContext: () => layerMergedContext,
|
|
783
|
+
make: () => make3,
|
|
784
|
+
makeWith: () => makeWith2,
|
|
785
|
+
mapRequest: () => mapRequest,
|
|
786
|
+
mapRequestEffect: () => mapRequestEffect,
|
|
787
|
+
mapRequestInput: () => mapRequestInput,
|
|
788
|
+
mapRequestInputEffect: () => mapRequestInputEffect,
|
|
789
|
+
options: () => options2,
|
|
790
|
+
patch: () => patch2,
|
|
791
|
+
post: () => post2,
|
|
792
|
+
put: () => put2,
|
|
793
|
+
query: () => query2,
|
|
794
|
+
retry: () => retry2,
|
|
795
|
+
retryTransient: () => retryTransient,
|
|
796
|
+
tap: () => tap2,
|
|
797
|
+
tapError: () => tapError2,
|
|
798
|
+
tapRequest: () => tapRequest,
|
|
799
|
+
transform: () => transform,
|
|
800
|
+
transformResponse: () => transformResponse,
|
|
801
|
+
withCookiesRef: () => withCookiesRef,
|
|
802
|
+
withRateLimiter: () => withRateLimiter,
|
|
803
|
+
withScope: () => withScope
|
|
804
|
+
});
|
|
805
|
+
|
|
806
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpClientError.js
|
|
807
|
+
var HttpClientError_exports = {};
|
|
808
|
+
__export(HttpClientError_exports, {
|
|
809
|
+
DecodeError: () => DecodeError,
|
|
810
|
+
EmptyBodyError: () => EmptyBodyError,
|
|
811
|
+
EncodeError: () => EncodeError,
|
|
812
|
+
HttpClientError: () => HttpClientError,
|
|
813
|
+
HttpClientErrorSchema: () => HttpClientErrorSchema,
|
|
814
|
+
InvalidUrlError: () => InvalidUrlError,
|
|
815
|
+
StatusCodeError: () => StatusCodeError,
|
|
816
|
+
TransportError: () => TransportError,
|
|
817
|
+
isHttpClientError: () => isHttpClientError
|
|
818
|
+
});
|
|
819
|
+
var TypeId3 = "~effect/http/HttpClientError";
|
|
820
|
+
var isHttpClientError = (u) => hasProperty(u, TypeId3);
|
|
821
|
+
var HttpClientError = class extends (/* @__PURE__ */ TaggedError("HttpClientError")) {
|
|
822
|
+
constructor(props) {
|
|
823
|
+
if ("cause" in props.reason) {
|
|
824
|
+
super({
|
|
825
|
+
...props,
|
|
826
|
+
cause: props.reason.cause
|
|
827
|
+
});
|
|
828
|
+
} else {
|
|
829
|
+
super(props);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Marks this value as an HTTP client error for runtime guards.
|
|
834
|
+
*
|
|
835
|
+
* @since 4.0.0
|
|
836
|
+
*/
|
|
837
|
+
[TypeId3] = TypeId3;
|
|
838
|
+
/**
|
|
839
|
+
* HTTP request associated with the client failure.
|
|
840
|
+
*
|
|
841
|
+
* @since 4.0.0
|
|
842
|
+
*/
|
|
843
|
+
get request() {
|
|
844
|
+
return this.reason.request;
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* HTTP response associated with the client failure, when one was received.
|
|
848
|
+
*
|
|
849
|
+
* @since 4.0.0
|
|
850
|
+
*/
|
|
851
|
+
get response() {
|
|
852
|
+
return "response" in this.reason ? this.reason.response : void 0;
|
|
853
|
+
}
|
|
854
|
+
get message() {
|
|
855
|
+
return this.reason.message;
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
var formatReason = (tag2) => tag2.endsWith("Error") ? tag2.slice(0, -5) : tag2;
|
|
859
|
+
var formatMessage = (reason, description, info) => description ? `${reason}: ${description} (${info})` : `${reason} error (${info})`;
|
|
860
|
+
var TransportError = class extends (/* @__PURE__ */ TaggedError("TransportError")) {
|
|
861
|
+
/**
|
|
862
|
+
* Formats the request method and URL for transport error messages.
|
|
863
|
+
*
|
|
864
|
+
* @since 4.0.0
|
|
865
|
+
*/
|
|
866
|
+
get methodAndUrl() {
|
|
867
|
+
return `${this.request.method} ${this.request.url}`;
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* Builds the transport error message from the optional description and request details.
|
|
871
|
+
*
|
|
872
|
+
* @since 4.0.0
|
|
873
|
+
*/
|
|
874
|
+
get message() {
|
|
875
|
+
return formatMessage(formatReason(this._tag), this.description, this.methodAndUrl);
|
|
876
|
+
}
|
|
877
|
+
};
|
|
878
|
+
var EncodeError = class extends (/* @__PURE__ */ TaggedError("EncodeError")) {
|
|
879
|
+
/**
|
|
880
|
+
* Formats the request method and URL for request encoding error messages.
|
|
881
|
+
*
|
|
882
|
+
* @since 4.0.0
|
|
883
|
+
*/
|
|
884
|
+
get methodAndUrl() {
|
|
885
|
+
return `${this.request.method} ${this.request.url}`;
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Builds the request encoding error message from the optional description and request details.
|
|
889
|
+
*
|
|
890
|
+
* @since 4.0.0
|
|
891
|
+
*/
|
|
892
|
+
get message() {
|
|
893
|
+
return formatMessage(formatReason(this._tag), this.description, this.methodAndUrl);
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
var InvalidUrlError = class extends (/* @__PURE__ */ TaggedError("InvalidUrlError")) {
|
|
897
|
+
/**
|
|
898
|
+
* Formats the request method and URL for invalid URL error messages.
|
|
899
|
+
*
|
|
900
|
+
* @since 4.0.0
|
|
901
|
+
*/
|
|
902
|
+
get methodAndUrl() {
|
|
903
|
+
return `${this.request.method} ${this.request.url}`;
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Builds the invalid URL error message from the optional description and request details.
|
|
907
|
+
*
|
|
908
|
+
* @since 4.0.0
|
|
909
|
+
*/
|
|
910
|
+
get message() {
|
|
911
|
+
return formatMessage(formatReason(this._tag), this.description, this.methodAndUrl);
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
var StatusCodeError = class extends (/* @__PURE__ */ TaggedError("StatusCodeError")) {
|
|
915
|
+
/**
|
|
916
|
+
* Formats the request method and URL for status code error messages.
|
|
917
|
+
*
|
|
918
|
+
* @since 4.0.0
|
|
919
|
+
*/
|
|
920
|
+
get methodAndUrl() {
|
|
921
|
+
return `${this.request.method} ${this.request.url}`;
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Builds the status code error message from the response status, optional description, and request details.
|
|
925
|
+
*
|
|
926
|
+
* @since 4.0.0
|
|
927
|
+
*/
|
|
928
|
+
get message() {
|
|
929
|
+
const info = `${this.response.status} ${this.methodAndUrl}`;
|
|
930
|
+
return formatMessage(formatReason(this._tag), this.description, info);
|
|
931
|
+
}
|
|
932
|
+
};
|
|
933
|
+
var DecodeError = class extends (/* @__PURE__ */ TaggedError("DecodeError")) {
|
|
934
|
+
/**
|
|
935
|
+
* Formats the request method and URL for response decoding error messages.
|
|
936
|
+
*
|
|
937
|
+
* @since 4.0.0
|
|
938
|
+
*/
|
|
939
|
+
get methodAndUrl() {
|
|
940
|
+
return `${this.request.method} ${this.request.url}`;
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* Builds the response decoding error message from the response status, optional description, and request details.
|
|
944
|
+
*
|
|
945
|
+
* @since 4.0.0
|
|
946
|
+
*/
|
|
947
|
+
get message() {
|
|
948
|
+
const info = `${this.response.status} ${this.methodAndUrl}`;
|
|
949
|
+
return formatMessage(formatReason(this._tag), this.description, info);
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
var EmptyBodyError = class extends (/* @__PURE__ */ TaggedError("EmptyBodyError")) {
|
|
953
|
+
/**
|
|
954
|
+
* Formats the request method and URL for empty response body error messages.
|
|
955
|
+
*
|
|
956
|
+
* @since 4.0.0
|
|
957
|
+
*/
|
|
958
|
+
get methodAndUrl() {
|
|
959
|
+
return `${this.request.method} ${this.request.url}`;
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* Builds the empty body error message from the response status, optional description, and request details.
|
|
963
|
+
*
|
|
964
|
+
* @since 4.0.0
|
|
965
|
+
*/
|
|
966
|
+
get message() {
|
|
967
|
+
const info = `${this.response.status} ${this.methodAndUrl}`;
|
|
968
|
+
return formatMessage(formatReason(this._tag), this.description, info);
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
var HttpClientErrorSchema = class _HttpClientErrorSchema extends (/* @__PURE__ */ Error3(TypeId3)({
|
|
972
|
+
_tag: /* @__PURE__ */ tag("HttpError"),
|
|
973
|
+
kind: /* @__PURE__ */ Literals(["EncodeError", "DecodeError", "TransportError", "InvalidUrlError", "StatusCodeError", "EmptyBodyError"]),
|
|
974
|
+
cause: /* @__PURE__ */ optional(/* @__PURE__ */ Defect())
|
|
975
|
+
})) {
|
|
976
|
+
/**
|
|
977
|
+
* Builds the serializable schema representation for an HTTP client error.
|
|
978
|
+
*
|
|
979
|
+
* @since 4.0.0
|
|
980
|
+
*/
|
|
981
|
+
static fromHttpClientError(error) {
|
|
982
|
+
return new _HttpClientErrorSchema({
|
|
983
|
+
_tag: "HttpError",
|
|
984
|
+
kind: error.reason._tag,
|
|
985
|
+
cause: error.reason
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpIncomingMessage.js
|
|
991
|
+
var TypeId4 = "~effect/http/HttpIncomingMessage";
|
|
992
|
+
var schemaBodyJson2 = (schema, options3) => {
|
|
993
|
+
const decode = decodeEffect(toCodecJson(schema));
|
|
994
|
+
const decodeJson = options3?.reviver === void 0 ? void 0 : decodeEffect(fromJsonString(toCodecJson(schema), options3));
|
|
995
|
+
return (self) => decodeJson === void 0 ? flatMap(self.json, (u) => decode(u, options3)) : flatMap(self.text, (body) => body === "" ? flatMap(self.json, (u) => decode(u, options3)) : decodeJson(body, options3));
|
|
996
|
+
};
|
|
997
|
+
var schemaBodyUrlParams = (schema, options3) => {
|
|
998
|
+
const decode = RecordFromUrlParams.pipe(decodeTo(schema), decodeEffect);
|
|
999
|
+
return (self) => flatMap(self.urlParamsBody, (u) => decode(u, options3));
|
|
1000
|
+
};
|
|
1001
|
+
var MaxBodySize = /* @__PURE__ */ Reference("effect/http/HttpIncomingMessage/MaxBodySize", {
|
|
1002
|
+
defaultValue: () => void 0
|
|
1003
|
+
});
|
|
1004
|
+
var inspect = (self, that) => {
|
|
1005
|
+
const contentType = self.headers["content-type"] ?? "";
|
|
1006
|
+
let body;
|
|
1007
|
+
if (contentType.includes("application/json")) {
|
|
1008
|
+
try {
|
|
1009
|
+
body = runSync(self.json);
|
|
1010
|
+
} catch (_) {
|
|
1011
|
+
}
|
|
1012
|
+
} else if (contentType.includes("text/") || contentType.includes("urlencoded")) {
|
|
1013
|
+
try {
|
|
1014
|
+
body = runSync(self.text);
|
|
1015
|
+
} catch (_) {
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
const obj = {
|
|
1019
|
+
...that,
|
|
1020
|
+
headers: redact(self.headers),
|
|
1021
|
+
remoteAddress: self.remoteAddress
|
|
1022
|
+
};
|
|
1023
|
+
if (body !== void 0) {
|
|
1024
|
+
obj.body = body;
|
|
1025
|
+
}
|
|
1026
|
+
return obj;
|
|
1027
|
+
};
|
|
1028
|
+
|
|
1029
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpClientResponse.js
|
|
1030
|
+
var TypeId5 = "~effect/http/HttpClientResponse";
|
|
1031
|
+
var fromWeb2 = (request, source) => new WebHttpClientResponse(request, source);
|
|
1032
|
+
var filterStatus = /* @__PURE__ */ dual(2, (self, f) => suspend(() => f(self.status) ? succeed2(self) : fail3(new HttpClientError({
|
|
1033
|
+
reason: new StatusCodeError({
|
|
1034
|
+
response: self,
|
|
1035
|
+
request: self.request,
|
|
1036
|
+
description: "invalid status code"
|
|
1037
|
+
})
|
|
1038
|
+
}))));
|
|
1039
|
+
var filterStatusOk = (self) => self.status >= 200 && self.status < 300 ? succeed2(self) : fail3(new HttpClientError({
|
|
1040
|
+
reason: new StatusCodeError({
|
|
1041
|
+
response: self,
|
|
1042
|
+
request: self.request,
|
|
1043
|
+
description: "non 2xx status code"
|
|
1044
|
+
})
|
|
1045
|
+
}));
|
|
1046
|
+
var WebHttpClientResponse = class extends Class {
|
|
1047
|
+
[TypeId4];
|
|
1048
|
+
[TypeId5];
|
|
1049
|
+
request;
|
|
1050
|
+
source;
|
|
1051
|
+
constructor(request, source) {
|
|
1052
|
+
super();
|
|
1053
|
+
this.request = request;
|
|
1054
|
+
this.source = source;
|
|
1055
|
+
this[TypeId4] = TypeId4;
|
|
1056
|
+
this[TypeId5] = TypeId5;
|
|
1057
|
+
}
|
|
1058
|
+
toJSON() {
|
|
1059
|
+
return inspect(this, {
|
|
1060
|
+
_id: "HttpClientResponse",
|
|
1061
|
+
request: this.request.toJSON(),
|
|
1062
|
+
status: this.status
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
get status() {
|
|
1066
|
+
return this.source.status;
|
|
1067
|
+
}
|
|
1068
|
+
get url() {
|
|
1069
|
+
if (this.source.url) return this.source.url.split("#")[0];
|
|
1070
|
+
const url = toUrl(this.request);
|
|
1071
|
+
if (isNone(url)) return "";
|
|
1072
|
+
url.value.hash = "";
|
|
1073
|
+
return url.value.href;
|
|
1074
|
+
}
|
|
1075
|
+
get headers() {
|
|
1076
|
+
return fromInput2(this.source.headers);
|
|
1077
|
+
}
|
|
1078
|
+
cachedCookies;
|
|
1079
|
+
get cookies() {
|
|
1080
|
+
if (this.cachedCookies) {
|
|
1081
|
+
return this.cachedCookies;
|
|
1082
|
+
}
|
|
1083
|
+
return this.cachedCookies = fromSetCookie(this.source.headers.getSetCookie());
|
|
1084
|
+
}
|
|
1085
|
+
get remoteAddress() {
|
|
1086
|
+
return none();
|
|
1087
|
+
}
|
|
1088
|
+
get stream() {
|
|
1089
|
+
return this.source.body ? fromReadableStream({
|
|
1090
|
+
evaluate: () => this.source.body,
|
|
1091
|
+
onError: (cause) => new HttpClientError({
|
|
1092
|
+
reason: new DecodeError({
|
|
1093
|
+
request: this.request,
|
|
1094
|
+
response: this,
|
|
1095
|
+
cause
|
|
1096
|
+
})
|
|
1097
|
+
})
|
|
1098
|
+
}) : fail4(new HttpClientError({
|
|
1099
|
+
reason: new EmptyBodyError({
|
|
1100
|
+
request: this.request,
|
|
1101
|
+
response: this,
|
|
1102
|
+
description: "can not create stream from empty body"
|
|
1103
|
+
})
|
|
1104
|
+
}));
|
|
1105
|
+
}
|
|
1106
|
+
get json() {
|
|
1107
|
+
return flatMap(this.text, (text3) => try_2({
|
|
1108
|
+
try: () => text3 === "" ? null : JSON.parse(text3),
|
|
1109
|
+
catch: (cause) => new HttpClientError({
|
|
1110
|
+
reason: new DecodeError({
|
|
1111
|
+
request: this.request,
|
|
1112
|
+
response: this,
|
|
1113
|
+
cause
|
|
1114
|
+
})
|
|
1115
|
+
})
|
|
1116
|
+
}));
|
|
1117
|
+
}
|
|
1118
|
+
textBody;
|
|
1119
|
+
get text() {
|
|
1120
|
+
return this.textBody ??= map(this.arrayBuffer, (_) => new TextDecoder().decode(_));
|
|
1121
|
+
}
|
|
1122
|
+
get urlParamsBody() {
|
|
1123
|
+
return flatMap(this.text, (_) => try_2({
|
|
1124
|
+
try: () => fromInput3(new URLSearchParams(_)),
|
|
1125
|
+
catch: (cause) => new HttpClientError({
|
|
1126
|
+
reason: new DecodeError({
|
|
1127
|
+
request: this.request,
|
|
1128
|
+
response: this,
|
|
1129
|
+
cause
|
|
1130
|
+
})
|
|
1131
|
+
})
|
|
1132
|
+
}));
|
|
1133
|
+
}
|
|
1134
|
+
formDataBody;
|
|
1135
|
+
get formData() {
|
|
1136
|
+
return this.formDataBody ??= tryPromise({
|
|
1137
|
+
try: () => this.source.formData(),
|
|
1138
|
+
catch: (cause) => new HttpClientError({
|
|
1139
|
+
reason: new DecodeError({
|
|
1140
|
+
request: this.request,
|
|
1141
|
+
response: this,
|
|
1142
|
+
cause
|
|
1143
|
+
})
|
|
1144
|
+
})
|
|
1145
|
+
}).pipe(cached, runSync);
|
|
1146
|
+
}
|
|
1147
|
+
arrayBufferBody;
|
|
1148
|
+
get arrayBuffer() {
|
|
1149
|
+
if (this.arrayBufferBody) {
|
|
1150
|
+
return this.arrayBufferBody;
|
|
1151
|
+
}
|
|
1152
|
+
this.arrayBufferBody = tryPromise({
|
|
1153
|
+
try: () => this.source.arrayBuffer(),
|
|
1154
|
+
catch: (cause) => new HttpClientError({
|
|
1155
|
+
reason: new DecodeError({
|
|
1156
|
+
request: this.request,
|
|
1157
|
+
response: this,
|
|
1158
|
+
cause
|
|
1159
|
+
})
|
|
1160
|
+
})
|
|
1161
|
+
}).pipe(cached, runSync);
|
|
1162
|
+
return this.arrayBufferBody;
|
|
1163
|
+
}
|
|
1164
|
+
pipe() {
|
|
1165
|
+
return pipeArguments(this, arguments);
|
|
1166
|
+
}
|
|
1167
|
+
};
|
|
1168
|
+
|
|
1169
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpTraceContext.js
|
|
1170
|
+
var HttpTraceContext_exports = {};
|
|
1171
|
+
__export(HttpTraceContext_exports, {
|
|
1172
|
+
b3: () => b3,
|
|
1173
|
+
fromHeaders: () => fromHeaders,
|
|
1174
|
+
toHeaders: () => toHeaders,
|
|
1175
|
+
w3c: () => w3c,
|
|
1176
|
+
xb3: () => xb3
|
|
1177
|
+
});
|
|
1178
|
+
var toHeaders = (span) => fromRecordUnsafe({
|
|
1179
|
+
b3: `${span.traceId}-${span.spanId}-${span.sampled ? "1" : "0"}${match(span.parent, {
|
|
1180
|
+
onNone: () => "",
|
|
1181
|
+
onSome: (parent) => `-${parent.spanId}`
|
|
1182
|
+
})}`,
|
|
1183
|
+
traceparent: `00-${span.traceId}-${span.spanId}-${span.sampled ? "01" : "00"}`
|
|
1184
|
+
});
|
|
1185
|
+
var fromHeaders = (headers) => {
|
|
1186
|
+
let span = w3c(headers);
|
|
1187
|
+
if (isSome(span)) {
|
|
1188
|
+
return span;
|
|
1189
|
+
}
|
|
1190
|
+
span = b3(headers);
|
|
1191
|
+
if (isSome(span)) {
|
|
1192
|
+
return span;
|
|
1193
|
+
}
|
|
1194
|
+
return xb3(headers);
|
|
1195
|
+
};
|
|
1196
|
+
var b3 = (headers) => {
|
|
1197
|
+
if (!("b3" in headers)) {
|
|
1198
|
+
return none();
|
|
1199
|
+
}
|
|
1200
|
+
const parts = headers["b3"].split("-");
|
|
1201
|
+
if (parts.length < 2) {
|
|
1202
|
+
return none();
|
|
1203
|
+
}
|
|
1204
|
+
return some(externalSpan({
|
|
1205
|
+
traceId: parts[0],
|
|
1206
|
+
spanId: parts[1],
|
|
1207
|
+
sampled: parts[2] ? parts[2] === "1" : true
|
|
1208
|
+
}));
|
|
1209
|
+
};
|
|
1210
|
+
var xb3 = (headers) => {
|
|
1211
|
+
if (!headers["x-b3-traceid"] || !headers["x-b3-spanid"]) {
|
|
1212
|
+
return none();
|
|
1213
|
+
}
|
|
1214
|
+
return some(externalSpan({
|
|
1215
|
+
traceId: headers["x-b3-traceid"],
|
|
1216
|
+
spanId: headers["x-b3-spanid"],
|
|
1217
|
+
sampled: headers["x-b3-sampled"] ? headers["x-b3-sampled"] === "1" : true
|
|
1218
|
+
}));
|
|
1219
|
+
};
|
|
1220
|
+
var w3cTraceId = /^[0-9a-f]{32}$/i;
|
|
1221
|
+
var w3cSpanId = /^[0-9a-f]{16}$/i;
|
|
1222
|
+
var w3c = (headers) => {
|
|
1223
|
+
if (!headers["traceparent"]) {
|
|
1224
|
+
return none();
|
|
1225
|
+
}
|
|
1226
|
+
const parts = headers["traceparent"].split("-");
|
|
1227
|
+
if (parts.length !== 4) {
|
|
1228
|
+
return none();
|
|
1229
|
+
}
|
|
1230
|
+
const [version, traceId, spanId, flags] = parts;
|
|
1231
|
+
switch (version) {
|
|
1232
|
+
case "00": {
|
|
1233
|
+
if (w3cTraceId.test(traceId) === false || w3cSpanId.test(spanId) === false) {
|
|
1234
|
+
return none();
|
|
1235
|
+
}
|
|
1236
|
+
return some(externalSpan({
|
|
1237
|
+
traceId,
|
|
1238
|
+
spanId,
|
|
1239
|
+
sampled: (parseInt(flags, 16) & 1) === 1
|
|
1240
|
+
}));
|
|
1241
|
+
}
|
|
1242
|
+
default: {
|
|
1243
|
+
return none();
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
};
|
|
1247
|
+
|
|
1248
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpClient.js
|
|
1249
|
+
var TypeId6 = "~effect/http/HttpClient";
|
|
1250
|
+
var isHttpClient = (u) => hasProperty(u, TypeId6);
|
|
1251
|
+
var HttpClient = /* @__PURE__ */ Service("effect/HttpClient");
|
|
1252
|
+
var accessor = (method) => (...args) => flatMap(HttpClient, (client) => client[method](...args));
|
|
1253
|
+
var execute = /* @__PURE__ */ accessor("execute");
|
|
1254
|
+
var get5 = /* @__PURE__ */ accessor("get");
|
|
1255
|
+
var query2 = /* @__PURE__ */ accessor("query");
|
|
1256
|
+
var head2 = /* @__PURE__ */ accessor("head");
|
|
1257
|
+
var post2 = /* @__PURE__ */ accessor("post");
|
|
1258
|
+
var patch2 = /* @__PURE__ */ accessor("patch");
|
|
1259
|
+
var put2 = /* @__PURE__ */ accessor("put");
|
|
1260
|
+
var del2 = /* @__PURE__ */ accessor("del");
|
|
1261
|
+
var options2 = /* @__PURE__ */ accessor("options");
|
|
1262
|
+
var transform = /* @__PURE__ */ dual(2, (self, f) => makeWith2(flatMap((request) => f(self.postprocess(succeed2(request)), request)), self.preprocess));
|
|
1263
|
+
var transformResponse = /* @__PURE__ */ dual(2, (self, f) => makeWith2((request) => f(self.postprocess(request)), self.preprocess));
|
|
1264
|
+
var catch_2 = /* @__PURE__ */ dual(2, (self, f) => transformResponse(self, catch_(f)));
|
|
1265
|
+
var catchTag2 = /* @__PURE__ */ dual(3, (self, tag2, f) => transformResponse(self, (effect2) => catchTag(effect2, tag2, f)));
|
|
1266
|
+
var catchTags2 = /* @__PURE__ */ dual(2, (self, cases) => transformResponse(self, catchTags(cases)));
|
|
1267
|
+
var filterOrElse2 = /* @__PURE__ */ dual(3, (self, f, orElse) => transformResponse(self, filterOrElse(f, orElse)));
|
|
1268
|
+
var filterOrFail2 = /* @__PURE__ */ dual(3, (self, f, orFailWith) => transformResponse(self, filterOrFail(f, orFailWith)));
|
|
1269
|
+
var filterStatus2 = /* @__PURE__ */ dual(2, (self, f) => transformResponse(self, flatMap(filterStatus(f))));
|
|
1270
|
+
var filterStatusOk2 = /* @__PURE__ */ transformResponse(/* @__PURE__ */ flatMap(filterStatusOk));
|
|
1271
|
+
var makeWith2 = (postprocess, preprocess) => {
|
|
1272
|
+
const self = Object.create(Proto3);
|
|
1273
|
+
self.preprocess = preprocess;
|
|
1274
|
+
self.postprocess = postprocess;
|
|
1275
|
+
self.execute = function(request) {
|
|
1276
|
+
return postprocess(preprocess(request));
|
|
1277
|
+
};
|
|
1278
|
+
return self;
|
|
1279
|
+
};
|
|
1280
|
+
var Proto3 = {
|
|
1281
|
+
[TypeId6]: TypeId6,
|
|
1282
|
+
pipe() {
|
|
1283
|
+
return pipeArguments(this, arguments);
|
|
1284
|
+
},
|
|
1285
|
+
...BaseProto,
|
|
1286
|
+
toJSON() {
|
|
1287
|
+
return {
|
|
1288
|
+
_id: "effect/HttpClient"
|
|
1289
|
+
};
|
|
1290
|
+
},
|
|
1291
|
+
.../* @__PURE__ */ Object.fromEntries(/* @__PURE__ */ allShort.map(([fullMethod, method]) => [method, function(url, options3) {
|
|
1292
|
+
return this.execute(make2(fullMethod)(url, options3));
|
|
1293
|
+
}]))
|
|
1294
|
+
};
|
|
1295
|
+
var make3 = (f) => makeWith2((effect2) => flatMap(effect2, (request) => withFiber((fiber) => {
|
|
1296
|
+
const scopedController = scopedRequests.get(request);
|
|
1297
|
+
const controller = scopedController ?? new AbortController();
|
|
1298
|
+
const urlResult = make(request.url, request.urlParams, getOrUndefined(request.hash));
|
|
1299
|
+
if (isFailure(urlResult)) {
|
|
1300
|
+
return fail3(new HttpClientError({
|
|
1301
|
+
reason: new InvalidUrlError({
|
|
1302
|
+
request,
|
|
1303
|
+
cause: urlResult.failure
|
|
1304
|
+
})
|
|
1305
|
+
}));
|
|
1306
|
+
}
|
|
1307
|
+
const url = urlResult.success;
|
|
1308
|
+
const tracerDisabled = fiber.getRef(DisablePropagation) || fiber.getRef(TracerDisabledWhen)(request);
|
|
1309
|
+
if (tracerDisabled) {
|
|
1310
|
+
const effect3 = f(request, url, controller.signal, fiber);
|
|
1311
|
+
if (scopedController) return effect3;
|
|
1312
|
+
return uninterruptibleMask((restore) => matchCauseEffect(restore(effect3), {
|
|
1313
|
+
onSuccess(response) {
|
|
1314
|
+
responseRegistry.register(response, controller);
|
|
1315
|
+
return succeed2(new InterruptibleResponse(response, controller));
|
|
1316
|
+
},
|
|
1317
|
+
onFailure(cause) {
|
|
1318
|
+
if (hasInterrupts(cause)) {
|
|
1319
|
+
controller.abort();
|
|
1320
|
+
}
|
|
1321
|
+
return failCause2(cause);
|
|
1322
|
+
}
|
|
1323
|
+
}));
|
|
1324
|
+
}
|
|
1325
|
+
return useSpan(fiber.getRef(SpanNameGenerator)(request), {
|
|
1326
|
+
kind: "client"
|
|
1327
|
+
}, (span) => {
|
|
1328
|
+
span.attribute("http.request.method", request.method);
|
|
1329
|
+
span.attribute("server.address", url.origin);
|
|
1330
|
+
if (url.port !== "") {
|
|
1331
|
+
span.attribute("server.port", +url.port);
|
|
1332
|
+
}
|
|
1333
|
+
span.attribute("url.full", url.toString());
|
|
1334
|
+
span.attribute("url.path", url.pathname);
|
|
1335
|
+
span.attribute("url.scheme", url.protocol.slice(0, -1));
|
|
1336
|
+
const query3 = url.search.slice(1);
|
|
1337
|
+
if (query3 !== "") {
|
|
1338
|
+
span.attribute("url.query", query3);
|
|
1339
|
+
}
|
|
1340
|
+
const redactedHeaderNames = fiber.getRef(CurrentRedactedNames);
|
|
1341
|
+
const headerFilter = fiber.getRef(TracerHeaderFilter);
|
|
1342
|
+
for (const name in request.headers) {
|
|
1343
|
+
if (!headerFilter(name, "request")) continue;
|
|
1344
|
+
span.attribute(`http.request.header.${name}`, isRedactedName(name, redactedHeaderNames) ? "<redacted>" : request.headers[name]);
|
|
1345
|
+
}
|
|
1346
|
+
request = fiber.getRef(TracerPropagationEnabled) ? setHeaders(request, toHeaders(span)) : request;
|
|
1347
|
+
return uninterruptibleMask((restore) => restore(f(request, url, controller.signal, fiber)).pipe(withParentSpan(span, {
|
|
1348
|
+
captureStackTrace: false
|
|
1349
|
+
}), matchCauseEffect({
|
|
1350
|
+
onSuccess: (response) => {
|
|
1351
|
+
span.attribute("http.response.status_code", response.status);
|
|
1352
|
+
for (const name in response.headers) {
|
|
1353
|
+
if (!headerFilter(name, "response")) continue;
|
|
1354
|
+
span.attribute(`http.response.header.${name}`, isRedactedName(name, redactedHeaderNames) ? "<redacted>" : response.headers[name]);
|
|
1355
|
+
}
|
|
1356
|
+
if (scopedController) return succeed2(response);
|
|
1357
|
+
responseRegistry.register(response, controller);
|
|
1358
|
+
return succeed2(new InterruptibleResponse(response, controller));
|
|
1359
|
+
},
|
|
1360
|
+
onFailure(cause) {
|
|
1361
|
+
if (!scopedController && hasInterrupts(cause)) {
|
|
1362
|
+
controller.abort();
|
|
1363
|
+
}
|
|
1364
|
+
return failCause2(cause);
|
|
1365
|
+
}
|
|
1366
|
+
})));
|
|
1367
|
+
});
|
|
1368
|
+
})), succeed2);
|
|
1369
|
+
var mapRequest = /* @__PURE__ */ dual(2, (self, f) => makeWith2(self.postprocess, (request) => map(self.preprocess(request), f)));
|
|
1370
|
+
var mapRequestEffect = /* @__PURE__ */ dual(2, (self, f) => makeWith2(self.postprocess, (request) => flatMap(self.preprocess(request), f)));
|
|
1371
|
+
var mapRequestInput = /* @__PURE__ */ dual(2, (self, f) => makeWith2(self.postprocess, (request) => self.preprocess(f(request))));
|
|
1372
|
+
var mapRequestInputEffect = /* @__PURE__ */ dual(2, (self, f) => makeWith2(self.postprocess, (request) => flatMap(f(request), self.preprocess)));
|
|
1373
|
+
var retry2 = /* @__PURE__ */ dual(2, (self, policy) => transformResponse(self, retry(policy)));
|
|
1374
|
+
var retryTransient = /* @__PURE__ */ dual(2, (self, options3) => {
|
|
1375
|
+
const isOnlySchedule = isSchedule(options3);
|
|
1376
|
+
const retryOn = isOnlySchedule ? "errors-and-responses" : options3.retryOn ?? "errors-and-responses";
|
|
1377
|
+
const schedule = isOnlySchedule ? options3 : options3.schedule;
|
|
1378
|
+
const passthroughSchedule = schedule && passthrough(schedule);
|
|
1379
|
+
const times = isOnlySchedule ? void 0 : options3.times;
|
|
1380
|
+
return transformResponse(self, flow(retryOn === "errors-only" ? identity : repeat({
|
|
1381
|
+
schedule: passthroughSchedule,
|
|
1382
|
+
times,
|
|
1383
|
+
while: isTransientResponse
|
|
1384
|
+
}), retryOn === "response-only" ? identity : retry({
|
|
1385
|
+
while: isOnlySchedule || options3.while === void 0 ? isTransientError : or(isTransientError, options3.while),
|
|
1386
|
+
schedule,
|
|
1387
|
+
times
|
|
1388
|
+
})));
|
|
1389
|
+
});
|
|
1390
|
+
var withRateLimiter = /* @__PURE__ */ dual(2, (self, options3) => {
|
|
1391
|
+
const initialState = {
|
|
1392
|
+
initial: true,
|
|
1393
|
+
limit: options3.limit,
|
|
1394
|
+
window: max(fromInputUnsafe(options3.window), millis(1))
|
|
1395
|
+
};
|
|
1396
|
+
const states = /* @__PURE__ */ new Map();
|
|
1397
|
+
const keyOption = options3.key;
|
|
1398
|
+
const resolveKey = typeof keyOption === "function" ? keyOption : constant(keyOption);
|
|
1399
|
+
const tokensOption = options3.tokens;
|
|
1400
|
+
const resolveTokens = typeof tokensOption === "function" ? tokensOption : constant(tokensOption ?? 1);
|
|
1401
|
+
const adaptiveLearningEnabled = !options3.disableAdaptiveLearning;
|
|
1402
|
+
const headerNames = resolveRateLimiterHeaderNames(options3.responseHeaders);
|
|
1403
|
+
const getState = (key) => {
|
|
1404
|
+
const current = states.get(key);
|
|
1405
|
+
if (current !== void 0) {
|
|
1406
|
+
return current;
|
|
1407
|
+
}
|
|
1408
|
+
states.set(key, initialState);
|
|
1409
|
+
return initialState;
|
|
1410
|
+
};
|
|
1411
|
+
const onResponse = options3.disableResponseInspection ? void 0 : (clock, key, headers, tokens) => {
|
|
1412
|
+
const current = getState(key);
|
|
1413
|
+
const next = parseRateLimiterState(current, clock, headers, tokens, headerNames);
|
|
1414
|
+
if (next.limit !== current.limit || !equals(next.window, current.window)) {
|
|
1415
|
+
states.set(key, next);
|
|
1416
|
+
}
|
|
1417
|
+
};
|
|
1418
|
+
return transform(self, function loop(effect2, request, retries = 0) {
|
|
1419
|
+
const fiber = getCurrent();
|
|
1420
|
+
const clock = fiber.getRef(Clock);
|
|
1421
|
+
const key = resolveKey(request);
|
|
1422
|
+
const tokens = Math.max(resolveTokens(request), 1);
|
|
1423
|
+
const current = getState(key);
|
|
1424
|
+
const canRetry = options3.times === void 0 || retries < options3.times;
|
|
1425
|
+
function retry3(retryAfter) {
|
|
1426
|
+
return retryAfter ? flatMap(sleep(retryAfter), () => loop(effect2, request, retries + 1)) : loop(effect2, request, retries + 1);
|
|
1427
|
+
}
|
|
1428
|
+
const inspectResponse = (response, adaptive) => {
|
|
1429
|
+
onResponse?.(clock, key, response.headers, tokens);
|
|
1430
|
+
if (options3.disableResponseInspection || response.status !== 429) {
|
|
1431
|
+
return succeed2(void 0);
|
|
1432
|
+
}
|
|
1433
|
+
const retryAfter = parseRetryAfter(clock, getHeader(response.headers, ...headerNames.retryAfter));
|
|
1434
|
+
if (retryAfter === void 0) {
|
|
1435
|
+
return succeed2(void 0);
|
|
1436
|
+
}
|
|
1437
|
+
const delay2 = parseRateLimitWindow(clock, response.headers, headerNames) ?? retryAfter;
|
|
1438
|
+
if (adaptive === void 0) {
|
|
1439
|
+
return succeed2(delay2);
|
|
1440
|
+
}
|
|
1441
|
+
return as(options3.limiter.adaptiveFeedback({
|
|
1442
|
+
key,
|
|
1443
|
+
epoch: adaptive.epoch,
|
|
1444
|
+
tokens,
|
|
1445
|
+
status: response.status,
|
|
1446
|
+
retryAfter: delay2
|
|
1447
|
+
}), delay2);
|
|
1448
|
+
};
|
|
1449
|
+
return flatMap(options3.limiter.consume({
|
|
1450
|
+
algorithm: options3.algorithm,
|
|
1451
|
+
onExceeded: "delay",
|
|
1452
|
+
key,
|
|
1453
|
+
limit: current.limit,
|
|
1454
|
+
window: current.window,
|
|
1455
|
+
tokens
|
|
1456
|
+
}), ({
|
|
1457
|
+
delay: delay2
|
|
1458
|
+
}) => {
|
|
1459
|
+
const runAdaptive = () => {
|
|
1460
|
+
const runRequest = (adaptive) => {
|
|
1461
|
+
const request2 = matchEffect(effect2, {
|
|
1462
|
+
onSuccess(response) {
|
|
1463
|
+
return flatMap(inspectResponse(response, adaptive), (retryAfter) => {
|
|
1464
|
+
if (response.status !== 429 || !canRetry) return succeed2(response);
|
|
1465
|
+
return retry3(retryAfter);
|
|
1466
|
+
});
|
|
1467
|
+
},
|
|
1468
|
+
onFailure(error) {
|
|
1469
|
+
if (isTooManyRequestsHttpClientError(error)) {
|
|
1470
|
+
return flatMap(inspectResponse(error.reason.response, adaptive), (retryAfter) => canRetry ? retry3(retryAfter) : fail3(error));
|
|
1471
|
+
}
|
|
1472
|
+
return fail3(error);
|
|
1473
|
+
}
|
|
1474
|
+
});
|
|
1475
|
+
return adaptive === void 0 || isZero(adaptive.delay) ? request2 : delay(request2, adaptive.delay);
|
|
1476
|
+
};
|
|
1477
|
+
if (!adaptiveLearningEnabled) {
|
|
1478
|
+
return runRequest(void 0);
|
|
1479
|
+
}
|
|
1480
|
+
return flatMap(options3.limiter.adaptiveConsume({
|
|
1481
|
+
key,
|
|
1482
|
+
tokens,
|
|
1483
|
+
fallbackLimit: current.limit,
|
|
1484
|
+
fallbackWindow: current.window
|
|
1485
|
+
}), (adaptive) => {
|
|
1486
|
+
if (!isZero(adaptive.delay) && adaptive.phase === "cooldown") {
|
|
1487
|
+
return flatMap(sleep(adaptive.delay), runAdaptive);
|
|
1488
|
+
}
|
|
1489
|
+
return runRequest(adaptive);
|
|
1490
|
+
});
|
|
1491
|
+
};
|
|
1492
|
+
return isZero(delay2) ? runAdaptive() : flatMap(sleep(delay2), runAdaptive);
|
|
1493
|
+
});
|
|
1494
|
+
});
|
|
1495
|
+
});
|
|
1496
|
+
var resolveRateLimiterHeaderNames = (responseHeaders) => ({
|
|
1497
|
+
limit: responseHeaders?.limit === void 0 ? ["ratelimit-limit", "x-ratelimit-limit"] : [responseHeaders.limit.toLowerCase()],
|
|
1498
|
+
remaining: responseHeaders?.remaining === void 0 ? ["ratelimit-remaining", "x-ratelimit-remaining"] : [responseHeaders.remaining.toLowerCase()],
|
|
1499
|
+
reset: responseHeaders?.reset === void 0 ? ["ratelimit-reset", "x-ratelimit-reset"] : [responseHeaders.reset.toLowerCase()],
|
|
1500
|
+
resetAfter: responseHeaders?.resetAfter === void 0 ? ["ratelimit-reset-after", "x-ratelimit-reset-after"] : [responseHeaders.resetAfter.toLowerCase()],
|
|
1501
|
+
retryAfter: responseHeaders?.retryAfter === void 0 ? ["retry-after"] : [responseHeaders.retryAfter.toLowerCase()]
|
|
1502
|
+
});
|
|
1503
|
+
var parseRateLimiterState = (state, clock, headers, tokens, headerNames) => {
|
|
1504
|
+
const limit = parseRateLimitLimit(state, headers, tokens, headerNames) ?? state.limit;
|
|
1505
|
+
const window = parseRateLimitWindow(clock, headers, headerNames) ?? state.window;
|
|
1506
|
+
if (limit === state.limit && equals(window, state.window)) {
|
|
1507
|
+
return state;
|
|
1508
|
+
}
|
|
1509
|
+
return {
|
|
1510
|
+
limit,
|
|
1511
|
+
window,
|
|
1512
|
+
initial: false
|
|
1513
|
+
};
|
|
1514
|
+
};
|
|
1515
|
+
var parseRateLimitLimit = (state, headers, tokens, headerNames) => {
|
|
1516
|
+
const raw3 = getHeader(headers, ...headerNames.limit);
|
|
1517
|
+
const value = parseNumberHeader(raw3);
|
|
1518
|
+
if (value !== void 0 && value > 0) {
|
|
1519
|
+
return value;
|
|
1520
|
+
}
|
|
1521
|
+
const remaining = parseRateLimitRemaining(headers, headerNames);
|
|
1522
|
+
if (remaining === void 0) {
|
|
1523
|
+
return void 0;
|
|
1524
|
+
}
|
|
1525
|
+
return state.initial ? remaining + tokens : Math.max(remaining + tokens, state.limit);
|
|
1526
|
+
};
|
|
1527
|
+
var parseRateLimitRemaining = (headers, headerNames) => {
|
|
1528
|
+
const raw3 = getHeader(headers, ...headerNames.remaining);
|
|
1529
|
+
const value = parseNumberHeader(raw3);
|
|
1530
|
+
return value !== void 0 && value >= 0 ? value : void 0;
|
|
1531
|
+
};
|
|
1532
|
+
var parseRateLimitWindow = (clock, headers, headerNames) => {
|
|
1533
|
+
const resetAfter = parseResetAfter(getHeader(headers, ...headerNames.resetAfter));
|
|
1534
|
+
if (resetAfter !== void 0) {
|
|
1535
|
+
return resetAfter;
|
|
1536
|
+
}
|
|
1537
|
+
return parseResetHeader(clock, getHeader(headers, ...headerNames.reset));
|
|
1538
|
+
};
|
|
1539
|
+
var parseRetryAfter = (clock, value) => {
|
|
1540
|
+
if (value === void 0) {
|
|
1541
|
+
return void 0;
|
|
1542
|
+
}
|
|
1543
|
+
const numeric = parseNumberHeader(value);
|
|
1544
|
+
if (numeric !== void 0) {
|
|
1545
|
+
return max(seconds(numeric), millis(1));
|
|
1546
|
+
}
|
|
1547
|
+
const parsedDate = Date.parse(value);
|
|
1548
|
+
if (Number.isNaN(parsedDate)) {
|
|
1549
|
+
return void 0;
|
|
1550
|
+
}
|
|
1551
|
+
const millis2 = parsedDate - clock.currentTimeMillisUnsafe();
|
|
1552
|
+
if (millis2 <= 0) {
|
|
1553
|
+
return millis(1);
|
|
1554
|
+
}
|
|
1555
|
+
return millis(millis2);
|
|
1556
|
+
};
|
|
1557
|
+
var parseResetAfter = (value) => {
|
|
1558
|
+
const numeric = parseNumberHeader(value);
|
|
1559
|
+
if (numeric === void 0 || numeric <= 0) {
|
|
1560
|
+
return void 0;
|
|
1561
|
+
}
|
|
1562
|
+
return max(seconds(numeric), millis(1));
|
|
1563
|
+
};
|
|
1564
|
+
var parseResetHeader = (clock, value) => {
|
|
1565
|
+
const numeric = parseNumberHeader(value);
|
|
1566
|
+
if (numeric === void 0 || numeric <= 0) {
|
|
1567
|
+
return void 0;
|
|
1568
|
+
}
|
|
1569
|
+
const nowMillis = clock.currentTimeMillisUnsafe();
|
|
1570
|
+
if (numeric > 1e12) {
|
|
1571
|
+
return millis(Math.max(numeric - nowMillis, 1));
|
|
1572
|
+
}
|
|
1573
|
+
if (numeric > 1e9) {
|
|
1574
|
+
return millis(Math.max(numeric * 1e3 - nowMillis, 1));
|
|
1575
|
+
}
|
|
1576
|
+
return max(seconds(numeric), millis(1));
|
|
1577
|
+
};
|
|
1578
|
+
var parseNumberHeader = (value) => {
|
|
1579
|
+
if (value === void 0) {
|
|
1580
|
+
return void 0;
|
|
1581
|
+
}
|
|
1582
|
+
const match2 = /-?\d+(?:\.\d+)?/.exec(value);
|
|
1583
|
+
if (match2 === null) {
|
|
1584
|
+
return void 0;
|
|
1585
|
+
}
|
|
1586
|
+
const parsed = Number(match2[0]);
|
|
1587
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
1588
|
+
};
|
|
1589
|
+
var getHeader = (headers, ...keys) => {
|
|
1590
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1591
|
+
const value = headers[keys[i]];
|
|
1592
|
+
if (value !== void 0) {
|
|
1593
|
+
return value;
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
return void 0;
|
|
1597
|
+
};
|
|
1598
|
+
var tap2 = /* @__PURE__ */ dual(2, (self, f) => transformResponse(self, tap(f)));
|
|
1599
|
+
var tapError2 = /* @__PURE__ */ dual(2, (self, f) => transformResponse(self, tapError(f)));
|
|
1600
|
+
var tapRequest = /* @__PURE__ */ dual(2, (self, f) => makeWith2(self.postprocess, (request) => tap(self.preprocess(request), f)));
|
|
1601
|
+
var withCookiesRef = /* @__PURE__ */ dual(2, (self, ref) => makeWith2((request) => tap(self.postprocess(request), (response) => update(ref, (cookies) => merge2(cookies, response.cookies))), (request) => flatMap(self.preprocess(request), (request2) => map(get3(ref), (cookies) => isEmpty(cookies) ? request2 : setHeader(request2, "cookie", toCookieHeader(cookies))))));
|
|
1602
|
+
var withScope = (self) => transform(self, (effect2, request) => {
|
|
1603
|
+
const controller = new AbortController();
|
|
1604
|
+
scopedRequests.set(request, controller);
|
|
1605
|
+
return andThen(addFinalizer(() => sync(() => controller.abort())), effect2);
|
|
1606
|
+
});
|
|
1607
|
+
var followRedirects = /* @__PURE__ */ dual((args) => isHttpClient(args[0]), (self, maxRedirects) => makeWith2((request) => {
|
|
1608
|
+
const loop = (request2, redirects) => suspend(() => {
|
|
1609
|
+
let currentRequest;
|
|
1610
|
+
return flatMap(self.postprocess(map(request2, (request3) => {
|
|
1611
|
+
currentRequest = request3;
|
|
1612
|
+
return request3;
|
|
1613
|
+
})), (response) => {
|
|
1614
|
+
if (response.status < 300 || response.status >= 400 || !response.headers.location || redirects >= (maxRedirects ?? 10)) {
|
|
1615
|
+
return succeed2(response);
|
|
1616
|
+
}
|
|
1617
|
+
const url = new URL(response.headers.location, response.request.url);
|
|
1618
|
+
const request3 = currentRequest ?? response.request;
|
|
1619
|
+
let nextRequest = request3;
|
|
1620
|
+
if ((response.status === 301 || response.status === 302) && request3.method === "POST" || response.status === 303 && request3.method !== "GET" && request3.method !== "HEAD") {
|
|
1621
|
+
nextRequest = setMethod(nextRequest, "GET");
|
|
1622
|
+
nextRequest = setBody(nextRequest, empty7);
|
|
1623
|
+
}
|
|
1624
|
+
if (url.origin !== new URL(response.request.url).origin) {
|
|
1625
|
+
nextRequest = removeHeader(nextRequest, "authorization");
|
|
1626
|
+
nextRequest = removeHeader(nextRequest, "proxy-authorization");
|
|
1627
|
+
nextRequest = removeHeader(nextRequest, "cookie");
|
|
1628
|
+
}
|
|
1629
|
+
return loop(succeed2(setUrl(nextRequest, url)), redirects + 1);
|
|
1630
|
+
});
|
|
1631
|
+
});
|
|
1632
|
+
return loop(request, 0);
|
|
1633
|
+
}, self.preprocess));
|
|
1634
|
+
var TracerDisabledWhen = /* @__PURE__ */ Reference("effect/http/HttpClient/TracerDisabledWhen", {
|
|
1635
|
+
defaultValue: () => constFalse
|
|
1636
|
+
});
|
|
1637
|
+
var TracerHeaderFilter = /* @__PURE__ */ Reference("effect/http/HttpClient/TracerHeaderFilter", {
|
|
1638
|
+
defaultValue: () => constTrue
|
|
1639
|
+
});
|
|
1640
|
+
var TracerPropagationEnabled = /* @__PURE__ */ Reference("effect/http/HttpClient/TracerPropagationEnabled", {
|
|
1641
|
+
defaultValue: constTrue
|
|
1642
|
+
});
|
|
1643
|
+
var SpanNameGenerator = /* @__PURE__ */ Reference("effect/http/HttpClient/SpanNameGenerator", {
|
|
1644
|
+
defaultValue: () => (request) => `http.client ${request.method}`
|
|
1645
|
+
});
|
|
1646
|
+
var layerMergedContext = (effect2) => effect(HttpClient)(contextWith((context2) => map(effect2, (client) => transformResponse(client, updateContext((input) => merge(context2, input))))));
|
|
1647
|
+
var responseRegistry = /* @__PURE__ */ (() => {
|
|
1648
|
+
if ("FinalizationRegistry" in globalThis && globalThis.FinalizationRegistry) {
|
|
1649
|
+
const registry = /* @__PURE__ */ new FinalizationRegistry((controller) => {
|
|
1650
|
+
controller.abort();
|
|
1651
|
+
});
|
|
1652
|
+
return {
|
|
1653
|
+
register(response, controller) {
|
|
1654
|
+
registry.register(response, controller, response);
|
|
1655
|
+
},
|
|
1656
|
+
unregister(response) {
|
|
1657
|
+
registry.unregister(response);
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
}
|
|
1661
|
+
const timers = /* @__PURE__ */ new Map();
|
|
1662
|
+
return {
|
|
1663
|
+
register(response, controller) {
|
|
1664
|
+
timers.set(response, setTimeout(() => controller.abort(), 5e3));
|
|
1665
|
+
},
|
|
1666
|
+
unregister(response) {
|
|
1667
|
+
const timer = timers.get(response);
|
|
1668
|
+
if (timer === void 0) return;
|
|
1669
|
+
clearTimeout(timer);
|
|
1670
|
+
timers.delete(response);
|
|
1671
|
+
}
|
|
1672
|
+
};
|
|
1673
|
+
})();
|
|
1674
|
+
var scopedRequests = /* @__PURE__ */ new WeakMap();
|
|
1675
|
+
var InterruptibleResponse = class {
|
|
1676
|
+
original;
|
|
1677
|
+
controller;
|
|
1678
|
+
constructor(original, controller) {
|
|
1679
|
+
this.original = original;
|
|
1680
|
+
this.controller = controller;
|
|
1681
|
+
}
|
|
1682
|
+
[TypeId5] = TypeId5;
|
|
1683
|
+
[TypeId4] = TypeId4;
|
|
1684
|
+
applyInterrupt(effect2) {
|
|
1685
|
+
return suspend(() => {
|
|
1686
|
+
responseRegistry.unregister(this.original);
|
|
1687
|
+
return onInterrupt(effect2, () => sync(() => {
|
|
1688
|
+
this.controller.abort();
|
|
1689
|
+
}));
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
get request() {
|
|
1693
|
+
return this.original.request;
|
|
1694
|
+
}
|
|
1695
|
+
get url() {
|
|
1696
|
+
return this.original.url;
|
|
1697
|
+
}
|
|
1698
|
+
get status() {
|
|
1699
|
+
return this.original.status;
|
|
1700
|
+
}
|
|
1701
|
+
get headers() {
|
|
1702
|
+
return this.original.headers;
|
|
1703
|
+
}
|
|
1704
|
+
get cookies() {
|
|
1705
|
+
return this.original.cookies;
|
|
1706
|
+
}
|
|
1707
|
+
get remoteAddress() {
|
|
1708
|
+
return this.original.remoteAddress;
|
|
1709
|
+
}
|
|
1710
|
+
get formData() {
|
|
1711
|
+
return this.applyInterrupt(this.original.formData);
|
|
1712
|
+
}
|
|
1713
|
+
get text() {
|
|
1714
|
+
return this.applyInterrupt(this.original.text);
|
|
1715
|
+
}
|
|
1716
|
+
get json() {
|
|
1717
|
+
return this.applyInterrupt(this.original.json);
|
|
1718
|
+
}
|
|
1719
|
+
get urlParamsBody() {
|
|
1720
|
+
return this.applyInterrupt(this.original.urlParamsBody);
|
|
1721
|
+
}
|
|
1722
|
+
get arrayBuffer() {
|
|
1723
|
+
return this.applyInterrupt(this.original.arrayBuffer);
|
|
1724
|
+
}
|
|
1725
|
+
get stream() {
|
|
1726
|
+
return suspend2(() => {
|
|
1727
|
+
responseRegistry.unregister(this.original);
|
|
1728
|
+
return ensuring2(this.original.stream, sync(() => {
|
|
1729
|
+
this.controller.abort();
|
|
1730
|
+
}));
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
toJSON() {
|
|
1734
|
+
return this.original.toJSON();
|
|
1735
|
+
}
|
|
1736
|
+
[NodeInspectSymbol]() {
|
|
1737
|
+
return this.original[NodeInspectSymbol]();
|
|
1738
|
+
}
|
|
1739
|
+
pipe() {
|
|
1740
|
+
return pipeArguments(this, arguments);
|
|
1741
|
+
}
|
|
1742
|
+
};
|
|
1743
|
+
var isTransientError = (error) => isTimeoutError(error) || isTransientHttpError(error);
|
|
1744
|
+
var isTransientHttpError = (error) => isHttpClientError(error) && (error.reason._tag === "TransportError" || error.reason._tag === "StatusCodeError" && isTransientResponse(error.reason.response));
|
|
1745
|
+
var isTooManyRequestsHttpClientError = (error) => isHttpClientError(error) && error.reason._tag === "StatusCodeError" && error.reason.response.status === 429;
|
|
1746
|
+
var isTransientResponse = (response) => response.status === 408 || response.status === 429 || response.status === 500 || response.status === 502 || response.status === 503 || response.status === 504;
|
|
1747
|
+
|
|
1748
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/Template.js
|
|
1749
|
+
function make4(strings, ...args) {
|
|
1750
|
+
const argsLength = args.length;
|
|
1751
|
+
const values = new Array(argsLength);
|
|
1752
|
+
const effects = [];
|
|
1753
|
+
for (let i = 0; i < argsLength; i++) {
|
|
1754
|
+
const arg = args[i];
|
|
1755
|
+
if (isOption(arg)) {
|
|
1756
|
+
values[i] = arg._tag === "Some" ? primitiveToString(arg.value) : "";
|
|
1757
|
+
} else if (isSuccess2(arg)) {
|
|
1758
|
+
values[i] = primitiveToString(arg.value);
|
|
1759
|
+
} else if (isEffect(arg)) {
|
|
1760
|
+
effects.push([i, arg]);
|
|
1761
|
+
} else {
|
|
1762
|
+
values[i] = primitiveToString(arg);
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
if (effects.length === 0) {
|
|
1766
|
+
return succeed2(consolidate(strings, values));
|
|
1767
|
+
}
|
|
1768
|
+
return map(forEach(effects, ([index, effect2]) => tap(effect2, (value) => sync(() => {
|
|
1769
|
+
values[index] = primitiveToString(value);
|
|
1770
|
+
})), {
|
|
1771
|
+
concurrency: "unbounded",
|
|
1772
|
+
discard: true
|
|
1773
|
+
}), (_) => consolidate(strings, values));
|
|
1774
|
+
}
|
|
1775
|
+
function stream2(strings, ...args) {
|
|
1776
|
+
const chunks = [];
|
|
1777
|
+
let buffer2 = "";
|
|
1778
|
+
for (let i = 0, len = args.length; i < len; i++) {
|
|
1779
|
+
buffer2 += strings[i];
|
|
1780
|
+
const arg = args[i];
|
|
1781
|
+
if (isOption(arg)) {
|
|
1782
|
+
buffer2 += arg._tag === "Some" ? primitiveToString(arg.value) : "";
|
|
1783
|
+
} else if (isSuccess2(arg)) {
|
|
1784
|
+
buffer2 += primitiveToString(arg.value);
|
|
1785
|
+
} else if (isEffect(arg)) {
|
|
1786
|
+
if (buffer2.length > 0) {
|
|
1787
|
+
chunks.push(buffer2);
|
|
1788
|
+
buffer2 = "";
|
|
1789
|
+
}
|
|
1790
|
+
chunks.push(map(arg, primitiveToString));
|
|
1791
|
+
} else if (isStream(arg)) {
|
|
1792
|
+
if (buffer2.length > 0) {
|
|
1793
|
+
chunks.push(buffer2);
|
|
1794
|
+
buffer2 = "";
|
|
1795
|
+
}
|
|
1796
|
+
chunks.push(map2(arg, primitiveToString));
|
|
1797
|
+
} else {
|
|
1798
|
+
buffer2 += primitiveToString(arg);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
buffer2 += strings[strings.length - 1];
|
|
1802
|
+
if (buffer2.length > 0) {
|
|
1803
|
+
chunks.push(buffer2);
|
|
1804
|
+
buffer2 = "";
|
|
1805
|
+
}
|
|
1806
|
+
return fromIterable2(chunks).pipe(mapEffect((chunk) => isEffect(chunk) ? chunk : succeed2(chunk), {
|
|
1807
|
+
concurrency: "unbounded"
|
|
1808
|
+
}), flatMap2((chunk) => typeof chunk === "string" ? succeed3(chunk) : chunk));
|
|
1809
|
+
}
|
|
1810
|
+
function primitiveToString(value) {
|
|
1811
|
+
if (Array.isArray(value)) {
|
|
1812
|
+
return value.map(primitiveToString).join("");
|
|
1813
|
+
}
|
|
1814
|
+
switch (typeof value) {
|
|
1815
|
+
case "string": {
|
|
1816
|
+
return value;
|
|
1817
|
+
}
|
|
1818
|
+
case "number":
|
|
1819
|
+
case "bigint": {
|
|
1820
|
+
return value.toString();
|
|
1821
|
+
}
|
|
1822
|
+
case "boolean": {
|
|
1823
|
+
return value ? "true" : "false";
|
|
1824
|
+
}
|
|
1825
|
+
default: {
|
|
1826
|
+
return "";
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
function consolidate(strings, values) {
|
|
1831
|
+
let out = "";
|
|
1832
|
+
for (let i = 0, len = values.length; i < len; i++) {
|
|
1833
|
+
out += strings[i];
|
|
1834
|
+
out += values[i];
|
|
1835
|
+
}
|
|
1836
|
+
return out + strings[strings.length - 1];
|
|
1837
|
+
}
|
|
1838
|
+
function isSuccess2(u) {
|
|
1839
|
+
return isExit(u) && u._tag === "Success";
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1842
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpServerResponse.js
|
|
1843
|
+
var HttpServerResponse_exports = {};
|
|
1844
|
+
__export(HttpServerResponse_exports, {
|
|
1845
|
+
empty: () => empty9,
|
|
1846
|
+
expireCookie: () => expireCookie2,
|
|
1847
|
+
expireCookieUnsafe: () => expireCookieUnsafe2,
|
|
1848
|
+
file: () => file2,
|
|
1849
|
+
fileWeb: () => fileWeb,
|
|
1850
|
+
formData: () => formData2,
|
|
1851
|
+
fromClientResponse: () => fromClientResponse,
|
|
1852
|
+
fromWeb: () => fromWeb3,
|
|
1853
|
+
html: () => html,
|
|
1854
|
+
htmlStream: () => htmlStream,
|
|
1855
|
+
isHttpServerResponse: () => isHttpServerResponse,
|
|
1856
|
+
json: () => json2,
|
|
1857
|
+
jsonUnsafe: () => jsonUnsafe2,
|
|
1858
|
+
mergeCookies: () => mergeCookies,
|
|
1859
|
+
omitsBody: () => omitsBody,
|
|
1860
|
+
raw: () => raw2,
|
|
1861
|
+
redirect: () => redirect,
|
|
1862
|
+
removeCookie: () => removeCookie,
|
|
1863
|
+
removeHeader: () => removeHeader2,
|
|
1864
|
+
replaceCookies: () => replaceCookies,
|
|
1865
|
+
schemaJson: () => schemaJson,
|
|
1866
|
+
setBody: () => setBody2,
|
|
1867
|
+
setBodyKeepHeaders: () => setBodyKeepHeaders,
|
|
1868
|
+
setCookie: () => setCookie,
|
|
1869
|
+
setCookieUnsafe: () => setCookieUnsafe,
|
|
1870
|
+
setCookies: () => setCookies,
|
|
1871
|
+
setCookiesUnsafe: () => setCookiesUnsafe,
|
|
1872
|
+
setHeader: () => setHeader2,
|
|
1873
|
+
setHeaders: () => setHeaders2,
|
|
1874
|
+
setStatus: () => setStatus,
|
|
1875
|
+
stream: () => stream3,
|
|
1876
|
+
text: () => text2,
|
|
1877
|
+
toClientResponse: () => toClientResponse,
|
|
1878
|
+
toWeb: () => toWeb2,
|
|
1879
|
+
uint8Array: () => uint8Array2,
|
|
1880
|
+
updateCookies: () => updateCookies,
|
|
1881
|
+
urlParams: () => urlParams2
|
|
1882
|
+
});
|
|
1883
|
+
|
|
1884
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/internal/headers.js
|
|
1885
|
+
var Proto4 = /* @__PURE__ */ Object.getPrototypeOf(empty4);
|
|
1886
|
+
var emptyMutableUnsafe = () => Object.create(Proto4);
|
|
1887
|
+
|
|
1888
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpServerResponse.js
|
|
1889
|
+
var TypeId7 = "~effect/http/HttpServerResponse";
|
|
1890
|
+
var isHttpServerResponse = (u) => hasProperty(u, TypeId7);
|
|
1891
|
+
var empty9 = (options3) => makeResponse({
|
|
1892
|
+
status: options3?.status ?? 204,
|
|
1893
|
+
statusText: options3?.statusText,
|
|
1894
|
+
headers: options3?.headers ? fromInput2(options3.headers) : void 0,
|
|
1895
|
+
cookies: options3?.cookies
|
|
1896
|
+
});
|
|
1897
|
+
var redirect = (location2, options3) => {
|
|
1898
|
+
const headers = fromRecordUnsafe({
|
|
1899
|
+
location: location2.toString()
|
|
1900
|
+
});
|
|
1901
|
+
return makeResponse({
|
|
1902
|
+
status: options3?.status ?? 302,
|
|
1903
|
+
statusText: options3?.statusText,
|
|
1904
|
+
headers: options3?.headers ? merge3(headers, fromInput2(options3.headers)) : headers,
|
|
1905
|
+
cookies: options3?.cookies ?? empty3
|
|
1906
|
+
});
|
|
1907
|
+
};
|
|
1908
|
+
var uint8Array2 = (body, options3) => {
|
|
1909
|
+
const headers = options3?.headers ? fromInput2(options3.headers) : empty4;
|
|
1910
|
+
return makeResponse({
|
|
1911
|
+
status: options3?.status ?? 200,
|
|
1912
|
+
statusText: options3?.statusText,
|
|
1913
|
+
headers,
|
|
1914
|
+
cookies: options3?.cookies ?? empty3,
|
|
1915
|
+
body: uint8Array(body, getContentType(options3, headers))
|
|
1916
|
+
});
|
|
1917
|
+
};
|
|
1918
|
+
var getContentType = (options3, headers) => {
|
|
1919
|
+
if (options3?.contentType) {
|
|
1920
|
+
return options3.contentType;
|
|
1921
|
+
} else if (options3?.headers) {
|
|
1922
|
+
return headers["content-type"];
|
|
1923
|
+
}
|
|
1924
|
+
};
|
|
1925
|
+
var text2 = (body, options3) => {
|
|
1926
|
+
const headers = options3?.headers ? fromInput2(options3.headers) : empty4;
|
|
1927
|
+
return makeResponse({
|
|
1928
|
+
status: options3?.status ?? 200,
|
|
1929
|
+
statusText: options3?.statusText,
|
|
1930
|
+
headers,
|
|
1931
|
+
cookies: options3?.cookies ?? empty3,
|
|
1932
|
+
body: text(body, getContentType(options3, headers))
|
|
1933
|
+
});
|
|
1934
|
+
};
|
|
1935
|
+
var html = (strings, ...args) => {
|
|
1936
|
+
if (typeof strings === "string") {
|
|
1937
|
+
return text2(strings, {
|
|
1938
|
+
contentType: "text/html"
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
return map(make4(strings, ...args), (_) => text2(_, {
|
|
1942
|
+
contentType: "text/html"
|
|
1943
|
+
}));
|
|
1944
|
+
};
|
|
1945
|
+
var htmlStream = (strings, ...args) => map(context(), (context2) => stream3(provideContext(encodeText(stream2(strings, ...args)), context2), {
|
|
1946
|
+
contentType: "text/html"
|
|
1947
|
+
}));
|
|
1948
|
+
var json2 = (body, options3) => {
|
|
1949
|
+
const headers = options3?.headers ? fromInput2(options3.headers) : empty4;
|
|
1950
|
+
return map(json(body, getContentType(options3, headers)), (body2) => makeResponse({
|
|
1951
|
+
status: options3?.status ?? 200,
|
|
1952
|
+
statusText: options3?.statusText,
|
|
1953
|
+
headers,
|
|
1954
|
+
cookies: options3?.cookies,
|
|
1955
|
+
body: body2
|
|
1956
|
+
}));
|
|
1957
|
+
};
|
|
1958
|
+
var schemaJson = (schema, options3) => {
|
|
1959
|
+
const encode = jsonSchema(schema, options3);
|
|
1960
|
+
return (body, options4) => {
|
|
1961
|
+
const headers = options4?.headers ? fromInput2(options4.headers) : empty4;
|
|
1962
|
+
return map(encode(body, getContentType(options4, headers)), (body2) => makeResponse({
|
|
1963
|
+
status: options4?.status ?? 200,
|
|
1964
|
+
statusText: options4?.statusText,
|
|
1965
|
+
headers,
|
|
1966
|
+
cookies: options4?.cookies,
|
|
1967
|
+
body: body2
|
|
1968
|
+
}));
|
|
1969
|
+
};
|
|
1970
|
+
};
|
|
1971
|
+
var jsonUnsafe2 = (body, options3) => {
|
|
1972
|
+
const headers = options3?.headers ? fromInput2(options3.headers) : empty4;
|
|
1973
|
+
return makeResponse({
|
|
1974
|
+
status: options3?.status ?? 200,
|
|
1975
|
+
statusText: options3?.statusText,
|
|
1976
|
+
headers,
|
|
1977
|
+
cookies: options3?.cookies,
|
|
1978
|
+
body: jsonUnsafe(body, getContentType(options3, headers))
|
|
1979
|
+
});
|
|
1980
|
+
};
|
|
1981
|
+
var urlParams2 = (body, options3) => {
|
|
1982
|
+
const headers = options3?.headers ? fromInput2(options3.headers) : empty4;
|
|
1983
|
+
return makeResponse({
|
|
1984
|
+
status: options3?.status ?? 200,
|
|
1985
|
+
statusText: options3?.statusText,
|
|
1986
|
+
headers,
|
|
1987
|
+
cookies: options3?.cookies,
|
|
1988
|
+
body: text(toString(fromInput3(body)), getContentType(options3, headers) ?? "application/x-www-form-urlencoded")
|
|
1989
|
+
});
|
|
1990
|
+
};
|
|
1991
|
+
var raw2 = (body, options3) => makeResponse({
|
|
1992
|
+
status: options3?.status ?? 200,
|
|
1993
|
+
statusText: options3?.statusText,
|
|
1994
|
+
headers: options3?.headers && fromInput2(options3.headers),
|
|
1995
|
+
cookies: options3?.cookies,
|
|
1996
|
+
body: raw(body, {
|
|
1997
|
+
contentType: options3?.contentType,
|
|
1998
|
+
contentLength: options3?.contentLength
|
|
1999
|
+
})
|
|
2000
|
+
});
|
|
2001
|
+
var formData2 = (body, options3) => makeResponse({
|
|
2002
|
+
status: options3?.status ?? 200,
|
|
2003
|
+
statusText: options3?.statusText,
|
|
2004
|
+
headers: options3?.headers && fromInput2(options3.headers),
|
|
2005
|
+
cookies: options3?.cookies,
|
|
2006
|
+
body: formData(body)
|
|
2007
|
+
});
|
|
2008
|
+
var stream3 = (body, options3) => {
|
|
2009
|
+
const headers = options3?.headers ? fromInput2(options3.headers) : empty4;
|
|
2010
|
+
return makeResponse({
|
|
2011
|
+
status: options3?.status ?? 200,
|
|
2012
|
+
statusText: options3?.statusText,
|
|
2013
|
+
headers,
|
|
2014
|
+
cookies: options3?.cookies,
|
|
2015
|
+
body: stream(body, getContentType(options3, headers), options3?.contentLength)
|
|
2016
|
+
});
|
|
2017
|
+
};
|
|
2018
|
+
var HttpPlatformKey = /* @__PURE__ */ Service("effect/http/HttpPlatform");
|
|
2019
|
+
var file2 = (path, options3) => flatMap(HttpPlatformKey, (platform) => platform.fileResponse(path, options3));
|
|
2020
|
+
var fileWeb = (file3, options3) => flatMap(HttpPlatformKey, (platform) => platform.fileWebResponse(file3, options3));
|
|
2021
|
+
var setHeader2 = /* @__PURE__ */ dual(3, (self, key, value) => makeResponse(self, set2(self.headers, key, value)));
|
|
2022
|
+
var removeHeader2 = /* @__PURE__ */ dual(2, (self, key) => makeResponse({
|
|
2023
|
+
...self,
|
|
2024
|
+
headers: remove2(self.headers, key)
|
|
2025
|
+
}));
|
|
2026
|
+
var setHeaders2 = /* @__PURE__ */ dual(2, (self, input) => makeResponse(self, setAll2(self.headers, input)));
|
|
2027
|
+
var removeCookie = /* @__PURE__ */ dual(2, (self, name) => makeResponse({
|
|
2028
|
+
...self,
|
|
2029
|
+
cookies: remove(self.cookies, name)
|
|
2030
|
+
}));
|
|
2031
|
+
var replaceCookies = /* @__PURE__ */ dual(2, (self, cookies) => makeResponse({
|
|
2032
|
+
...self,
|
|
2033
|
+
cookies
|
|
2034
|
+
}));
|
|
2035
|
+
var setCookie = /* @__PURE__ */ dual((args) => isHttpServerResponse(args[0]), (self, name, value, options3) => map(fromResult(set(self.cookies, name, value, options3)), (cookies) => makeResponse({
|
|
2036
|
+
...self,
|
|
2037
|
+
cookies
|
|
2038
|
+
})));
|
|
2039
|
+
var expireCookie2 = /* @__PURE__ */ dual((args) => isHttpServerResponse(args[0]), (self, name, options3) => map(fromResult(expireCookie(self.cookies, name, options3)), (cookies) => makeResponse({
|
|
2040
|
+
...self,
|
|
2041
|
+
cookies
|
|
2042
|
+
})));
|
|
2043
|
+
var setCookieUnsafe = /* @__PURE__ */ dual((args) => isHttpServerResponse(args[0]), (self, name, value, options3) => makeResponse({
|
|
2044
|
+
...self,
|
|
2045
|
+
cookies: setUnsafe(self.cookies, name, value, options3)
|
|
2046
|
+
}));
|
|
2047
|
+
var expireCookieUnsafe2 = /* @__PURE__ */ dual((args) => isHttpServerResponse(args[0]), (self, name, options3) => makeResponse({
|
|
2048
|
+
...self,
|
|
2049
|
+
cookies: expireCookieUnsafe(self.cookies, name, options3)
|
|
2050
|
+
}));
|
|
2051
|
+
var updateCookies = /* @__PURE__ */ dual(2, (self, f) => makeResponse({
|
|
2052
|
+
...self,
|
|
2053
|
+
cookies: f(self.cookies)
|
|
2054
|
+
}));
|
|
2055
|
+
var mergeCookies = /* @__PURE__ */ dual(2, (self, cookies) => makeResponse({
|
|
2056
|
+
...self,
|
|
2057
|
+
cookies: merge2(self.cookies, cookies)
|
|
2058
|
+
}));
|
|
2059
|
+
var setCookies = /* @__PURE__ */ dual(2, (self, cookies) => map(fromResult(setAll(self.cookies, cookies)), (cookies2) => makeResponse({
|
|
2060
|
+
...self,
|
|
2061
|
+
cookies: cookies2
|
|
2062
|
+
})));
|
|
2063
|
+
var setCookiesUnsafe = /* @__PURE__ */ dual(2, (self, cookies) => makeResponse({
|
|
2064
|
+
...self,
|
|
2065
|
+
cookies: setAllUnsafe(self.cookies, cookies)
|
|
2066
|
+
}));
|
|
2067
|
+
var setBody2 = /* @__PURE__ */ dual(2, (self, body) => makeResponse({
|
|
2068
|
+
...self,
|
|
2069
|
+
body
|
|
2070
|
+
}, updateHeaders(self.headers, body)));
|
|
2071
|
+
var setBodyKeepHeaders = (self, body) => {
|
|
2072
|
+
const response = Object.create(Proto5);
|
|
2073
|
+
response.status = self.status;
|
|
2074
|
+
response.statusText = self.statusText;
|
|
2075
|
+
response.headers = self.headers;
|
|
2076
|
+
response.cookies = self.cookies;
|
|
2077
|
+
response.body = body;
|
|
2078
|
+
return response;
|
|
2079
|
+
};
|
|
2080
|
+
var setStatus = /* @__PURE__ */ dual((args) => isHttpServerResponse(args[0]), (self, status, statusText) => makeResponse({
|
|
2081
|
+
...self,
|
|
2082
|
+
status,
|
|
2083
|
+
statusText: statusText ?? self.statusText
|
|
2084
|
+
}));
|
|
2085
|
+
var omitsBody = (response, withoutBody = false) => withoutBody || response.status === 204 || response.status === 205 || response.status === 304;
|
|
2086
|
+
var toWeb2 = (response, options3) => {
|
|
2087
|
+
const headers = new globalThis.Headers(response.headers);
|
|
2088
|
+
if (!isEmpty(response.cookies)) {
|
|
2089
|
+
const toAdd = toSetCookieHeaders(response.cookies);
|
|
2090
|
+
for (const header of toAdd) {
|
|
2091
|
+
headers.append("set-cookie", header);
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
const body = response.body;
|
|
2095
|
+
const outerOmitsBody = omitsBody(response);
|
|
2096
|
+
const withoutBody = outerOmitsBody || options3?.withoutBody === true;
|
|
2097
|
+
if (body._tag === "Raw" && body.body instanceof Response) {
|
|
2098
|
+
const raw3 = body.body;
|
|
2099
|
+
for (const [key, value] of headers) {
|
|
2100
|
+
if (key === "set-cookie") {
|
|
2101
|
+
raw3.headers.append(key, value);
|
|
2102
|
+
} else {
|
|
2103
|
+
raw3.headers.set(key, value);
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
if (!withoutBody) {
|
|
2107
|
+
return raw3;
|
|
2108
|
+
}
|
|
2109
|
+
const source = outerOmitsBody ? response : raw3;
|
|
2110
|
+
return new Response(void 0, {
|
|
2111
|
+
status: source.status,
|
|
2112
|
+
statusText: source.statusText,
|
|
2113
|
+
headers: raw3.headers
|
|
2114
|
+
});
|
|
2115
|
+
}
|
|
2116
|
+
if (withoutBody) {
|
|
2117
|
+
if (body._tag === "Raw" && isReadableStream2(body.body)) {
|
|
2118
|
+
body.body.cancel().catch(constVoid);
|
|
2119
|
+
}
|
|
2120
|
+
return new Response(void 0, {
|
|
2121
|
+
status: response.status,
|
|
2122
|
+
statusText: response.statusText,
|
|
2123
|
+
headers
|
|
2124
|
+
});
|
|
2125
|
+
}
|
|
2126
|
+
switch (body._tag) {
|
|
2127
|
+
case "Empty": {
|
|
2128
|
+
return new Response(void 0, {
|
|
2129
|
+
status: response.status,
|
|
2130
|
+
statusText: response.statusText,
|
|
2131
|
+
headers
|
|
2132
|
+
});
|
|
2133
|
+
}
|
|
2134
|
+
case "Uint8Array": {
|
|
2135
|
+
return new Response(body.text ?? body.body, {
|
|
2136
|
+
status: response.status,
|
|
2137
|
+
statusText: response.statusText,
|
|
2138
|
+
headers
|
|
2139
|
+
});
|
|
2140
|
+
}
|
|
2141
|
+
case "Raw": {
|
|
2142
|
+
return new Response(body.body, {
|
|
2143
|
+
status: response.status,
|
|
2144
|
+
statusText: response.statusText,
|
|
2145
|
+
headers
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
case "FormData": {
|
|
2149
|
+
return new Response(body.formData, {
|
|
2150
|
+
status: response.status,
|
|
2151
|
+
statusText: response.statusText,
|
|
2152
|
+
headers
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
case "Stream": {
|
|
2156
|
+
return new Response(toReadableStreamWith(body.stream, options3?.context ?? empty2()), {
|
|
2157
|
+
status: response.status,
|
|
2158
|
+
statusText: response.statusText,
|
|
2159
|
+
headers
|
|
2160
|
+
});
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
};
|
|
2164
|
+
var toClientResponse = (response, options3) => new ServerHttpClientResponse(options3?.request ?? empty8, response);
|
|
2165
|
+
var ServerHttpClientResponse = class extends Class {
|
|
2166
|
+
[TypeId4];
|
|
2167
|
+
[TypeId5];
|
|
2168
|
+
request;
|
|
2169
|
+
response;
|
|
2170
|
+
constructor(request, response) {
|
|
2171
|
+
super();
|
|
2172
|
+
this.request = request;
|
|
2173
|
+
this.response = response;
|
|
2174
|
+
this[TypeId4] = TypeId4;
|
|
2175
|
+
this[TypeId5] = TypeId5;
|
|
2176
|
+
}
|
|
2177
|
+
toJSON() {
|
|
2178
|
+
return inspect(this, {
|
|
2179
|
+
_id: "HttpClientResponse",
|
|
2180
|
+
request: this.request.toJSON(),
|
|
2181
|
+
status: this.status
|
|
2182
|
+
});
|
|
2183
|
+
}
|
|
2184
|
+
get status() {
|
|
2185
|
+
return this.response.status;
|
|
2186
|
+
}
|
|
2187
|
+
get url() {
|
|
2188
|
+
if (this.request === empty8) return "";
|
|
2189
|
+
const url = toUrl(this.request);
|
|
2190
|
+
if (isNone(url)) return "";
|
|
2191
|
+
url.value.hash = "";
|
|
2192
|
+
return url.value.href;
|
|
2193
|
+
}
|
|
2194
|
+
cachedHeaders;
|
|
2195
|
+
get headers() {
|
|
2196
|
+
return this.cachedHeaders ??= this.response.body._tag === "FormData" ? merge3(this.response.headers, fromInput2(this.getFormDataResponse().headers)) : this.response.headers;
|
|
2197
|
+
}
|
|
2198
|
+
get cookies() {
|
|
2199
|
+
return this.response.cookies;
|
|
2200
|
+
}
|
|
2201
|
+
get remoteAddress() {
|
|
2202
|
+
return none();
|
|
2203
|
+
}
|
|
2204
|
+
get stream() {
|
|
2205
|
+
const body = this.response.body;
|
|
2206
|
+
switch (body._tag) {
|
|
2207
|
+
case "Empty": {
|
|
2208
|
+
return empty6;
|
|
2209
|
+
}
|
|
2210
|
+
case "Stream": {
|
|
2211
|
+
return mapError3(body.stream, (cause) => this.decodeError(cause));
|
|
2212
|
+
}
|
|
2213
|
+
case "Uint8Array": {
|
|
2214
|
+
return succeed3(body.body);
|
|
2215
|
+
}
|
|
2216
|
+
case "Raw": {
|
|
2217
|
+
const rawBody = body.body;
|
|
2218
|
+
if (rawBody instanceof Response) {
|
|
2219
|
+
return rawBody.body ? fromReadableStream({
|
|
2220
|
+
evaluate: () => rawBody.body,
|
|
2221
|
+
onError: (cause) => this.decodeError(cause)
|
|
2222
|
+
}) : empty6;
|
|
2223
|
+
}
|
|
2224
|
+
if (isReadableStream2(rawBody)) {
|
|
2225
|
+
return fromReadableStream({
|
|
2226
|
+
evaluate: () => rawBody,
|
|
2227
|
+
onError: (cause) => this.decodeError(cause)
|
|
2228
|
+
});
|
|
2229
|
+
}
|
|
2230
|
+
if (rawBody instanceof Blob) {
|
|
2231
|
+
return fromReadableStream({
|
|
2232
|
+
evaluate: () => rawBody.stream(),
|
|
2233
|
+
onError: (cause) => this.decodeError(cause)
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
2236
|
+
return unwrap2(map(this.bytes, succeed3));
|
|
2237
|
+
}
|
|
2238
|
+
case "FormData": {
|
|
2239
|
+
const response = this.getFormDataResponse();
|
|
2240
|
+
return fromReadableStream({
|
|
2241
|
+
evaluate: () => response.body,
|
|
2242
|
+
onError: (cause) => this.decodeError(cause)
|
|
2243
|
+
});
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
get json() {
|
|
2248
|
+
return flatMap(this.text, (text3) => try_2({
|
|
2249
|
+
try: () => text3 === "" ? null : JSON.parse(text3),
|
|
2250
|
+
catch: (cause) => new HttpClientError({
|
|
2251
|
+
reason: new DecodeError({
|
|
2252
|
+
request: this.request,
|
|
2253
|
+
response: this,
|
|
2254
|
+
cause
|
|
2255
|
+
})
|
|
2256
|
+
})
|
|
2257
|
+
}));
|
|
2258
|
+
}
|
|
2259
|
+
get bytes() {
|
|
2260
|
+
const body = this.response.body;
|
|
2261
|
+
switch (body._tag) {
|
|
2262
|
+
case "Empty": {
|
|
2263
|
+
return succeed2(new Uint8Array(0));
|
|
2264
|
+
}
|
|
2265
|
+
case "Uint8Array": {
|
|
2266
|
+
return succeed2(body.body);
|
|
2267
|
+
}
|
|
2268
|
+
case "Stream": {
|
|
2269
|
+
return mkUint8Array2(this.stream);
|
|
2270
|
+
}
|
|
2271
|
+
case "Raw": {
|
|
2272
|
+
const rawBody = body.body;
|
|
2273
|
+
if (rawBody instanceof Response) {
|
|
2274
|
+
return tryPromise({
|
|
2275
|
+
try: () => rawBody.clone().arrayBuffer().then((buffer2) => new Uint8Array(buffer2)),
|
|
2276
|
+
catch: (cause) => this.decodeError(cause)
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
return tryPromise({
|
|
2280
|
+
try: () => new Response(rawBody).arrayBuffer().then((buffer2) => new Uint8Array(buffer2)),
|
|
2281
|
+
catch: (cause) => this.decodeError(cause)
|
|
2282
|
+
});
|
|
2283
|
+
}
|
|
2284
|
+
case "FormData": {
|
|
2285
|
+
return tryPromise({
|
|
2286
|
+
try: () => new Response(body.formData).arrayBuffer().then((buffer2) => new Uint8Array(buffer2)),
|
|
2287
|
+
catch: (cause) => this.decodeError(cause)
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
get text() {
|
|
2293
|
+
return map(this.bytes, (bytes) => textDecoder.decode(bytes));
|
|
2294
|
+
}
|
|
2295
|
+
get urlParamsBody() {
|
|
2296
|
+
return flatMap(this.text, (_) => try_2({
|
|
2297
|
+
try: () => fromInput3(new URLSearchParams(_)),
|
|
2298
|
+
catch: (cause) => new HttpClientError({
|
|
2299
|
+
reason: new DecodeError({
|
|
2300
|
+
request: this.request,
|
|
2301
|
+
response: this,
|
|
2302
|
+
cause
|
|
2303
|
+
})
|
|
2304
|
+
})
|
|
2305
|
+
}));
|
|
2306
|
+
}
|
|
2307
|
+
get formData() {
|
|
2308
|
+
const body = this.response.body;
|
|
2309
|
+
if (body._tag === "FormData") {
|
|
2310
|
+
return succeed2(body.formData);
|
|
2311
|
+
}
|
|
2312
|
+
return contextWith((context2) => {
|
|
2313
|
+
const readableStream = toReadableStreamWith(this.stream, context2);
|
|
2314
|
+
return tryPromise({
|
|
2315
|
+
try: () => new Response(readableStream, {
|
|
2316
|
+
headers: this.headers
|
|
2317
|
+
}).formData(),
|
|
2318
|
+
catch: (cause) => this.decodeError(cause)
|
|
2319
|
+
});
|
|
2320
|
+
});
|
|
2321
|
+
}
|
|
2322
|
+
get arrayBuffer() {
|
|
2323
|
+
return map(
|
|
2324
|
+
this.bytes,
|
|
2325
|
+
// Copy this view because Buffer views may share a larger ArrayBuffer.
|
|
2326
|
+
(bytes) => bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength)
|
|
2327
|
+
);
|
|
2328
|
+
}
|
|
2329
|
+
decodeError(cause) {
|
|
2330
|
+
return new HttpClientError({
|
|
2331
|
+
reason: new DecodeError({
|
|
2332
|
+
request: this.request,
|
|
2333
|
+
response: this,
|
|
2334
|
+
cause
|
|
2335
|
+
})
|
|
2336
|
+
});
|
|
2337
|
+
}
|
|
2338
|
+
formDataResponse;
|
|
2339
|
+
getFormDataResponse() {
|
|
2340
|
+
return this.formDataResponse ??= new Response(this.response.body.formData);
|
|
2341
|
+
}
|
|
2342
|
+
pipe() {
|
|
2343
|
+
return pipeArguments(this, arguments);
|
|
2344
|
+
}
|
|
2345
|
+
};
|
|
2346
|
+
var textDecoder = /* @__PURE__ */ new TextDecoder();
|
|
2347
|
+
var fromClientResponse = (response) => {
|
|
2348
|
+
const headers = remove2(response.headers, "set-cookie");
|
|
2349
|
+
return makeResponse({
|
|
2350
|
+
status: response.status,
|
|
2351
|
+
headers,
|
|
2352
|
+
cookies: response.cookies,
|
|
2353
|
+
body: stream(catchIf(response.stream, isEmptyBodyError, () => empty6), getOrUndefined(get2(headers, "content-type")), parseContentLength(headers["content-length"]))
|
|
2354
|
+
});
|
|
2355
|
+
};
|
|
2356
|
+
var isReadableStream2 = (u) => typeof ReadableStream !== "undefined" && u instanceof ReadableStream;
|
|
2357
|
+
var isEmptyBodyError = (error) => isHttpClientError(error) && error.reason._tag === "EmptyBodyError";
|
|
2358
|
+
var Proto5 = {
|
|
2359
|
+
...PipeInspectableProto,
|
|
2360
|
+
[TypeId7]: TypeId7,
|
|
2361
|
+
[ignore]: true,
|
|
2362
|
+
toJSON() {
|
|
2363
|
+
return {
|
|
2364
|
+
_id: "HttpServerResponse",
|
|
2365
|
+
status: this.status,
|
|
2366
|
+
statusText: this.statusText,
|
|
2367
|
+
headers: redact(this.headers),
|
|
2368
|
+
cookies: this.cookies.toJSON(),
|
|
2369
|
+
body: this.body.toJSON()
|
|
2370
|
+
};
|
|
2371
|
+
}
|
|
2372
|
+
};
|
|
2373
|
+
var makeResponse = (options3, ownedHeaders) => {
|
|
2374
|
+
const self = Object.create(Proto5);
|
|
2375
|
+
self.status = options3.status;
|
|
2376
|
+
self.statusText = options3.statusText;
|
|
2377
|
+
self.cookies = options3.cookies ?? empty3;
|
|
2378
|
+
self.body = options3.body ?? empty7;
|
|
2379
|
+
if (self.body._tag !== "Empty" && (self.body.contentType || self.body.contentLength !== void 0)) {
|
|
2380
|
+
const owned = ownedHeaders !== void 0;
|
|
2381
|
+
const newHeaders = owned ? ownedHeaders : options3.headers === void 0 || options3.headers === empty4 ? emptyMutableUnsafe() : fromRecordUnsafe({
|
|
2382
|
+
...options3.headers
|
|
2383
|
+
});
|
|
2384
|
+
if (self.body.contentType && (!owned || newHeaders["content-type"] === void 0)) {
|
|
2385
|
+
newHeaders["content-type"] = self.body.contentType;
|
|
2386
|
+
}
|
|
2387
|
+
if (self.body.contentLength !== void 0 && (!owned || newHeaders["content-length"] === void 0)) {
|
|
2388
|
+
newHeaders["content-length"] = self.body.contentLength.toString();
|
|
2389
|
+
}
|
|
2390
|
+
self.headers = newHeaders;
|
|
2391
|
+
} else {
|
|
2392
|
+
self.headers = ownedHeaders ?? options3.headers ?? empty4;
|
|
2393
|
+
}
|
|
2394
|
+
return self;
|
|
2395
|
+
};
|
|
2396
|
+
var fromWeb3 = (response) => {
|
|
2397
|
+
const headers = new globalThis.Headers(response.headers);
|
|
2398
|
+
const setCookieHeaders = headers.getSetCookie();
|
|
2399
|
+
headers.delete("set-cookie");
|
|
2400
|
+
let self = empty9({
|
|
2401
|
+
status: response.status,
|
|
2402
|
+
statusText: response.statusText,
|
|
2403
|
+
headers,
|
|
2404
|
+
cookies: fromSetCookie(setCookieHeaders)
|
|
2405
|
+
});
|
|
2406
|
+
if (response.body) {
|
|
2407
|
+
const contentType = response.headers.get("content-type");
|
|
2408
|
+
self = setBody2(self, stream(fromReadableStream({
|
|
2409
|
+
evaluate: () => response.body,
|
|
2410
|
+
onError: (e) => e
|
|
2411
|
+
}), contentType ?? void 0, parseContentLength(response.headers.get("content-length"))));
|
|
2412
|
+
}
|
|
2413
|
+
return self;
|
|
2414
|
+
};
|
|
2415
|
+
|
|
2416
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpServerRespondable.js
|
|
2417
|
+
var symbol = "~effect/http/HttpServerRespondable";
|
|
2418
|
+
|
|
2419
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpServerError.js
|
|
2420
|
+
var TypeId8 = "~effect/http/HttpServerError";
|
|
2421
|
+
var HttpServerError = class extends (/* @__PURE__ */ TaggedError("HttpServerError")) {
|
|
2422
|
+
constructor(props) {
|
|
2423
|
+
if ("cause" in props.reason) {
|
|
2424
|
+
super({
|
|
2425
|
+
...props,
|
|
2426
|
+
cause: props.reason.cause
|
|
2427
|
+
});
|
|
2428
|
+
} else {
|
|
2429
|
+
super(props);
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
[TypeId8] = TypeId8;
|
|
2433
|
+
stack = `${this.name}: ${this.message}`;
|
|
2434
|
+
get request() {
|
|
2435
|
+
return this.reason.request;
|
|
2436
|
+
}
|
|
2437
|
+
get response() {
|
|
2438
|
+
return "response" in this.reason ? this.reason.response : void 0;
|
|
2439
|
+
}
|
|
2440
|
+
[symbol]() {
|
|
2441
|
+
return this.reason[symbol]();
|
|
2442
|
+
}
|
|
2443
|
+
get [ignore]() {
|
|
2444
|
+
return this.reason[ignore] ?? false;
|
|
2445
|
+
}
|
|
2446
|
+
get message() {
|
|
2447
|
+
return this.reason.message;
|
|
2448
|
+
}
|
|
2449
|
+
};
|
|
2450
|
+
var RequestParseError = class extends (/* @__PURE__ */ TaggedError("RequestParseError")) {
|
|
2451
|
+
/**
|
|
2452
|
+
* Converts the request error into a `400 Bad Request` response.
|
|
2453
|
+
*
|
|
2454
|
+
* @since 4.0.0
|
|
2455
|
+
*/
|
|
2456
|
+
[symbol]() {
|
|
2457
|
+
return succeed2(empty9({
|
|
2458
|
+
status: 400
|
|
2459
|
+
}));
|
|
2460
|
+
}
|
|
2461
|
+
get methodAndUrl() {
|
|
2462
|
+
return `${this.request.method} ${this.request.url}`;
|
|
2463
|
+
}
|
|
2464
|
+
get message() {
|
|
2465
|
+
return formatRequestMessage(this._tag, this.description, this.methodAndUrl);
|
|
2466
|
+
}
|
|
2467
|
+
};
|
|
2468
|
+
var RouteNotFound = class extends (/* @__PURE__ */ TaggedError("RouteNotFound")) {
|
|
2469
|
+
[symbol]() {
|
|
2470
|
+
return succeed2(empty9({
|
|
2471
|
+
status: 404
|
|
2472
|
+
}));
|
|
2473
|
+
}
|
|
2474
|
+
[ignore] = true;
|
|
2475
|
+
get methodAndUrl() {
|
|
2476
|
+
return `${this.request.method} ${this.request.url}`;
|
|
2477
|
+
}
|
|
2478
|
+
get message() {
|
|
2479
|
+
return formatRequestMessage(this._tag, this.description, this.methodAndUrl);
|
|
2480
|
+
}
|
|
2481
|
+
};
|
|
2482
|
+
var InternalError = class extends (/* @__PURE__ */ TaggedError("InternalError")) {
|
|
2483
|
+
/**
|
|
2484
|
+
* Converts the server error into a `500 Internal Server Error` response.
|
|
2485
|
+
*
|
|
2486
|
+
* @since 4.0.0
|
|
2487
|
+
*/
|
|
2488
|
+
[symbol]() {
|
|
2489
|
+
return succeed2(empty9({
|
|
2490
|
+
status: 500
|
|
2491
|
+
}));
|
|
2492
|
+
}
|
|
2493
|
+
get methodAndUrl() {
|
|
2494
|
+
return `${this.request.method} ${this.request.url}`;
|
|
2495
|
+
}
|
|
2496
|
+
get message() {
|
|
2497
|
+
return formatRequestMessage(this._tag, this.description, this.methodAndUrl);
|
|
2498
|
+
}
|
|
2499
|
+
};
|
|
2500
|
+
var ResponseError = class extends (/* @__PURE__ */ TaggedError("ResponseError")) {
|
|
2501
|
+
[symbol]() {
|
|
2502
|
+
return succeed2(empty9({
|
|
2503
|
+
status: 500
|
|
2504
|
+
}));
|
|
2505
|
+
}
|
|
2506
|
+
get methodAndUrl() {
|
|
2507
|
+
return `${this.request.method} ${this.request.url}`;
|
|
2508
|
+
}
|
|
2509
|
+
get message() {
|
|
2510
|
+
const info = `${this._tag} (${this.response.status} ${this.methodAndUrl})`;
|
|
2511
|
+
return this.description ? `${info}: ${this.description}` : info;
|
|
2512
|
+
}
|
|
2513
|
+
};
|
|
2514
|
+
var formatRequestMessage = (reason, description, info) => {
|
|
2515
|
+
const prefix = `${reason} (${info})`;
|
|
2516
|
+
return description ? `${prefix}: ${description}` : prefix;
|
|
2517
|
+
};
|
|
2518
|
+
|
|
2519
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/MultipartParser/internal/contentType.js
|
|
2520
|
+
var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u{10ffff}]|\\[\v\u0020-\u{10ffff}])*"|[!#$%&'*+.^\w`|~-]+) */gu;
|
|
2521
|
+
var quotedPairRE = /\\([\v\u0020-\u{10ffff}])/gu;
|
|
2522
|
+
var mediaTypeRE = /^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u;
|
|
2523
|
+
var mediaTypeRENoSlash = /^[!#$%&'*+.^\w|~-]+$/u;
|
|
2524
|
+
var defaultContentType = {
|
|
2525
|
+
value: "",
|
|
2526
|
+
parameters: /* @__PURE__ */ Object.create(null)
|
|
2527
|
+
};
|
|
2528
|
+
function parse(header, withoutSlash = false) {
|
|
2529
|
+
if (typeof header !== "string") {
|
|
2530
|
+
return defaultContentType;
|
|
2531
|
+
}
|
|
2532
|
+
let index = header.indexOf(";");
|
|
2533
|
+
const type = index !== -1 ? header.slice(0, index).trim() : header.trim();
|
|
2534
|
+
const mediaRE = withoutSlash ? mediaTypeRENoSlash : mediaTypeRE;
|
|
2535
|
+
if (mediaRE.test(type) === false) {
|
|
2536
|
+
return defaultContentType;
|
|
2537
|
+
}
|
|
2538
|
+
const result = {
|
|
2539
|
+
value: type.toLowerCase(),
|
|
2540
|
+
parameters: /* @__PURE__ */ Object.create(null)
|
|
2541
|
+
};
|
|
2542
|
+
if (index === -1) {
|
|
2543
|
+
return result;
|
|
2544
|
+
}
|
|
2545
|
+
let key;
|
|
2546
|
+
let match2;
|
|
2547
|
+
let value;
|
|
2548
|
+
paramRE.lastIndex = index;
|
|
2549
|
+
while (match2 = paramRE.exec(header)) {
|
|
2550
|
+
if (match2.index !== index) {
|
|
2551
|
+
return defaultContentType;
|
|
2552
|
+
}
|
|
2553
|
+
index += match2[0].length;
|
|
2554
|
+
key = match2[1].toLowerCase();
|
|
2555
|
+
value = match2[2];
|
|
2556
|
+
if (value[0] === '"') {
|
|
2557
|
+
value = value.slice(1, value.length - 1);
|
|
2558
|
+
if (!withoutSlash && quotedPairRE.test(value)) {
|
|
2559
|
+
value = value.replace(quotedPairRE, "$1");
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
result.parameters[key] = value;
|
|
2563
|
+
}
|
|
2564
|
+
if (index !== header.length) {
|
|
2565
|
+
return defaultContentType;
|
|
2566
|
+
}
|
|
2567
|
+
return result;
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/MultipartParser/internal/headers.js
|
|
2571
|
+
var constMaxPairs = 100;
|
|
2572
|
+
var constMaxSize = 16 * 1024;
|
|
2573
|
+
var State = {
|
|
2574
|
+
key: 0,
|
|
2575
|
+
whitespace: 1,
|
|
2576
|
+
value: 2
|
|
2577
|
+
};
|
|
2578
|
+
var constContinue = {
|
|
2579
|
+
_tag: "Continue"
|
|
2580
|
+
};
|
|
2581
|
+
var constNameChars = /* @__PURE__ */ new Uint8Array(256);
|
|
2582
|
+
for (const char of "!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") {
|
|
2583
|
+
constNameChars[/* @__PURE__ */ char.charCodeAt(0)] = 1;
|
|
2584
|
+
}
|
|
2585
|
+
var constValueChars = /* @__PURE__ */ new Uint8Array(256);
|
|
2586
|
+
constValueChars[9] = 1;
|
|
2587
|
+
for (let i = 32; i <= 126; i++) {
|
|
2588
|
+
constValueChars[i] = 1;
|
|
2589
|
+
}
|
|
2590
|
+
for (let i = 128; i <= 255; i++) {
|
|
2591
|
+
constValueChars[i] = 1;
|
|
2592
|
+
}
|
|
2593
|
+
function make5() {
|
|
2594
|
+
const decoder = new TextDecoder();
|
|
2595
|
+
const state = {
|
|
2596
|
+
state: State.key,
|
|
2597
|
+
headers: /* @__PURE__ */ Object.create(null),
|
|
2598
|
+
key: "",
|
|
2599
|
+
value: void 0,
|
|
2600
|
+
crlf: 0,
|
|
2601
|
+
previousChunk: void 0,
|
|
2602
|
+
pairs: 0,
|
|
2603
|
+
size: 0
|
|
2604
|
+
};
|
|
2605
|
+
function reset(value) {
|
|
2606
|
+
state.state = State.key;
|
|
2607
|
+
state.headers = /* @__PURE__ */ Object.create(null);
|
|
2608
|
+
state.key = "";
|
|
2609
|
+
state.value = void 0;
|
|
2610
|
+
state.crlf = 0;
|
|
2611
|
+
state.previousChunk = void 0;
|
|
2612
|
+
state.pairs = 0;
|
|
2613
|
+
state.size = 0;
|
|
2614
|
+
return value;
|
|
2615
|
+
}
|
|
2616
|
+
function concatUint8Array(a, b) {
|
|
2617
|
+
const newUint8Array = new Uint8Array(a.length + b.length);
|
|
2618
|
+
newUint8Array.set(a);
|
|
2619
|
+
newUint8Array.set(b, a.length);
|
|
2620
|
+
return newUint8Array;
|
|
2621
|
+
}
|
|
2622
|
+
function error(reason) {
|
|
2623
|
+
return reset({
|
|
2624
|
+
_tag: "Failure",
|
|
2625
|
+
reason,
|
|
2626
|
+
headers: state.headers
|
|
2627
|
+
});
|
|
2628
|
+
}
|
|
2629
|
+
return function write(chunk, start) {
|
|
2630
|
+
let endOffset = 0;
|
|
2631
|
+
let previousCursor;
|
|
2632
|
+
if (state.previousChunk !== void 0) {
|
|
2633
|
+
endOffset = state.previousChunk.length;
|
|
2634
|
+
previousCursor = endOffset;
|
|
2635
|
+
const newChunk = new Uint8Array(chunk.length + endOffset);
|
|
2636
|
+
newChunk.set(state.previousChunk);
|
|
2637
|
+
newChunk.set(chunk, endOffset);
|
|
2638
|
+
state.previousChunk = void 0;
|
|
2639
|
+
chunk = newChunk;
|
|
2640
|
+
}
|
|
2641
|
+
const end = chunk.length;
|
|
2642
|
+
outer: while (start < end) {
|
|
2643
|
+
if (state.state === State.key) {
|
|
2644
|
+
let i = start;
|
|
2645
|
+
for (; i < end; i++) {
|
|
2646
|
+
if (state.size++ > constMaxSize) {
|
|
2647
|
+
return error("HeaderTooLarge");
|
|
2648
|
+
}
|
|
2649
|
+
if (chunk[i] === 58) {
|
|
2650
|
+
state.key += decoder.decode(chunk.subarray(start, i)).toLowerCase();
|
|
2651
|
+
if (state.key.length === 0) {
|
|
2652
|
+
return error("InvalidHeaderName");
|
|
2653
|
+
}
|
|
2654
|
+
if (chunk[i + 1] === 32 && chunk[i + 2] !== 32 && chunk[i + 2] !== 9) {
|
|
2655
|
+
start = i + 2;
|
|
2656
|
+
state.state = State.value;
|
|
2657
|
+
state.size++;
|
|
2658
|
+
} else if (chunk[i + 1] !== 32 && chunk[i + 1] !== 9) {
|
|
2659
|
+
start = i + 1;
|
|
2660
|
+
state.state = State.value;
|
|
2661
|
+
} else {
|
|
2662
|
+
start = i + 1;
|
|
2663
|
+
state.state = State.whitespace;
|
|
2664
|
+
}
|
|
2665
|
+
break;
|
|
2666
|
+
} else if (constNameChars[chunk[i]] !== 1) {
|
|
2667
|
+
return error("InvalidHeaderName");
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
if (i === end) {
|
|
2671
|
+
state.key += decoder.decode(chunk.subarray(start, end)).toLowerCase();
|
|
2672
|
+
return constContinue;
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
if (state.state === State.whitespace) {
|
|
2676
|
+
for (; start < end; start++) {
|
|
2677
|
+
if (state.size++ > constMaxSize) {
|
|
2678
|
+
return error("HeaderTooLarge");
|
|
2679
|
+
}
|
|
2680
|
+
if (chunk[start] !== 32 && chunk[start] !== 9) {
|
|
2681
|
+
state.state = State.value;
|
|
2682
|
+
break;
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
if (start === end) {
|
|
2686
|
+
return constContinue;
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2689
|
+
if (state.state === State.value) {
|
|
2690
|
+
let i = start;
|
|
2691
|
+
if (previousCursor !== void 0) {
|
|
2692
|
+
i = previousCursor;
|
|
2693
|
+
previousCursor = void 0;
|
|
2694
|
+
}
|
|
2695
|
+
for (; i < end; i++) {
|
|
2696
|
+
if (state.size++ > constMaxSize) {
|
|
2697
|
+
return error("HeaderTooLarge");
|
|
2698
|
+
}
|
|
2699
|
+
if (chunk[i] === 13 || state.crlf > 0) {
|
|
2700
|
+
let byte = chunk[i];
|
|
2701
|
+
if (byte === 13 && state.crlf === 0) {
|
|
2702
|
+
state.crlf = 1;
|
|
2703
|
+
i++;
|
|
2704
|
+
state.size++;
|
|
2705
|
+
byte = chunk[i];
|
|
2706
|
+
}
|
|
2707
|
+
if (byte === 10 && state.crlf === 1) {
|
|
2708
|
+
state.crlf = 2;
|
|
2709
|
+
i++;
|
|
2710
|
+
state.size++;
|
|
2711
|
+
byte = chunk[i];
|
|
2712
|
+
}
|
|
2713
|
+
if (byte === 13 && state.crlf === 2) {
|
|
2714
|
+
state.crlf = 3;
|
|
2715
|
+
i++;
|
|
2716
|
+
state.size++;
|
|
2717
|
+
byte = chunk[i];
|
|
2718
|
+
}
|
|
2719
|
+
if (byte === 10 && state.crlf === 3) {
|
|
2720
|
+
state.crlf = 4;
|
|
2721
|
+
i++;
|
|
2722
|
+
state.size++;
|
|
2723
|
+
}
|
|
2724
|
+
if (state.crlf < 4 && i >= end) {
|
|
2725
|
+
state.previousChunk = chunk.subarray(start);
|
|
2726
|
+
return constContinue;
|
|
2727
|
+
} else if (state.crlf >= 2) {
|
|
2728
|
+
state.value = state.value === void 0 ? chunk.subarray(start, i - state.crlf) : concatUint8Array(state.value, chunk.subarray(start, i - state.crlf));
|
|
2729
|
+
const value = decoder.decode(state.value);
|
|
2730
|
+
if (state.headers[state.key] === void 0) {
|
|
2731
|
+
state.headers[state.key] = value;
|
|
2732
|
+
} else if (typeof state.headers[state.key] === "string") {
|
|
2733
|
+
state.headers[state.key] = [state.headers[state.key], value];
|
|
2734
|
+
} else {
|
|
2735
|
+
;
|
|
2736
|
+
state.headers[state.key].push(value);
|
|
2737
|
+
}
|
|
2738
|
+
start = i;
|
|
2739
|
+
state.size--;
|
|
2740
|
+
if (state.crlf !== 4 && state.pairs === constMaxPairs) {
|
|
2741
|
+
return error("TooManyHeaders");
|
|
2742
|
+
} else if (state.crlf === 3) {
|
|
2743
|
+
return error("InvalidHeaderValue");
|
|
2744
|
+
} else if (state.crlf === 4) {
|
|
2745
|
+
return reset({
|
|
2746
|
+
_tag: "Headers",
|
|
2747
|
+
headers: state.headers,
|
|
2748
|
+
endPosition: start - endOffset
|
|
2749
|
+
});
|
|
2750
|
+
}
|
|
2751
|
+
state.pairs++;
|
|
2752
|
+
state.key = "";
|
|
2753
|
+
state.value = void 0;
|
|
2754
|
+
state.crlf = 0;
|
|
2755
|
+
state.state = State.key;
|
|
2756
|
+
continue outer;
|
|
2757
|
+
}
|
|
2758
|
+
} else if (constValueChars[chunk[i]] !== 1) {
|
|
2759
|
+
return error("InvalidHeaderValue");
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
if (i === end) {
|
|
2763
|
+
state.value = state.value === void 0 ? chunk.subarray(start, end) : concatUint8Array(state.value, chunk.subarray(start, end));
|
|
2764
|
+
return constContinue;
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
if (start > end) {
|
|
2769
|
+
state.size += end - start;
|
|
2770
|
+
}
|
|
2771
|
+
return constContinue;
|
|
2772
|
+
};
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/MultipartParser/internal/search.js
|
|
2776
|
+
function makeState(needle_) {
|
|
2777
|
+
const needle = new TextEncoder().encode(needle_);
|
|
2778
|
+
const needleLength = needle.length;
|
|
2779
|
+
const indexes = {};
|
|
2780
|
+
for (let i = 0; i < needleLength; i++) {
|
|
2781
|
+
const b = needle[i];
|
|
2782
|
+
if (indexes[b] === void 0) indexes[b] = [];
|
|
2783
|
+
indexes[b].push(i);
|
|
2784
|
+
}
|
|
2785
|
+
return {
|
|
2786
|
+
needle,
|
|
2787
|
+
needleLength,
|
|
2788
|
+
indexes,
|
|
2789
|
+
firstByte: needle[0],
|
|
2790
|
+
previousChunk: void 0,
|
|
2791
|
+
previousChunkLength: 0,
|
|
2792
|
+
matchIndex: 0
|
|
2793
|
+
};
|
|
2794
|
+
}
|
|
2795
|
+
function make6(needle, callback2, seed, minimumChunkLength) {
|
|
2796
|
+
const state = makeState(needle);
|
|
2797
|
+
const minChunkLength = minimumChunkLength ?? state.needleLength;
|
|
2798
|
+
if (seed !== void 0) {
|
|
2799
|
+
state.previousChunk = seed;
|
|
2800
|
+
state.previousChunkLength = seed.length;
|
|
2801
|
+
}
|
|
2802
|
+
function makeIndexOf() {
|
|
2803
|
+
if ("Buffer" in globalThis && !("Bun" in globalThis || "Deno" in globalThis)) {
|
|
2804
|
+
return function(chunk, needle2, fromIndex) {
|
|
2805
|
+
return Buffer.prototype.indexOf.call(chunk, needle2, fromIndex);
|
|
2806
|
+
};
|
|
2807
|
+
}
|
|
2808
|
+
const skipTable = new Uint8Array(256).fill(state.needle.length);
|
|
2809
|
+
for (let i = 0, lastIndex = state.needle.length - 1; i < lastIndex; ++i) {
|
|
2810
|
+
skipTable[state.needle[i]] = lastIndex - i;
|
|
2811
|
+
}
|
|
2812
|
+
return function(chunk, needle2, fromIndex) {
|
|
2813
|
+
const lengthTotal = chunk.length;
|
|
2814
|
+
let i = fromIndex + state.needleLength - 1;
|
|
2815
|
+
while (i < lengthTotal) {
|
|
2816
|
+
for (let j = state.needleLength - 1, k = i; j >= 0 && chunk[k] === needle2[j]; j--, k--) {
|
|
2817
|
+
if (j === 0) return k;
|
|
2818
|
+
}
|
|
2819
|
+
i += skipTable[chunk[i]];
|
|
2820
|
+
}
|
|
2821
|
+
return -1;
|
|
2822
|
+
};
|
|
2823
|
+
}
|
|
2824
|
+
const indexOf = makeIndexOf();
|
|
2825
|
+
function write(chunk) {
|
|
2826
|
+
let chunkLength = chunk.length;
|
|
2827
|
+
if (state.previousChunk !== void 0) {
|
|
2828
|
+
const newChunk = new Uint8Array(state.previousChunkLength + chunkLength);
|
|
2829
|
+
newChunk.set(state.previousChunk);
|
|
2830
|
+
newChunk.set(chunk, state.previousChunkLength);
|
|
2831
|
+
chunk = newChunk;
|
|
2832
|
+
chunkLength = state.previousChunkLength + chunkLength;
|
|
2833
|
+
state.previousChunk = void 0;
|
|
2834
|
+
}
|
|
2835
|
+
let pos = 0;
|
|
2836
|
+
while (pos < chunkLength) {
|
|
2837
|
+
const remaining = chunkLength - pos;
|
|
2838
|
+
if (remaining < minChunkLength) {
|
|
2839
|
+
state.previousChunk = chunk.subarray(pos);
|
|
2840
|
+
state.previousChunkLength = remaining;
|
|
2841
|
+
return;
|
|
2842
|
+
}
|
|
2843
|
+
const match2 = indexOf(chunk, state.needle, pos);
|
|
2844
|
+
if (match2 > -1) {
|
|
2845
|
+
if (match2 > pos) {
|
|
2846
|
+
callback2(state.matchIndex, chunk.subarray(pos, match2));
|
|
2847
|
+
}
|
|
2848
|
+
state.matchIndex += 1;
|
|
2849
|
+
pos = match2 + state.needleLength;
|
|
2850
|
+
continue;
|
|
2851
|
+
} else if (chunk[chunkLength - 1] in state.indexes) {
|
|
2852
|
+
const indexes = state.indexes[chunk[chunkLength - 1]];
|
|
2853
|
+
let earliestIndex = -1;
|
|
2854
|
+
for (let i = 0, len = indexes.length; i < len; i++) {
|
|
2855
|
+
const index = indexes[i];
|
|
2856
|
+
if (chunk[chunkLength - 1 - index] === state.firstByte && i > earliestIndex) {
|
|
2857
|
+
earliestIndex = index;
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
if (earliestIndex === -1) {
|
|
2861
|
+
if (pos === 0) {
|
|
2862
|
+
callback2(state.matchIndex, chunk);
|
|
2863
|
+
} else {
|
|
2864
|
+
callback2(state.matchIndex, chunk.subarray(pos));
|
|
2865
|
+
}
|
|
2866
|
+
} else {
|
|
2867
|
+
if (chunkLength - 1 - earliestIndex > pos) {
|
|
2868
|
+
callback2(state.matchIndex, chunk.subarray(pos, chunkLength - 1 - earliestIndex));
|
|
2869
|
+
}
|
|
2870
|
+
state.previousChunk = chunk.subarray(chunkLength - 1 - earliestIndex);
|
|
2871
|
+
state.previousChunkLength = earliestIndex + 1;
|
|
2872
|
+
}
|
|
2873
|
+
} else if (pos === 0) {
|
|
2874
|
+
callback2(state.matchIndex, chunk);
|
|
2875
|
+
} else {
|
|
2876
|
+
callback2(state.matchIndex, chunk.subarray(pos));
|
|
2877
|
+
}
|
|
2878
|
+
break;
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
function end() {
|
|
2882
|
+
if (state.previousChunk !== void 0 && state.previousChunk !== seed) {
|
|
2883
|
+
callback2(state.matchIndex, state.previousChunk);
|
|
2884
|
+
}
|
|
2885
|
+
state.previousChunk = seed;
|
|
2886
|
+
state.previousChunkLength = seed?.length ?? 0;
|
|
2887
|
+
state.matchIndex = 0;
|
|
2888
|
+
}
|
|
2889
|
+
return {
|
|
2890
|
+
write,
|
|
2891
|
+
end
|
|
2892
|
+
};
|
|
2893
|
+
}
|
|
2894
|
+
|
|
2895
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/MultipartParser/internal/multipart.js
|
|
2896
|
+
var State2 = {
|
|
2897
|
+
headers: 0,
|
|
2898
|
+
body: 1
|
|
2899
|
+
};
|
|
2900
|
+
var errInvalidDisposition = {
|
|
2901
|
+
_tag: "InvalidDisposition"
|
|
2902
|
+
};
|
|
2903
|
+
var errEndNotReached = {
|
|
2904
|
+
_tag: "EndNotReached"
|
|
2905
|
+
};
|
|
2906
|
+
var errMaxParts = {
|
|
2907
|
+
_tag: "ReachedLimit",
|
|
2908
|
+
limit: "MaxParts"
|
|
2909
|
+
};
|
|
2910
|
+
var errMaxTotalSize = {
|
|
2911
|
+
_tag: "ReachedLimit",
|
|
2912
|
+
limit: "MaxTotalSize"
|
|
2913
|
+
};
|
|
2914
|
+
var errMaxPartSize = {
|
|
2915
|
+
_tag: "ReachedLimit",
|
|
2916
|
+
limit: "MaxPartSize"
|
|
2917
|
+
};
|
|
2918
|
+
var errMaxFieldSize = {
|
|
2919
|
+
_tag: "ReachedLimit",
|
|
2920
|
+
limit: "MaxFieldSize"
|
|
2921
|
+
};
|
|
2922
|
+
var constCR = /* @__PURE__ */ new TextEncoder().encode("\r\n");
|
|
2923
|
+
function defaultIsFile(info) {
|
|
2924
|
+
return info.filename !== void 0 || info.contentType === "application/octet-stream";
|
|
2925
|
+
}
|
|
2926
|
+
function parseBoundary(headers) {
|
|
2927
|
+
const contentType = parse(headers["content-type"]);
|
|
2928
|
+
return contentType.parameters.boundary;
|
|
2929
|
+
}
|
|
2930
|
+
function noopOnChunk(_chunk) {
|
|
2931
|
+
}
|
|
2932
|
+
var toLimit = (input) => input === Infinity ? Infinity : Number(fromInputUnsafe2(input));
|
|
2933
|
+
function make7({
|
|
2934
|
+
headers,
|
|
2935
|
+
onFile: onPart,
|
|
2936
|
+
onField,
|
|
2937
|
+
onError,
|
|
2938
|
+
onDone,
|
|
2939
|
+
isFile = defaultIsFile,
|
|
2940
|
+
maxParts = Infinity,
|
|
2941
|
+
maxTotalSize: maxTotalSizeInput = Infinity,
|
|
2942
|
+
maxPartSize: maxPartSizeInput = Infinity,
|
|
2943
|
+
maxFieldSize: maxFieldSizeInput = 1024 * 1024
|
|
2944
|
+
}) {
|
|
2945
|
+
const maxTotalSize = toLimit(maxTotalSizeInput);
|
|
2946
|
+
const maxPartSize = toLimit(maxPartSizeInput);
|
|
2947
|
+
const maxFieldSize = toLimit(maxFieldSizeInput);
|
|
2948
|
+
const boundary = parseBoundary(headers);
|
|
2949
|
+
if (boundary === void 0) {
|
|
2950
|
+
onError({
|
|
2951
|
+
_tag: "InvalidBoundary"
|
|
2952
|
+
});
|
|
2953
|
+
return {
|
|
2954
|
+
write: noopOnChunk,
|
|
2955
|
+
end() {
|
|
2956
|
+
}
|
|
2957
|
+
};
|
|
2958
|
+
}
|
|
2959
|
+
const state = {
|
|
2960
|
+
state: State2.headers,
|
|
2961
|
+
index: 0,
|
|
2962
|
+
parts: 0,
|
|
2963
|
+
onChunk: noopOnChunk,
|
|
2964
|
+
info: void 0,
|
|
2965
|
+
headerSkip: 0,
|
|
2966
|
+
partSize: 0,
|
|
2967
|
+
totalSize: 0,
|
|
2968
|
+
isFile: false,
|
|
2969
|
+
fieldChunks: [],
|
|
2970
|
+
fieldSize: 0,
|
|
2971
|
+
done: false,
|
|
2972
|
+
stopped: false
|
|
2973
|
+
};
|
|
2974
|
+
function skipBody() {
|
|
2975
|
+
state.state = State2.body;
|
|
2976
|
+
state.isFile = true;
|
|
2977
|
+
state.onChunk = noopOnChunk;
|
|
2978
|
+
}
|
|
2979
|
+
function stop(error) {
|
|
2980
|
+
state.stopped = true;
|
|
2981
|
+
if (state.state === State2.body && state.isFile) {
|
|
2982
|
+
state.onChunk(null);
|
|
2983
|
+
}
|
|
2984
|
+
onError(error);
|
|
2985
|
+
}
|
|
2986
|
+
const headerParser = make5();
|
|
2987
|
+
const split = make6(`\r
|
|
2988
|
+
--${boundary}`, function(index, chunk) {
|
|
2989
|
+
if (state.stopped) {
|
|
2990
|
+
return;
|
|
2991
|
+
}
|
|
2992
|
+
if (index === 0) {
|
|
2993
|
+
skipBody();
|
|
2994
|
+
return;
|
|
2995
|
+
} else if (index !== state.index) {
|
|
2996
|
+
if (state.index > 0) {
|
|
2997
|
+
if (state.isFile) {
|
|
2998
|
+
state.onChunk(null);
|
|
2999
|
+
} else {
|
|
3000
|
+
if (state.fieldChunks.length === 1) {
|
|
3001
|
+
onField(state.info, state.fieldChunks[0]);
|
|
3002
|
+
} else {
|
|
3003
|
+
const buf = new Uint8Array(state.fieldSize);
|
|
3004
|
+
let offset = 0;
|
|
3005
|
+
for (let i = 0; i < state.fieldChunks.length; i++) {
|
|
3006
|
+
const chunk2 = state.fieldChunks[i];
|
|
3007
|
+
buf.set(chunk2, offset);
|
|
3008
|
+
offset += chunk2.length;
|
|
3009
|
+
}
|
|
3010
|
+
onField(state.info, buf);
|
|
3011
|
+
}
|
|
3012
|
+
state.fieldSize = 0;
|
|
3013
|
+
state.fieldChunks = [];
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
3016
|
+
state.partSize = 0;
|
|
3017
|
+
state.state = State2.headers;
|
|
3018
|
+
state.index = index;
|
|
3019
|
+
state.headerSkip = 2;
|
|
3020
|
+
if (chunk[0] === 45 && chunk[1] === 45) {
|
|
3021
|
+
state.done = true;
|
|
3022
|
+
return onDone();
|
|
3023
|
+
}
|
|
3024
|
+
state.parts++;
|
|
3025
|
+
if (state.parts > maxParts) {
|
|
3026
|
+
return stop(errMaxParts);
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
3029
|
+
if ((state.partSize += chunk.length) > maxPartSize) {
|
|
3030
|
+
return stop(errMaxPartSize);
|
|
3031
|
+
}
|
|
3032
|
+
if (state.state === State2.headers) {
|
|
3033
|
+
const result = headerParser(chunk, state.headerSkip);
|
|
3034
|
+
state.headerSkip = 0;
|
|
3035
|
+
if (result._tag === "Continue") {
|
|
3036
|
+
return;
|
|
3037
|
+
} else if (result._tag === "Failure") {
|
|
3038
|
+
skipBody();
|
|
3039
|
+
return onError({
|
|
3040
|
+
_tag: "BadHeaders",
|
|
3041
|
+
error: result
|
|
3042
|
+
});
|
|
3043
|
+
}
|
|
3044
|
+
const contentType = parse(result.headers["content-type"]);
|
|
3045
|
+
const contentDisposition = parse(result.headers["content-disposition"], true);
|
|
3046
|
+
if ("form-data" === contentDisposition.value && !("name" in contentDisposition.parameters)) {
|
|
3047
|
+
skipBody();
|
|
3048
|
+
return onError(errInvalidDisposition);
|
|
3049
|
+
}
|
|
3050
|
+
let encodedFilename;
|
|
3051
|
+
if ("filename*" in contentDisposition.parameters) {
|
|
3052
|
+
const parts = contentDisposition.parameters["filename*"].split("''");
|
|
3053
|
+
if (parts.length === 2) {
|
|
3054
|
+
try {
|
|
3055
|
+
encodedFilename = decodeURIComponent(parts[1]);
|
|
3056
|
+
} catch {
|
|
3057
|
+
encodedFilename = parts[1];
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
state.info = {
|
|
3062
|
+
name: contentDisposition.parameters.name ?? "",
|
|
3063
|
+
filename: encodedFilename ?? contentDisposition.parameters.filename,
|
|
3064
|
+
contentType: contentType.value === "" ? contentDisposition.parameters.filename !== void 0 ? "application/octet-stream" : "text/plain" : contentType.value,
|
|
3065
|
+
contentTypeParameters: contentType.parameters,
|
|
3066
|
+
contentDisposition: contentDisposition.value,
|
|
3067
|
+
contentDispositionParameters: contentDisposition.parameters,
|
|
3068
|
+
headers: result.headers
|
|
3069
|
+
};
|
|
3070
|
+
state.state = State2.body;
|
|
3071
|
+
state.isFile = isFile(state.info);
|
|
3072
|
+
if (state.isFile) {
|
|
3073
|
+
state.onChunk = onPart(state.info);
|
|
3074
|
+
}
|
|
3075
|
+
if (result.endPosition < chunk.length) {
|
|
3076
|
+
if (state.isFile) {
|
|
3077
|
+
state.onChunk(chunk.subarray(result.endPosition));
|
|
3078
|
+
} else {
|
|
3079
|
+
const buf = chunk.subarray(result.endPosition);
|
|
3080
|
+
if ((state.fieldSize += buf.length) > maxFieldSize) {
|
|
3081
|
+
return stop(errMaxFieldSize);
|
|
3082
|
+
}
|
|
3083
|
+
state.fieldChunks.push(buf);
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
} else if (state.isFile) {
|
|
3087
|
+
state.onChunk(chunk);
|
|
3088
|
+
} else {
|
|
3089
|
+
if ((state.fieldSize += chunk.length) > maxFieldSize) {
|
|
3090
|
+
return stop(errMaxFieldSize);
|
|
3091
|
+
}
|
|
3092
|
+
state.fieldChunks.push(chunk);
|
|
3093
|
+
}
|
|
3094
|
+
}, constCR, 2);
|
|
3095
|
+
return {
|
|
3096
|
+
write(chunk) {
|
|
3097
|
+
if (state.stopped) {
|
|
3098
|
+
return;
|
|
3099
|
+
}
|
|
3100
|
+
if ((state.totalSize += chunk.length) > maxTotalSize) {
|
|
3101
|
+
return stop(errMaxTotalSize);
|
|
3102
|
+
}
|
|
3103
|
+
return split.write(chunk);
|
|
3104
|
+
},
|
|
3105
|
+
end() {
|
|
3106
|
+
split.end();
|
|
3107
|
+
if (!state.done && !state.stopped) {
|
|
3108
|
+
stop(errEndNotReached);
|
|
3109
|
+
}
|
|
3110
|
+
state.state = State2.headers;
|
|
3111
|
+
state.index = 0;
|
|
3112
|
+
state.parts = 0;
|
|
3113
|
+
state.onChunk = noopOnChunk;
|
|
3114
|
+
state.info = void 0;
|
|
3115
|
+
state.totalSize = 0;
|
|
3116
|
+
state.partSize = 0;
|
|
3117
|
+
state.fieldChunks = [];
|
|
3118
|
+
state.fieldSize = 0;
|
|
3119
|
+
state.done = false;
|
|
3120
|
+
state.stopped = false;
|
|
3121
|
+
}
|
|
3122
|
+
};
|
|
3123
|
+
}
|
|
3124
|
+
var utf8Decoder = /* @__PURE__ */ new TextDecoder("utf-8");
|
|
3125
|
+
function getDecoder(charset) {
|
|
3126
|
+
if (charset === "utf-8" || charset === "utf8" || charset === "") {
|
|
3127
|
+
return utf8Decoder;
|
|
3128
|
+
}
|
|
3129
|
+
try {
|
|
3130
|
+
return new TextDecoder(charset);
|
|
3131
|
+
} catch (error) {
|
|
3132
|
+
return utf8Decoder;
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
function decodeField(info, value) {
|
|
3136
|
+
return getDecoder(info.contentTypeParameters.charset ?? "utf-8").decode(value);
|
|
3137
|
+
}
|
|
3138
|
+
|
|
3139
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/MultipartParser.js
|
|
3140
|
+
var make8 = make7;
|
|
3141
|
+
var defaultIsFile2 = defaultIsFile;
|
|
3142
|
+
var decodeField2 = decodeField;
|
|
3143
|
+
|
|
3144
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/Multipart.js
|
|
3145
|
+
var TypeId9 = "~effect/http/Multipart";
|
|
3146
|
+
var MultipartErrorTypeId = "~effect/http/Multipart/MultipartError";
|
|
3147
|
+
var toMultipartError = (cause) => hasProperty(cause, MultipartErrorTypeId) ? cause : MultipartError.fromReason("InternalError", cause);
|
|
3148
|
+
var MultipartErrorReason = class extends Error2 {
|
|
3149
|
+
};
|
|
3150
|
+
var responseStatusByReason = {
|
|
3151
|
+
FileTooLarge: 413,
|
|
3152
|
+
FieldTooLarge: 413,
|
|
3153
|
+
BodyTooLarge: 413,
|
|
3154
|
+
TooManyParts: 413,
|
|
3155
|
+
InternalError: 500,
|
|
3156
|
+
Parse: 400
|
|
3157
|
+
};
|
|
3158
|
+
var MultipartError = class _MultipartError extends (/* @__PURE__ */ TaggedError("MultipartError")) {
|
|
3159
|
+
/**
|
|
3160
|
+
* Creates a multipart error from a reason tag and optional cause.
|
|
3161
|
+
*
|
|
3162
|
+
* @since 4.0.0
|
|
3163
|
+
*/
|
|
3164
|
+
static fromReason(reason, cause) {
|
|
3165
|
+
return new _MultipartError({
|
|
3166
|
+
reason: new MultipartErrorReason({
|
|
3167
|
+
_tag: reason,
|
|
3168
|
+
cause
|
|
3169
|
+
})
|
|
3170
|
+
});
|
|
3171
|
+
}
|
|
3172
|
+
/**
|
|
3173
|
+
* Marks this value as a multipart error for runtime guards.
|
|
3174
|
+
*
|
|
3175
|
+
* @since 4.0.0
|
|
3176
|
+
*/
|
|
3177
|
+
[MultipartErrorTypeId] = MultipartErrorTypeId;
|
|
3178
|
+
[ignore] = true;
|
|
3179
|
+
/**
|
|
3180
|
+
* Converts the multipart error into an HTTP response based on its reason.
|
|
3181
|
+
*
|
|
3182
|
+
* **Details**
|
|
3183
|
+
*
|
|
3184
|
+
* Parse errors produce `400`, size and part-count limits produce `413`, and
|
|
3185
|
+
* internal errors produce `500`.
|
|
3186
|
+
*
|
|
3187
|
+
* @since 4.0.0
|
|
3188
|
+
*/
|
|
3189
|
+
[symbol]() {
|
|
3190
|
+
return succeed2(empty9({
|
|
3191
|
+
status: responseStatusByReason[this.reason._tag]
|
|
3192
|
+
}));
|
|
3193
|
+
}
|
|
3194
|
+
/**
|
|
3195
|
+
* Uses the concrete multipart error reason as the public message.
|
|
3196
|
+
*
|
|
3197
|
+
* @since 4.0.0
|
|
3198
|
+
*/
|
|
3199
|
+
get message() {
|
|
3200
|
+
return this.reason._tag;
|
|
3201
|
+
}
|
|
3202
|
+
};
|
|
3203
|
+
var schemaPersisted = (schema) => decodeUnknownEffect(schema);
|
|
3204
|
+
var schemaJson2 = (schema, options3) => {
|
|
3205
|
+
const fromJson = fromJsonString(schema, options3);
|
|
3206
|
+
return dual(2, (persisted, field) => map(decodeUnknownEffect(Struct({
|
|
3207
|
+
[field]: fromJson
|
|
3208
|
+
}))(persisted, options3), (_) => _[field]));
|
|
3209
|
+
};
|
|
3210
|
+
var makeConfig = (headers) => withFiber((fiber) => {
|
|
3211
|
+
const mimeTypes = get(fiber.context, FieldMimeTypes);
|
|
3212
|
+
return succeed2({
|
|
3213
|
+
headers,
|
|
3214
|
+
maxParts: fiber.getRef(MaxParts),
|
|
3215
|
+
maxFieldSize: fiber.getRef(MaxFieldSize),
|
|
3216
|
+
maxPartSize: fiber.getRef(MaxFileSize),
|
|
3217
|
+
maxTotalSize: fiber.getRef(MaxBodySize),
|
|
3218
|
+
isFile: mimeTypes.length === 0 ? void 0 : (info) => !mimeTypes.some((_) => info.contentType.includes(_)) && defaultIsFile2(info)
|
|
3219
|
+
});
|
|
3220
|
+
});
|
|
3221
|
+
var makeChannel = (headers) => fromTransform((upstream) => map(makeConfig(headers), (config) => {
|
|
3222
|
+
let partsBuffer = [];
|
|
3223
|
+
let exit2 = none();
|
|
3224
|
+
let ended = false;
|
|
3225
|
+
const parser = make8({
|
|
3226
|
+
...config,
|
|
3227
|
+
onField(info, value) {
|
|
3228
|
+
partsBuffer.push(new FieldImpl(info.name, info.contentType, decodeField2(info, value)));
|
|
3229
|
+
},
|
|
3230
|
+
onFile(info) {
|
|
3231
|
+
let chunks = [];
|
|
3232
|
+
let finished = false;
|
|
3233
|
+
const pullChunks = fromPull(succeed2(suspend(function loop() {
|
|
3234
|
+
if (!isReadonlyArrayNonEmpty(chunks)) {
|
|
3235
|
+
if (finished) {
|
|
3236
|
+
return done();
|
|
3237
|
+
}
|
|
3238
|
+
if (isSome(exit2)) {
|
|
3239
|
+
return exit2.value;
|
|
3240
|
+
}
|
|
3241
|
+
return flatMap(pump, loop);
|
|
3242
|
+
}
|
|
3243
|
+
const chunk = chunks;
|
|
3244
|
+
chunks = [];
|
|
3245
|
+
return succeed2(chunk);
|
|
3246
|
+
})));
|
|
3247
|
+
partsBuffer.push(new FileImpl(info, mapError2(pullChunks, toMultipartError)));
|
|
3248
|
+
return function(chunk) {
|
|
3249
|
+
if (chunk === null) {
|
|
3250
|
+
finished = true;
|
|
3251
|
+
} else {
|
|
3252
|
+
chunks.push(chunk);
|
|
3253
|
+
}
|
|
3254
|
+
};
|
|
3255
|
+
},
|
|
3256
|
+
onError(error_) {
|
|
3257
|
+
exit2 = some(fail2(convertError(error_)));
|
|
3258
|
+
},
|
|
3259
|
+
onDone() {
|
|
3260
|
+
if (isNone(exit2)) {
|
|
3261
|
+
exit2 = some(fail2(Done()));
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
});
|
|
3265
|
+
const pump = upstream.pipe(flatMap((chunk) => {
|
|
3266
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
3267
|
+
parser.write(chunk[i]);
|
|
3268
|
+
}
|
|
3269
|
+
return void_2;
|
|
3270
|
+
}), catchCause((cause) => {
|
|
3271
|
+
if (isDoneCause(cause)) {
|
|
3272
|
+
if (!ended) {
|
|
3273
|
+
ended = true;
|
|
3274
|
+
parser.end();
|
|
3275
|
+
}
|
|
3276
|
+
} else {
|
|
3277
|
+
exit2 = some(failCause(cause));
|
|
3278
|
+
}
|
|
3279
|
+
return void_2;
|
|
3280
|
+
}));
|
|
3281
|
+
return pump.pipe(flatMap(function loop() {
|
|
3282
|
+
if (!isReadonlyArrayNonEmpty(partsBuffer)) {
|
|
3283
|
+
if (isSome(exit2)) {
|
|
3284
|
+
return exit2.value;
|
|
3285
|
+
}
|
|
3286
|
+
return flatMap(pump, loop);
|
|
3287
|
+
}
|
|
3288
|
+
const parts = partsBuffer;
|
|
3289
|
+
partsBuffer = [];
|
|
3290
|
+
return succeed2(parts);
|
|
3291
|
+
}));
|
|
3292
|
+
}));
|
|
3293
|
+
function convertError(cause) {
|
|
3294
|
+
switch (cause._tag) {
|
|
3295
|
+
case "ReachedLimit": {
|
|
3296
|
+
switch (cause.limit) {
|
|
3297
|
+
case "MaxParts": {
|
|
3298
|
+
return MultipartError.fromReason("TooManyParts", cause);
|
|
3299
|
+
}
|
|
3300
|
+
case "MaxFieldSize": {
|
|
3301
|
+
return MultipartError.fromReason("FieldTooLarge", cause);
|
|
3302
|
+
}
|
|
3303
|
+
case "MaxPartSize": {
|
|
3304
|
+
return MultipartError.fromReason("FileTooLarge", cause);
|
|
3305
|
+
}
|
|
3306
|
+
case "MaxTotalSize": {
|
|
3307
|
+
return MultipartError.fromReason("BodyTooLarge", cause);
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
default: {
|
|
3312
|
+
return MultipartError.fromReason("Parse", cause);
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
var PartBase = class extends Class {
|
|
3317
|
+
[TypeId9];
|
|
3318
|
+
constructor() {
|
|
3319
|
+
super();
|
|
3320
|
+
this[TypeId9] = TypeId9;
|
|
3321
|
+
}
|
|
3322
|
+
};
|
|
3323
|
+
var FieldImpl = class extends PartBase {
|
|
3324
|
+
_tag = "Field";
|
|
3325
|
+
key;
|
|
3326
|
+
contentType;
|
|
3327
|
+
value;
|
|
3328
|
+
constructor(key, contentType, value) {
|
|
3329
|
+
super();
|
|
3330
|
+
this.key = key;
|
|
3331
|
+
this.contentType = contentType;
|
|
3332
|
+
this.value = value;
|
|
3333
|
+
}
|
|
3334
|
+
toJSON() {
|
|
3335
|
+
return {
|
|
3336
|
+
_id: "@effect/platform/Multipart/Part",
|
|
3337
|
+
_tag: "Field",
|
|
3338
|
+
key: this.key,
|
|
3339
|
+
contentType: this.contentType,
|
|
3340
|
+
value: this.value
|
|
3341
|
+
};
|
|
3342
|
+
}
|
|
3343
|
+
};
|
|
3344
|
+
var FileImpl = class extends PartBase {
|
|
3345
|
+
_tag = "File";
|
|
3346
|
+
key;
|
|
3347
|
+
name;
|
|
3348
|
+
contentType;
|
|
3349
|
+
content;
|
|
3350
|
+
contentEffect;
|
|
3351
|
+
constructor(info, channel) {
|
|
3352
|
+
super();
|
|
3353
|
+
this.key = info.name;
|
|
3354
|
+
this.name = info.filename ?? info.name;
|
|
3355
|
+
this.contentType = info.contentType;
|
|
3356
|
+
this.content = fromChannel(channel);
|
|
3357
|
+
this.contentEffect = mkUint8Array(channel);
|
|
3358
|
+
}
|
|
3359
|
+
toJSON() {
|
|
3360
|
+
return {
|
|
3361
|
+
_id: "@effect/platform/Multipart/Part",
|
|
3362
|
+
_tag: "File",
|
|
3363
|
+
key: this.key,
|
|
3364
|
+
name: this.name,
|
|
3365
|
+
contentType: this.contentType
|
|
3366
|
+
};
|
|
3367
|
+
}
|
|
3368
|
+
};
|
|
3369
|
+
var defaultWriteFile = (path, file3) => flatMap(FileSystem, (fs) => mapError(run(file3.content, fs.sink(path)), toMultipartError));
|
|
3370
|
+
var toPersisted = (stream4, writeFile = defaultWriteFile) => gen(function* () {
|
|
3371
|
+
const fs = yield* FileSystem;
|
|
3372
|
+
const path_ = yield* Path;
|
|
3373
|
+
const dir = yield* fs.makeTempDirectoryScoped();
|
|
3374
|
+
const persisted = /* @__PURE__ */ Object.create(null);
|
|
3375
|
+
const usedPaths = /* @__PURE__ */ new Set();
|
|
3376
|
+
let fileIndex = 0;
|
|
3377
|
+
yield* runForEach(stream4, (part) => {
|
|
3378
|
+
if (part._tag === "Field") {
|
|
3379
|
+
if (!(part.key in persisted)) {
|
|
3380
|
+
persisted[part.key] = part.value;
|
|
3381
|
+
} else if (typeof persisted[part.key] === "string") {
|
|
3382
|
+
persisted[part.key] = [persisted[part.key], part.value];
|
|
3383
|
+
} else {
|
|
3384
|
+
;
|
|
3385
|
+
persisted[part.key].push(part.value);
|
|
3386
|
+
}
|
|
3387
|
+
return void_2;
|
|
3388
|
+
} else if (part.name === "") {
|
|
3389
|
+
return void_2;
|
|
3390
|
+
}
|
|
3391
|
+
const file3 = part;
|
|
3392
|
+
const fileName = path_.basename(file3.name).slice(-128);
|
|
3393
|
+
let path = path_.join(dir, fileName);
|
|
3394
|
+
while (usedPaths.has(path)) {
|
|
3395
|
+
path = path_.join(dir, `${fileIndex++}-${fileName}`);
|
|
3396
|
+
}
|
|
3397
|
+
usedPaths.add(path);
|
|
3398
|
+
const filePart = new PersistedFileImpl(file3.key, file3.name, file3.contentType, path);
|
|
3399
|
+
if (Array.isArray(persisted[part.key])) {
|
|
3400
|
+
;
|
|
3401
|
+
persisted[part.key].push(filePart);
|
|
3402
|
+
} else {
|
|
3403
|
+
persisted[part.key] = [filePart];
|
|
3404
|
+
}
|
|
3405
|
+
return writeFile(path, file3);
|
|
3406
|
+
});
|
|
3407
|
+
return persisted;
|
|
3408
|
+
}).pipe(catchTag("PlatformError", (cause) => fail3(MultipartError.fromReason("InternalError", cause))));
|
|
3409
|
+
var PersistedFileImpl = class extends PartBase {
|
|
3410
|
+
_tag = "PersistedFile";
|
|
3411
|
+
key;
|
|
3412
|
+
name;
|
|
3413
|
+
contentType;
|
|
3414
|
+
path;
|
|
3415
|
+
constructor(key, name, contentType, path) {
|
|
3416
|
+
super();
|
|
3417
|
+
this.key = key;
|
|
3418
|
+
this.name = name;
|
|
3419
|
+
this.contentType = contentType;
|
|
3420
|
+
this.path = path;
|
|
3421
|
+
}
|
|
3422
|
+
toJSON() {
|
|
3423
|
+
return {
|
|
3424
|
+
_id: "@effect/platform/Multipart/Part",
|
|
3425
|
+
_tag: "PersistedFile",
|
|
3426
|
+
key: this.key,
|
|
3427
|
+
name: this.name,
|
|
3428
|
+
contentType: this.contentType,
|
|
3429
|
+
path: this.path
|
|
3430
|
+
};
|
|
3431
|
+
}
|
|
3432
|
+
};
|
|
3433
|
+
var MaxParts = /* @__PURE__ */ Reference("effect/http/Multipart/MaxParts", {
|
|
3434
|
+
defaultValue: () => void 0
|
|
3435
|
+
});
|
|
3436
|
+
var MaxFieldSize = /* @__PURE__ */ Reference("effect/http/Multipart/MaxFieldSize", {
|
|
3437
|
+
defaultValue: /* @__PURE__ */ constant(/* @__PURE__ */ mebibytes(10))
|
|
3438
|
+
});
|
|
3439
|
+
var MaxFileSize = /* @__PURE__ */ Reference("effect/http/Multipart/MaxFileSize", {
|
|
3440
|
+
defaultValue: () => void 0
|
|
3441
|
+
});
|
|
3442
|
+
var FieldMimeTypes = /* @__PURE__ */ Reference("effect/http/Multipart/FieldMimeTypes", {
|
|
3443
|
+
defaultValue: /* @__PURE__ */ constant(["application/json"])
|
|
3444
|
+
});
|
|
3445
|
+
|
|
3446
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpServerRequest.js
|
|
3447
|
+
var HttpServerRequest_exports = {};
|
|
3448
|
+
__export(HttpServerRequest_exports, {
|
|
3449
|
+
HttpServerRequest: () => HttpServerRequest,
|
|
3450
|
+
MaxBodySize: () => MaxBodySize,
|
|
3451
|
+
ParsedSearchParams: () => ParsedSearchParams,
|
|
3452
|
+
TypeId: () => TypeId10,
|
|
3453
|
+
fromClientRequest: () => fromClientRequest,
|
|
3454
|
+
fromWeb: () => fromWeb4,
|
|
3455
|
+
schemaBodyForm: () => schemaBodyForm,
|
|
3456
|
+
schemaBodyFormJson: () => schemaBodyFormJson,
|
|
3457
|
+
schemaBodyJson: () => schemaBodyJson3,
|
|
3458
|
+
schemaBodyMultipart: () => schemaBodyMultipart,
|
|
3459
|
+
schemaBodyUrlParams: () => schemaBodyUrlParams2,
|
|
3460
|
+
schemaCookies: () => schemaCookies,
|
|
3461
|
+
schemaHeaders: () => schemaHeaders,
|
|
3462
|
+
schemaSearchParams: () => schemaSearchParams,
|
|
3463
|
+
searchParamsFromURL: () => searchParamsFromURL,
|
|
3464
|
+
toClientRequest: () => toClientRequest,
|
|
3465
|
+
toURL: () => toURL,
|
|
3466
|
+
toWeb: () => toWeb3,
|
|
3467
|
+
toWebResult: () => toWebResult2,
|
|
3468
|
+
upgradeChannel: () => upgradeChannel
|
|
3469
|
+
});
|
|
3470
|
+
|
|
3471
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/socket/Socket.js
|
|
3472
|
+
var encoder2 = /* @__PURE__ */ new TextEncoder();
|
|
3473
|
+
var readerBytes = (self) => map(self.reader, ({
|
|
3474
|
+
pull
|
|
3475
|
+
}) => map(pull, (chunk) => {
|
|
3476
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
3477
|
+
if (typeof chunk[i] === "string") {
|
|
3478
|
+
const out = new Array(chunk.length);
|
|
3479
|
+
for (let j = 0; j < chunk.length; j++) {
|
|
3480
|
+
const item = chunk[j];
|
|
3481
|
+
out[j] = typeof item === "string" ? encoder2.encode(item) : item;
|
|
3482
|
+
}
|
|
3483
|
+
return out;
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
return chunk;
|
|
3487
|
+
}));
|
|
3488
|
+
var CloseEventTypeId = "~effect/socket/Socket/CloseEvent";
|
|
3489
|
+
var CloseEvent = class {
|
|
3490
|
+
/**
|
|
3491
|
+
* Marks this value as a socket close event for runtime guards.
|
|
3492
|
+
*
|
|
3493
|
+
* @since 4.0.0
|
|
3494
|
+
*/
|
|
3495
|
+
[CloseEventTypeId];
|
|
3496
|
+
code;
|
|
3497
|
+
reason;
|
|
3498
|
+
constructor(code = 1e3, reason) {
|
|
3499
|
+
this[CloseEventTypeId] = CloseEventTypeId;
|
|
3500
|
+
this.code = code;
|
|
3501
|
+
this.reason = reason;
|
|
3502
|
+
}
|
|
3503
|
+
/**
|
|
3504
|
+
* Formats the close code and optional reason for display.
|
|
3505
|
+
*
|
|
3506
|
+
* @since 4.0.0
|
|
3507
|
+
*/
|
|
3508
|
+
toString() {
|
|
3509
|
+
return this.reason ? `${this.code}: ${this.reason}` : `${this.code}`;
|
|
3510
|
+
}
|
|
3511
|
+
};
|
|
3512
|
+
var isCloseEvent = (u) => hasProperty(u, CloseEventTypeId);
|
|
3513
|
+
var SocketErrorTypeId = "~effect/socket/Socket/SocketError";
|
|
3514
|
+
var isSocketError = (u) => hasProperty(u, SocketErrorTypeId);
|
|
3515
|
+
var SocketReadError = class extends (/* @__PURE__ */ Error3("effect/socket/Socket/SocketReadError")({
|
|
3516
|
+
_tag: /* @__PURE__ */ tag("SocketReadError"),
|
|
3517
|
+
cause: /* @__PURE__ */ Defect()
|
|
3518
|
+
})) {
|
|
3519
|
+
/**
|
|
3520
|
+
* Default message used for socket read failures.
|
|
3521
|
+
*
|
|
3522
|
+
* @since 4.0.0
|
|
3523
|
+
*/
|
|
3524
|
+
message = `An error occurred during Read`;
|
|
3525
|
+
};
|
|
3526
|
+
var SocketWriteError = class extends (/* @__PURE__ */ Error3("effect/socket/Socket/SocketWriteError")({
|
|
3527
|
+
_tag: /* @__PURE__ */ tag("SocketWriteError"),
|
|
3528
|
+
cause: /* @__PURE__ */ Defect()
|
|
3529
|
+
})) {
|
|
3530
|
+
/**
|
|
3531
|
+
* Default message used for socket write failures.
|
|
3532
|
+
*
|
|
3533
|
+
* @since 4.0.0
|
|
3534
|
+
*/
|
|
3535
|
+
message = `An error occurred during Write`;
|
|
3536
|
+
};
|
|
3537
|
+
var SocketOpenError = class extends (/* @__PURE__ */ Error3("effect/socket/Socket/SocketOpenError")({
|
|
3538
|
+
_tag: /* @__PURE__ */ tag("SocketOpenError"),
|
|
3539
|
+
kind: /* @__PURE__ */ Literals(["Unknown", "Timeout"]),
|
|
3540
|
+
cause: /* @__PURE__ */ Defect()
|
|
3541
|
+
})) {
|
|
3542
|
+
/**
|
|
3543
|
+
* Formats timeout and unknown open failures for display.
|
|
3544
|
+
*
|
|
3545
|
+
* @since 4.0.0
|
|
3546
|
+
*/
|
|
3547
|
+
get message() {
|
|
3548
|
+
return this.kind === "Timeout" ? `timeout waiting for "open"` : `An error occurred during Open`;
|
|
3549
|
+
}
|
|
3550
|
+
};
|
|
3551
|
+
var SocketUpgradeError = class _SocketUpgradeError extends (/* @__PURE__ */ Error3("effect/socket/Socket/SocketUpgradeError")({
|
|
3552
|
+
_tag: /* @__PURE__ */ tag("SocketUpgradeError"),
|
|
3553
|
+
cause: /* @__PURE__ */ optional(/* @__PURE__ */ Defect())
|
|
3554
|
+
})) {
|
|
3555
|
+
/**
|
|
3556
|
+
* An upgrade implementation for transports that cannot wrap the connection
|
|
3557
|
+
* with TLS.
|
|
3558
|
+
*
|
|
3559
|
+
* @since 4.0.0
|
|
3560
|
+
*/
|
|
3561
|
+
static unsupported = () => fail3(new SocketError({
|
|
3562
|
+
reason: new _SocketUpgradeError({})
|
|
3563
|
+
}));
|
|
3564
|
+
get message() {
|
|
3565
|
+
return this.cause === void 0 ? `Socket does not support TLS upgrade` : `An error occurred during TLS upgrade`;
|
|
3566
|
+
}
|
|
3567
|
+
};
|
|
3568
|
+
var SocketCloseError = class extends (/* @__PURE__ */ Error3("effect/socket/Socket/SocketCloseError")({
|
|
3569
|
+
_tag: /* @__PURE__ */ tag("SocketCloseError"),
|
|
3570
|
+
code: Int,
|
|
3571
|
+
closeReason: /* @__PURE__ */ optional(String2)
|
|
3572
|
+
})) {
|
|
3573
|
+
get message() {
|
|
3574
|
+
if (this.closeReason) {
|
|
3575
|
+
return `${this.code}: ${this.closeReason}`;
|
|
3576
|
+
}
|
|
3577
|
+
return `${this.code}`;
|
|
3578
|
+
}
|
|
3579
|
+
};
|
|
3580
|
+
var SocketErrorReason = /* @__PURE__ */ Union([SocketReadError, SocketWriteError, SocketOpenError, SocketUpgradeError, SocketCloseError]);
|
|
3581
|
+
var SocketError = class extends (/* @__PURE__ */ TaggedError2(SocketErrorTypeId)("SocketError", {
|
|
3582
|
+
_tag: /* @__PURE__ */ tag("SocketError"),
|
|
3583
|
+
reason: SocketErrorReason
|
|
3584
|
+
})) {
|
|
3585
|
+
// @effect-diagnostics-next-line overriddenSchemaConstructor:off
|
|
3586
|
+
constructor(props) {
|
|
3587
|
+
if ("cause" in props.reason) {
|
|
3588
|
+
super({
|
|
3589
|
+
...props,
|
|
3590
|
+
cause: props.reason.cause
|
|
3591
|
+
});
|
|
3592
|
+
} else {
|
|
3593
|
+
super(props);
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
/**
|
|
3597
|
+
* Marks this value as a socket error wrapper for runtime guards.
|
|
3598
|
+
*
|
|
3599
|
+
* @since 4.0.0
|
|
3600
|
+
*/
|
|
3601
|
+
[SocketErrorTypeId] = SocketErrorTypeId;
|
|
3602
|
+
/**
|
|
3603
|
+
* Returns `true` when the value is a `SocketError`.
|
|
3604
|
+
*
|
|
3605
|
+
* @since 4.0.0
|
|
3606
|
+
*/
|
|
3607
|
+
static is(u) {
|
|
3608
|
+
return isSocketError(u);
|
|
3609
|
+
}
|
|
3610
|
+
message = this.reason.message;
|
|
3611
|
+
};
|
|
3612
|
+
var writeChunk = (writer, chunk) => {
|
|
3613
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
3614
|
+
if (isCloseEvent(chunk[i])) {
|
|
3615
|
+
return gen(function* () {
|
|
3616
|
+
for (let index = 0; index <= i; index++) {
|
|
3617
|
+
yield* writer.write(chunk[index]);
|
|
3618
|
+
}
|
|
3619
|
+
});
|
|
3620
|
+
}
|
|
3621
|
+
}
|
|
3622
|
+
return writer.writeAll(chunk);
|
|
3623
|
+
};
|
|
3624
|
+
var toChannelWithReader = (self, reader) => fromTransform(fnUntraced(function* (upstream, scope2) {
|
|
3625
|
+
const readScope = yield* fork(scope2);
|
|
3626
|
+
const pull = yield* provide(reader, readScope);
|
|
3627
|
+
const writeScope = yield* fork(scope2);
|
|
3628
|
+
const writer = yield* provide(self.writer, writeScope);
|
|
3629
|
+
let writeFailure;
|
|
3630
|
+
yield* upstream.pipe(flatMap((chunk) => writeChunk(writer, chunk)), forever({
|
|
3631
|
+
disableYield: true
|
|
3632
|
+
}), catchCauseFilter(filterNoDone, (cause) => suspend(() => {
|
|
3633
|
+
writeFailure = cause;
|
|
3634
|
+
return close(readScope, void_);
|
|
3635
|
+
})), ensuring(close(writeScope, void_)), forkIn(scope2));
|
|
3636
|
+
return catchCause(suspend(() => writeFailure !== void 0 ? failCause2(writeFailure) : pull), (cause) => failCause2(writeFailure ?? cause));
|
|
3637
|
+
}));
|
|
3638
|
+
var toChannel = (self) => toChannelWithReader(self, readerBytes(self));
|
|
3639
|
+
var toChannelWith = () => (self) => toChannel(self);
|
|
3640
|
+
var defaultHighWaterMark = 64 * 1024;
|
|
3641
|
+
|
|
3642
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpServerRequest.js
|
|
3643
|
+
var TypeId10 = "~effect/http/HttpServerRequest";
|
|
3644
|
+
var HttpServerRequest = /* @__PURE__ */ Service("effect/http/HttpServerRequest");
|
|
3645
|
+
var ParsedSearchParams = class extends (/* @__PURE__ */ Service()("effect/http/ParsedSearchParams")) {
|
|
3646
|
+
};
|
|
3647
|
+
var searchParamsFromURL = (url) => {
|
|
3648
|
+
const out = {};
|
|
3649
|
+
for (const [key, value] of url.searchParams.entries()) {
|
|
3650
|
+
if (Object.hasOwn(out, key)) {
|
|
3651
|
+
const entry = out[key];
|
|
3652
|
+
if (Array.isArray(entry)) {
|
|
3653
|
+
entry.push(value);
|
|
3654
|
+
} else {
|
|
3655
|
+
assignProperty(out, key, [entry, value]);
|
|
3656
|
+
}
|
|
3657
|
+
} else {
|
|
3658
|
+
assignProperty(out, key, value);
|
|
3659
|
+
}
|
|
3660
|
+
}
|
|
3661
|
+
return out;
|
|
3662
|
+
};
|
|
3663
|
+
var upgradeChannel = () => HttpServerRequest.pipe(flatMap((_) => _.upgrade), map(toChannelWith()), unwrap);
|
|
3664
|
+
var schemaCookies = (schema, options3) => {
|
|
3665
|
+
const parse2 = decodeUnknownEffect(schema);
|
|
3666
|
+
return flatMap(HttpServerRequest, (req) => parse2(req.cookies, options3));
|
|
3667
|
+
};
|
|
3668
|
+
var schemaHeaders = (schema, options3) => {
|
|
3669
|
+
const parse2 = decodeUnknownEffect(schema);
|
|
3670
|
+
return flatMap(HttpServerRequest, (req) => parse2(req.headers, options3));
|
|
3671
|
+
};
|
|
3672
|
+
var schemaSearchParams = (schema, options3) => {
|
|
3673
|
+
const parse2 = decodeUnknownEffect(schema);
|
|
3674
|
+
return flatMap(ParsedSearchParams, (params) => parse2(params, options3));
|
|
3675
|
+
};
|
|
3676
|
+
var schemaBodyJson3 = (schema, options3) => {
|
|
3677
|
+
const parse2 = schemaBodyJson2(schema, options3);
|
|
3678
|
+
return flatMap(HttpServerRequest, parse2);
|
|
3679
|
+
};
|
|
3680
|
+
var isMultipart = (request) => request.headers["content-type"]?.toLowerCase().includes("multipart/form-data") === true || getFormDataBody(request) !== void 0;
|
|
3681
|
+
var schemaBodyForm = (schema, options3) => {
|
|
3682
|
+
const parseMultipart = schemaPersisted(schema);
|
|
3683
|
+
const parseUrlParams = schemaBodyUrlParams(schema, options3);
|
|
3684
|
+
return flatMap(HttpServerRequest, (request) => {
|
|
3685
|
+
if (isMultipart(request)) {
|
|
3686
|
+
return flatMap(request.multipart, (_) => parseMultipart(_, options3));
|
|
3687
|
+
}
|
|
3688
|
+
return parseUrlParams(request);
|
|
3689
|
+
});
|
|
3690
|
+
};
|
|
3691
|
+
var schemaBodyUrlParams2 = (schema, options3) => {
|
|
3692
|
+
const parse2 = schemaBodyUrlParams(schema, options3);
|
|
3693
|
+
return flatMap(HttpServerRequest, parse2);
|
|
3694
|
+
};
|
|
3695
|
+
var schemaBodyMultipart = (schema, options3) => {
|
|
3696
|
+
const parse2 = schemaPersisted(schema);
|
|
3697
|
+
return HttpServerRequest.pipe(flatMap((_) => _.multipart), flatMap((_) => parse2(_, options3)));
|
|
3698
|
+
};
|
|
3699
|
+
var schemaBodyFormJson = (schema, options3) => {
|
|
3700
|
+
const parseMultipart = schemaJson2(schema, options3);
|
|
3701
|
+
return (field) => {
|
|
3702
|
+
const parseUrlParams = JsonFromUrlParamsField(field, options3).pipe(decodeTo(schema), decodeEffect);
|
|
3703
|
+
return flatMap(HttpServerRequest, (request) => {
|
|
3704
|
+
if (isMultipart(request)) {
|
|
3705
|
+
return flatMap(mapError(request.multipart, (cause) => new HttpServerError({
|
|
3706
|
+
reason: new RequestParseError({
|
|
3707
|
+
request,
|
|
3708
|
+
cause
|
|
3709
|
+
})
|
|
3710
|
+
})), parseMultipart(field));
|
|
3711
|
+
}
|
|
3712
|
+
return flatMap(request.urlParamsBody, (_) => parseUrlParams(_, options3));
|
|
3713
|
+
});
|
|
3714
|
+
};
|
|
3715
|
+
};
|
|
3716
|
+
var fromClientRequest = (request) => {
|
|
3717
|
+
const url = match(toUrl(request), {
|
|
3718
|
+
onNone: () => request.url,
|
|
3719
|
+
onSome: (url2) => url2.toString()
|
|
3720
|
+
});
|
|
3721
|
+
return new ClientRequestImpl(request, url);
|
|
3722
|
+
};
|
|
3723
|
+
var fromWeb4 = (request) => new ServerRequestImpl(request, removeHost(request.url));
|
|
3724
|
+
var toClientRequest = (request) => {
|
|
3725
|
+
const body = toClientBody(request);
|
|
3726
|
+
const headers = body._tag !== "Empty" && body.contentLength === void 0 ? remove2(request.headers, "content-length") : request.headers;
|
|
3727
|
+
return setUrl(makeWith(request.method, "", empty5, none(), headers, body), getOrElse(toURL(request), () => request.url));
|
|
3728
|
+
};
|
|
3729
|
+
var toClientBody = (request) => {
|
|
3730
|
+
if (!hasBody(request.method)) {
|
|
3731
|
+
return empty7;
|
|
3732
|
+
}
|
|
3733
|
+
const formData3 = getFormDataBody(request);
|
|
3734
|
+
return formData3 === void 0 ? stream(request.stream, request.headers["content-type"], parseContentLength(request.headers["content-length"])) : formData(formData3);
|
|
3735
|
+
};
|
|
3736
|
+
var removeHost = (url) => {
|
|
3737
|
+
if (url[0] === "/") {
|
|
3738
|
+
return url;
|
|
3739
|
+
}
|
|
3740
|
+
const index = url.indexOf("/", url.indexOf("//") + 2);
|
|
3741
|
+
return index === -1 ? "/" : url.slice(index);
|
|
3742
|
+
};
|
|
3743
|
+
var ServerRequestImpl = class _ServerRequestImpl extends Class {
|
|
3744
|
+
[TypeId10];
|
|
3745
|
+
[TypeId4];
|
|
3746
|
+
source;
|
|
3747
|
+
url;
|
|
3748
|
+
headersOverride;
|
|
3749
|
+
remoteAddressOverride;
|
|
3750
|
+
constructor(source, url, headersOverride, remoteAddressOverride) {
|
|
3751
|
+
super();
|
|
3752
|
+
this[TypeId10] = TypeId10;
|
|
3753
|
+
this[TypeId4] = TypeId4;
|
|
3754
|
+
this.source = source;
|
|
3755
|
+
this.url = url;
|
|
3756
|
+
this.headersOverride = headersOverride;
|
|
3757
|
+
this.remoteAddressOverride = remoteAddressOverride;
|
|
3758
|
+
}
|
|
3759
|
+
toJSON() {
|
|
3760
|
+
return inspect(this, {
|
|
3761
|
+
_id: "HttpServerRequest",
|
|
3762
|
+
method: this.method,
|
|
3763
|
+
url: this.originalUrl
|
|
3764
|
+
});
|
|
3765
|
+
}
|
|
3766
|
+
modify(options3) {
|
|
3767
|
+
return new _ServerRequestImpl(this.source, options3.url ?? this.url, options3.headers ?? this.headersOverride, "remoteAddress" in options3 ? options3.remoteAddress : this.remoteAddressOverride);
|
|
3768
|
+
}
|
|
3769
|
+
get method() {
|
|
3770
|
+
return this.source.method.toUpperCase();
|
|
3771
|
+
}
|
|
3772
|
+
get originalUrl() {
|
|
3773
|
+
return this.source.url;
|
|
3774
|
+
}
|
|
3775
|
+
get remoteAddress() {
|
|
3776
|
+
return this.remoteAddressOverride ?? none();
|
|
3777
|
+
}
|
|
3778
|
+
get headers() {
|
|
3779
|
+
this.headersOverride ??= fromInput2(this.source.headers);
|
|
3780
|
+
return this.headersOverride;
|
|
3781
|
+
}
|
|
3782
|
+
cachedCookies;
|
|
3783
|
+
get cookies() {
|
|
3784
|
+
if (this.cachedCookies) {
|
|
3785
|
+
return this.cachedCookies;
|
|
3786
|
+
}
|
|
3787
|
+
return this.cachedCookies = parseHeader(this.headers.cookie ?? "");
|
|
3788
|
+
}
|
|
3789
|
+
get stream() {
|
|
3790
|
+
return this.source.body ? fromReadableStream({
|
|
3791
|
+
evaluate: () => this.source.body,
|
|
3792
|
+
onError: (cause) => new HttpServerError({
|
|
3793
|
+
reason: new RequestParseError({
|
|
3794
|
+
request: this,
|
|
3795
|
+
cause
|
|
3796
|
+
})
|
|
3797
|
+
})
|
|
3798
|
+
}) : fail4(new HttpServerError({
|
|
3799
|
+
reason: new RequestParseError({
|
|
3800
|
+
request: this,
|
|
3801
|
+
description: "can not create stream from empty body"
|
|
3802
|
+
})
|
|
3803
|
+
}));
|
|
3804
|
+
}
|
|
3805
|
+
textEffect;
|
|
3806
|
+
get text() {
|
|
3807
|
+
if (this.textEffect) {
|
|
3808
|
+
return this.textEffect;
|
|
3809
|
+
}
|
|
3810
|
+
this.textEffect = runSync(cached(tryPromise({
|
|
3811
|
+
try: () => this.source.text(),
|
|
3812
|
+
catch: (cause) => new HttpServerError({
|
|
3813
|
+
reason: new RequestParseError({
|
|
3814
|
+
request: this,
|
|
3815
|
+
cause
|
|
3816
|
+
})
|
|
3817
|
+
})
|
|
3818
|
+
})));
|
|
3819
|
+
return this.textEffect;
|
|
3820
|
+
}
|
|
3821
|
+
get json() {
|
|
3822
|
+
return flatMap(this.text, (text3) => try_2({
|
|
3823
|
+
try: () => JSON.parse(text3),
|
|
3824
|
+
catch: (cause) => new HttpServerError({
|
|
3825
|
+
reason: new RequestParseError({
|
|
3826
|
+
request: this,
|
|
3827
|
+
cause
|
|
3828
|
+
})
|
|
3829
|
+
})
|
|
3830
|
+
}));
|
|
3831
|
+
}
|
|
3832
|
+
get urlParamsBody() {
|
|
3833
|
+
return flatMap(this.text, (_) => try_2({
|
|
3834
|
+
try: () => fromInput3(new URLSearchParams(_)),
|
|
3835
|
+
catch: (cause) => new HttpServerError({
|
|
3836
|
+
reason: new RequestParseError({
|
|
3837
|
+
request: this,
|
|
3838
|
+
cause
|
|
3839
|
+
})
|
|
3840
|
+
})
|
|
3841
|
+
}));
|
|
3842
|
+
}
|
|
3843
|
+
multipartEffect;
|
|
3844
|
+
get multipart() {
|
|
3845
|
+
if (this.multipartEffect) {
|
|
3846
|
+
return this.multipartEffect;
|
|
3847
|
+
}
|
|
3848
|
+
this.multipartEffect = runSync(cached(toPersisted(this.multipartStream)));
|
|
3849
|
+
return this.multipartEffect;
|
|
3850
|
+
}
|
|
3851
|
+
get multipartStream() {
|
|
3852
|
+
return pipeThroughChannel(mapError3(this.stream, (cause) => MultipartError.fromReason("InternalError", cause)), makeChannel(this.headers));
|
|
3853
|
+
}
|
|
3854
|
+
arrayBufferEffect;
|
|
3855
|
+
get arrayBuffer() {
|
|
3856
|
+
if (this.arrayBufferEffect) {
|
|
3857
|
+
return this.arrayBufferEffect;
|
|
3858
|
+
}
|
|
3859
|
+
this.arrayBufferEffect = runSync(cached(tryPromise({
|
|
3860
|
+
try: () => this.source.arrayBuffer(),
|
|
3861
|
+
catch: (cause) => new HttpServerError({
|
|
3862
|
+
reason: new RequestParseError({
|
|
3863
|
+
request: this,
|
|
3864
|
+
cause
|
|
3865
|
+
})
|
|
3866
|
+
})
|
|
3867
|
+
})));
|
|
3868
|
+
return this.arrayBufferEffect;
|
|
3869
|
+
}
|
|
3870
|
+
get upgrade() {
|
|
3871
|
+
return fail3(new HttpServerError({
|
|
3872
|
+
reason: new RequestParseError({
|
|
3873
|
+
request: this,
|
|
3874
|
+
description: "Not an upgradeable ServerRequest"
|
|
3875
|
+
})
|
|
3876
|
+
}));
|
|
3877
|
+
}
|
|
3878
|
+
};
|
|
3879
|
+
var ClientRequestImpl = class _ClientRequestImpl extends Class {
|
|
3880
|
+
[TypeId10];
|
|
3881
|
+
[TypeId4];
|
|
3882
|
+
source;
|
|
3883
|
+
originalUrl;
|
|
3884
|
+
headersOverride;
|
|
3885
|
+
remoteAddressOverride;
|
|
3886
|
+
urlOverride;
|
|
3887
|
+
constructor(source, originalUrl, urlOverride, headersOverride, remoteAddressOverride) {
|
|
3888
|
+
super();
|
|
3889
|
+
this[TypeId10] = TypeId10;
|
|
3890
|
+
this[TypeId4] = TypeId4;
|
|
3891
|
+
this.source = source;
|
|
3892
|
+
this.originalUrl = originalUrl;
|
|
3893
|
+
this.urlOverride = urlOverride;
|
|
3894
|
+
this.headersOverride = headersOverride;
|
|
3895
|
+
this.remoteAddressOverride = remoteAddressOverride;
|
|
3896
|
+
}
|
|
3897
|
+
toJSON() {
|
|
3898
|
+
return inspect(this, {
|
|
3899
|
+
_id: "HttpServerRequest",
|
|
3900
|
+
method: this.method,
|
|
3901
|
+
url: this.originalUrl
|
|
3902
|
+
});
|
|
3903
|
+
}
|
|
3904
|
+
modify(options3) {
|
|
3905
|
+
return new _ClientRequestImpl(this.source, this.originalUrl, options3.url ?? this.url, options3.headers ?? this.headersOverride, "remoteAddress" in options3 ? options3.remoteAddress : this.remoteAddressOverride);
|
|
3906
|
+
}
|
|
3907
|
+
get method() {
|
|
3908
|
+
return this.source.method;
|
|
3909
|
+
}
|
|
3910
|
+
get url() {
|
|
3911
|
+
return this.urlOverride ?? removeHost(this.originalUrl);
|
|
3912
|
+
}
|
|
3913
|
+
get remoteAddress() {
|
|
3914
|
+
return this.remoteAddressOverride ?? none();
|
|
3915
|
+
}
|
|
3916
|
+
get headers() {
|
|
3917
|
+
return this.headersOverride ??= this.source.headers;
|
|
3918
|
+
}
|
|
3919
|
+
cachedCookies;
|
|
3920
|
+
get cookies() {
|
|
3921
|
+
if (this.cachedCookies) {
|
|
3922
|
+
return this.cachedCookies;
|
|
3923
|
+
}
|
|
3924
|
+
return this.cachedCookies = parseHeader(this.headers.cookie ?? "");
|
|
3925
|
+
}
|
|
3926
|
+
get stream() {
|
|
3927
|
+
const body = this.source.body;
|
|
3928
|
+
switch (body._tag) {
|
|
3929
|
+
case "Empty": {
|
|
3930
|
+
return empty6;
|
|
3931
|
+
}
|
|
3932
|
+
case "Uint8Array": {
|
|
3933
|
+
return succeed3(body.body);
|
|
3934
|
+
}
|
|
3935
|
+
case "Stream": {
|
|
3936
|
+
return mapError3(body.stream, (cause) => requestParseError(this, void 0, cause));
|
|
3937
|
+
}
|
|
3938
|
+
case "FormData": {
|
|
3939
|
+
return streamFromReadable(this, new Response(body.formData).body);
|
|
3940
|
+
}
|
|
3941
|
+
case "Raw": {
|
|
3942
|
+
return rawBodyStream(this, body.body);
|
|
3943
|
+
}
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
bytesEffect;
|
|
3947
|
+
get bytes() {
|
|
3948
|
+
if (this.bytesEffect) {
|
|
3949
|
+
return this.bytesEffect;
|
|
3950
|
+
}
|
|
3951
|
+
const body = this.source.body;
|
|
3952
|
+
let effect2;
|
|
3953
|
+
switch (body._tag) {
|
|
3954
|
+
case "Empty": {
|
|
3955
|
+
effect2 = succeed2(new Uint8Array(0));
|
|
3956
|
+
break;
|
|
3957
|
+
}
|
|
3958
|
+
case "Uint8Array": {
|
|
3959
|
+
effect2 = succeed2(body.body);
|
|
3960
|
+
break;
|
|
3961
|
+
}
|
|
3962
|
+
case "FormData": {
|
|
3963
|
+
effect2 = bytesFromBodyInit(this, body.formData);
|
|
3964
|
+
break;
|
|
3965
|
+
}
|
|
3966
|
+
case "Stream": {
|
|
3967
|
+
effect2 = mkUint8Array2(this.stream);
|
|
3968
|
+
break;
|
|
3969
|
+
}
|
|
3970
|
+
case "Raw": {
|
|
3971
|
+
effect2 = rawBodyBytes(this, body.body);
|
|
3972
|
+
break;
|
|
3973
|
+
}
|
|
3974
|
+
}
|
|
3975
|
+
this.bytesEffect = runSync(cached(effect2));
|
|
3976
|
+
return this.bytesEffect;
|
|
3977
|
+
}
|
|
3978
|
+
get text() {
|
|
3979
|
+
return map(this.bytes, (bytes) => textDecoder2.decode(bytes));
|
|
3980
|
+
}
|
|
3981
|
+
get json() {
|
|
3982
|
+
return flatMap(this.text, (text3) => try_2({
|
|
3983
|
+
try: () => text3 === "" ? null : JSON.parse(text3),
|
|
3984
|
+
catch: (cause) => requestParseError(this, void 0, cause)
|
|
3985
|
+
}));
|
|
3986
|
+
}
|
|
3987
|
+
get urlParamsBody() {
|
|
3988
|
+
return flatMap(this.text, (_) => try_2({
|
|
3989
|
+
try: () => fromInput3(new URLSearchParams(_)),
|
|
3990
|
+
catch: (cause) => requestParseError(this, void 0, cause)
|
|
3991
|
+
}));
|
|
3992
|
+
}
|
|
3993
|
+
multipartEffect;
|
|
3994
|
+
get multipart() {
|
|
3995
|
+
if (this.multipartEffect) {
|
|
3996
|
+
return this.multipartEffect;
|
|
3997
|
+
}
|
|
3998
|
+
this.multipartEffect = runSync(cached(toPersisted(this.multipartStream)));
|
|
3999
|
+
return this.multipartEffect;
|
|
4000
|
+
}
|
|
4001
|
+
get multipartStream() {
|
|
4002
|
+
const formData3 = this.source.body._tag === "FormData" && this.source.body.formData;
|
|
4003
|
+
if (formData3) {
|
|
4004
|
+
return fromIterable2(formDataToParts(formData3));
|
|
4005
|
+
}
|
|
4006
|
+
return pipeThroughChannel(mapError3(this.stream, (cause) => MultipartError.fromReason("InternalError", cause)), makeChannel(this.headers));
|
|
4007
|
+
}
|
|
4008
|
+
get arrayBuffer() {
|
|
4009
|
+
return map(
|
|
4010
|
+
this.bytes,
|
|
4011
|
+
// Copy this view because Buffer views may share a larger ArrayBuffer.
|
|
4012
|
+
(bytes) => bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength)
|
|
4013
|
+
);
|
|
4014
|
+
}
|
|
4015
|
+
get upgrade() {
|
|
4016
|
+
return fail3(requestParseError(this, "Not an upgradeable ServerRequest"));
|
|
4017
|
+
}
|
|
4018
|
+
};
|
|
4019
|
+
var getFormDataBody = (request) => {
|
|
4020
|
+
if (!isHttpClientRequest(request.source)) {
|
|
4021
|
+
return void 0;
|
|
4022
|
+
}
|
|
4023
|
+
const body = request.source.body;
|
|
4024
|
+
if (body._tag === "FormData") {
|
|
4025
|
+
return body.formData;
|
|
4026
|
+
}
|
|
4027
|
+
if (body._tag === "Raw" && isFormData(body.body)) {
|
|
4028
|
+
return body.body;
|
|
4029
|
+
}
|
|
4030
|
+
return void 0;
|
|
4031
|
+
};
|
|
4032
|
+
var rawBodyStream = (request, body) => {
|
|
4033
|
+
if (body instanceof Request) {
|
|
4034
|
+
return streamFromReadable(request, body.body);
|
|
4035
|
+
}
|
|
4036
|
+
if (isReadableStream3(body)) {
|
|
4037
|
+
return streamFromReadable(request, body);
|
|
4038
|
+
}
|
|
4039
|
+
if (isBodyInit(body)) {
|
|
4040
|
+
return streamFromReadable(request, new Response(body).body);
|
|
4041
|
+
}
|
|
4042
|
+
return fail4(requestParseError(request, "Unsupported body type"));
|
|
4043
|
+
};
|
|
4044
|
+
var rawBodyBytes = (request, body) => {
|
|
4045
|
+
if (body instanceof Request) {
|
|
4046
|
+
return tryPromise({
|
|
4047
|
+
try: () => body.arrayBuffer().then((buffer2) => new Uint8Array(buffer2)),
|
|
4048
|
+
catch: (cause) => requestParseError(request, void 0, cause)
|
|
4049
|
+
});
|
|
4050
|
+
}
|
|
4051
|
+
if (isBodyInit(body)) {
|
|
4052
|
+
return bytesFromBodyInit(request, body);
|
|
4053
|
+
}
|
|
4054
|
+
return fail3(requestParseError(request, "Unsupported body type"));
|
|
4055
|
+
};
|
|
4056
|
+
var bytesFromBodyInit = (request, body) => tryPromise({
|
|
4057
|
+
try: () => new Response(body).arrayBuffer().then((buffer2) => new Uint8Array(buffer2)),
|
|
4058
|
+
catch: (cause) => requestParseError(request, void 0, cause)
|
|
4059
|
+
});
|
|
4060
|
+
var streamFromReadable = (request, body) => body ? fromReadableStream({
|
|
4061
|
+
evaluate: () => body,
|
|
4062
|
+
onError: (cause) => requestParseError(request, void 0, cause)
|
|
4063
|
+
}) : empty6;
|
|
4064
|
+
var requestParseError = (request, description, cause) => new HttpServerError({
|
|
4065
|
+
reason: new RequestParseError({
|
|
4066
|
+
request,
|
|
4067
|
+
...description === void 0 ? void 0 : {
|
|
4068
|
+
description
|
|
4069
|
+
},
|
|
4070
|
+
...cause === void 0 ? void 0 : {
|
|
4071
|
+
cause
|
|
4072
|
+
}
|
|
4073
|
+
})
|
|
4074
|
+
});
|
|
4075
|
+
var formDataToParts = (formData3) => {
|
|
4076
|
+
const parts = [];
|
|
4077
|
+
for (const [key, value] of formData3.entries()) {
|
|
4078
|
+
parts.push(typeof value === "string" ? new MultipartFieldPart(key, value) : new MultipartFilePart(key, value));
|
|
4079
|
+
}
|
|
4080
|
+
return parts;
|
|
4081
|
+
};
|
|
4082
|
+
var MultipartFieldPart = class extends Class {
|
|
4083
|
+
[TypeId9];
|
|
4084
|
+
_tag = "Field";
|
|
4085
|
+
contentType = "text/plain";
|
|
4086
|
+
key;
|
|
4087
|
+
value;
|
|
4088
|
+
constructor(key, value) {
|
|
4089
|
+
super();
|
|
4090
|
+
this[TypeId9] = TypeId9;
|
|
4091
|
+
this.key = key;
|
|
4092
|
+
this.value = value;
|
|
4093
|
+
}
|
|
4094
|
+
toJSON() {
|
|
4095
|
+
return {
|
|
4096
|
+
_id: "@effect/platform/Multipart/Part",
|
|
4097
|
+
_tag: "Field",
|
|
4098
|
+
key: this.key,
|
|
4099
|
+
contentType: this.contentType,
|
|
4100
|
+
value: this.value
|
|
4101
|
+
};
|
|
4102
|
+
}
|
|
4103
|
+
};
|
|
4104
|
+
var MultipartFilePart = class extends Class {
|
|
4105
|
+
[TypeId9];
|
|
4106
|
+
_tag = "File";
|
|
4107
|
+
key;
|
|
4108
|
+
name;
|
|
4109
|
+
contentType;
|
|
4110
|
+
content;
|
|
4111
|
+
contentEffect;
|
|
4112
|
+
constructor(key, file3) {
|
|
4113
|
+
super();
|
|
4114
|
+
this[TypeId9] = TypeId9;
|
|
4115
|
+
this.key = key;
|
|
4116
|
+
this.name = file3.name;
|
|
4117
|
+
this.contentType = file3.type;
|
|
4118
|
+
this.content = fromReadableStream({
|
|
4119
|
+
evaluate: () => file3.stream(),
|
|
4120
|
+
onError: (cause) => MultipartError.fromReason("InternalError", cause)
|
|
4121
|
+
});
|
|
4122
|
+
this.contentEffect = tryPromise({
|
|
4123
|
+
try: () => file3.arrayBuffer().then((buffer2) => new Uint8Array(buffer2)),
|
|
4124
|
+
catch: (cause) => MultipartError.fromReason("InternalError", cause)
|
|
4125
|
+
});
|
|
4126
|
+
}
|
|
4127
|
+
toJSON() {
|
|
4128
|
+
return {
|
|
4129
|
+
_id: "@effect/platform/Multipart/Part",
|
|
4130
|
+
_tag: "File",
|
|
4131
|
+
key: this.key,
|
|
4132
|
+
name: this.name,
|
|
4133
|
+
contentType: this.contentType
|
|
4134
|
+
};
|
|
4135
|
+
}
|
|
4136
|
+
};
|
|
4137
|
+
var isReadableStream3 = (u) => typeof ReadableStream !== "undefined" && u instanceof ReadableStream;
|
|
4138
|
+
var isFormData = (u) => typeof FormData !== "undefined" && u instanceof FormData;
|
|
4139
|
+
var isBodyInit = (u) => typeof u === "string" || typeof ArrayBuffer !== "undefined" && (u instanceof ArrayBuffer || ArrayBuffer.isView(u)) || typeof Blob !== "undefined" && u instanceof Blob || isFormData(u) || typeof URLSearchParams !== "undefined" && u instanceof URLSearchParams || isReadableStream3(u);
|
|
4140
|
+
var textDecoder2 = /* @__PURE__ */ new TextDecoder();
|
|
4141
|
+
var toURL = (self) => {
|
|
4142
|
+
const host = self.headers.host ?? "localhost";
|
|
4143
|
+
const protocol = self.headers["x-forwarded-proto"] === "https" ? "https" : "http";
|
|
4144
|
+
try {
|
|
4145
|
+
return some(new URL(self.url, `${protocol}://${host}`));
|
|
4146
|
+
} catch {
|
|
4147
|
+
return none();
|
|
4148
|
+
}
|
|
4149
|
+
};
|
|
4150
|
+
var toWebResult2 = (self, options3) => {
|
|
4151
|
+
if (self.source instanceof Request) {
|
|
4152
|
+
return succeed(self.source);
|
|
4153
|
+
}
|
|
4154
|
+
const url = toURL(self);
|
|
4155
|
+
if (isNone(url)) {
|
|
4156
|
+
return fail(new RequestParseError({
|
|
4157
|
+
request: self,
|
|
4158
|
+
description: "Invalid URL"
|
|
4159
|
+
}));
|
|
4160
|
+
}
|
|
4161
|
+
const requestInit = {
|
|
4162
|
+
method: self.method,
|
|
4163
|
+
headers: self.headers
|
|
4164
|
+
};
|
|
4165
|
+
if (options3?.signal) {
|
|
4166
|
+
requestInit.signal = options3.signal;
|
|
4167
|
+
}
|
|
4168
|
+
if (hasBody(self.method)) {
|
|
4169
|
+
requestInit.body = toReadableStreamWith(self.stream, options3?.context ?? empty2());
|
|
4170
|
+
requestInit.duplex = "half";
|
|
4171
|
+
}
|
|
4172
|
+
return succeed(new Request(url.value, requestInit));
|
|
4173
|
+
};
|
|
4174
|
+
var toWeb3 = (self, options3) => contextWith((context2) => fromResult(toWebResult2(self, {
|
|
4175
|
+
context: context2,
|
|
4176
|
+
signal: options3?.signal
|
|
4177
|
+
})));
|
|
4178
|
+
|
|
4179
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpMiddleware.js
|
|
4180
|
+
var loggerDisabledRequests = /* @__PURE__ */ new WeakSet();
|
|
4181
|
+
var withLoggerDisabled = (self) => withFiber((fiber) => {
|
|
4182
|
+
const request = getUnsafe(fiber.context, HttpServerRequest);
|
|
4183
|
+
loggerDisabledRequests.add(request.source);
|
|
4184
|
+
return self;
|
|
4185
|
+
});
|
|
4186
|
+
|
|
4187
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpRouter.js
|
|
4188
|
+
var HttpRouter = /* @__PURE__ */ Service("effect/http/HttpRouter");
|
|
4189
|
+
var removeTrailingSlash = (path) => path.endsWith("/") ? path.slice(0, -1) : path;
|
|
4190
|
+
var prefixPath = /* @__PURE__ */ dual(2, (self, prefix) => {
|
|
4191
|
+
prefix = removeTrailingSlash(prefix);
|
|
4192
|
+
if (self === "*") return `${prefix}/*`;
|
|
4193
|
+
else if (self === "/") return prefix;
|
|
4194
|
+
return prefix + self;
|
|
4195
|
+
});
|
|
4196
|
+
var MiddlewareTypeId = "~effect/http/HttpRouter/Middleware";
|
|
4197
|
+
var middleware = function() {
|
|
4198
|
+
if (arguments.length === 0) {
|
|
4199
|
+
return makeMiddleware;
|
|
4200
|
+
}
|
|
4201
|
+
return makeMiddleware(arguments[0], arguments[1]);
|
|
4202
|
+
};
|
|
4203
|
+
var makeMiddleware = (middleware2, options3) => options3?.global ? effectDiscard(gen(function* () {
|
|
4204
|
+
const router = yield* HttpRouter;
|
|
4205
|
+
const fn = isEffect(middleware2) ? yield* middleware2 : middleware2;
|
|
4206
|
+
yield* router.addGlobalMiddleware(fn);
|
|
4207
|
+
})) : new MiddlewareImpl(isEffect(middleware2) ? effectContext(map(middleware2, (fn) => makeUnsafe(/* @__PURE__ */ new Map([[fnContextKey, fn]])))) : succeedContext(makeUnsafe(/* @__PURE__ */ new Map([[fnContextKey, middleware2]]))));
|
|
4208
|
+
var middlewareId = 0;
|
|
4209
|
+
var fnContextKey = "effect/http/HttpRouter/MiddlewareFn";
|
|
4210
|
+
var MiddlewareImpl = class _MiddlewareImpl {
|
|
4211
|
+
[MiddlewareTypeId] = {};
|
|
4212
|
+
layerFn;
|
|
4213
|
+
dependencies;
|
|
4214
|
+
constructor(layerFn, dependencies) {
|
|
4215
|
+
this.layerFn = layerFn;
|
|
4216
|
+
this.dependencies = dependencies;
|
|
4217
|
+
const contextKey = `effect/http/HttpRouter/Middleware-${++middlewareId}`;
|
|
4218
|
+
this.layer = effectContext(gen({
|
|
4219
|
+
self: this
|
|
4220
|
+
}, function* () {
|
|
4221
|
+
const context2 = yield* context();
|
|
4222
|
+
const stack = [getOrUndefinedUnsafe(context2, fnContextKey)];
|
|
4223
|
+
if (this.dependencies) {
|
|
4224
|
+
const memoMap = yield* CurrentMemoMap;
|
|
4225
|
+
const scope2 = get(context2, Scope);
|
|
4226
|
+
const depsContext = yield* buildWithMemoMap(this.dependencies, memoMap, scope2);
|
|
4227
|
+
stack.push(...getMiddleware(depsContext));
|
|
4228
|
+
}
|
|
4229
|
+
return makeUnsafe(/* @__PURE__ */ new Map([[contextKey, stack]]));
|
|
4230
|
+
})).pipe(provide2(this.layerFn));
|
|
4231
|
+
}
|
|
4232
|
+
layer;
|
|
4233
|
+
combine(other) {
|
|
4234
|
+
return new _MiddlewareImpl(this.layerFn, this.dependencies ? provideMerge(this.dependencies, other.layer) : other.layer);
|
|
4235
|
+
}
|
|
4236
|
+
};
|
|
4237
|
+
var middlewareCache = /* @__PURE__ */ new WeakMap();
|
|
4238
|
+
var getMiddleware = (context2) => {
|
|
4239
|
+
let arr = middlewareCache.get(context2);
|
|
4240
|
+
if (arr) return arr;
|
|
4241
|
+
const topLevel = empty();
|
|
4242
|
+
let maxLength = 0;
|
|
4243
|
+
for (const [key, value] of context2.mapUnsafe) {
|
|
4244
|
+
if (key.startsWith("effect/http/HttpRouter/Middleware-")) {
|
|
4245
|
+
topLevel.push(value);
|
|
4246
|
+
if (value.length > maxLength) {
|
|
4247
|
+
maxLength = value.length;
|
|
4248
|
+
}
|
|
4249
|
+
}
|
|
4250
|
+
}
|
|
4251
|
+
if (topLevel.length === 0) {
|
|
4252
|
+
arr = [];
|
|
4253
|
+
} else {
|
|
4254
|
+
const middleware2 = /* @__PURE__ */ new Set();
|
|
4255
|
+
for (let i = maxLength - 1; i >= 0; i--) {
|
|
4256
|
+
for (const arr2 of topLevel) {
|
|
4257
|
+
if (i < arr2.length) {
|
|
4258
|
+
middleware2.add(arr2[i]);
|
|
4259
|
+
}
|
|
4260
|
+
}
|
|
4261
|
+
}
|
|
4262
|
+
arr = fromIterable(middleware2).reverse();
|
|
4263
|
+
}
|
|
4264
|
+
middlewareCache.set(context2, arr);
|
|
4265
|
+
return arr;
|
|
4266
|
+
};
|
|
4267
|
+
var disableLogger = middleware(withLoggerDisabled).layer;
|
|
4268
|
+
|
|
4269
|
+
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/HttpStatus.js
|
|
4270
|
+
var codeByLiteral = {
|
|
4271
|
+
Continue: 100,
|
|
4272
|
+
SwitchingProtocols: 101,
|
|
4273
|
+
Processing: 102,
|
|
4274
|
+
EarlyHints: 103,
|
|
4275
|
+
OK: 200,
|
|
4276
|
+
Ok: 200,
|
|
4277
|
+
Created: 201,
|
|
4278
|
+
Accepted: 202,
|
|
4279
|
+
NonAuthoritativeInformation: 203,
|
|
4280
|
+
NoContent: 204,
|
|
4281
|
+
ResetContent: 205,
|
|
4282
|
+
PartialContent: 206,
|
|
4283
|
+
MultiStatus: 207,
|
|
4284
|
+
AlreadyReported: 208,
|
|
4285
|
+
ImUsed: 226,
|
|
4286
|
+
MultipleChoices: 300,
|
|
4287
|
+
MovedPermanently: 301,
|
|
4288
|
+
Found: 302,
|
|
4289
|
+
SeeOther: 303,
|
|
4290
|
+
NotModified: 304,
|
|
4291
|
+
TemporaryRedirect: 307,
|
|
4292
|
+
PermanentRedirect: 308,
|
|
4293
|
+
BadRequest: 400,
|
|
4294
|
+
Unauthorized: 401,
|
|
4295
|
+
PaymentRequired: 402,
|
|
4296
|
+
Forbidden: 403,
|
|
4297
|
+
NotFound: 404,
|
|
4298
|
+
MethodNotAllowed: 405,
|
|
4299
|
+
NotAcceptable: 406,
|
|
4300
|
+
ProxyAuthenticationRequired: 407,
|
|
4301
|
+
RequestTimeout: 408,
|
|
4302
|
+
Conflict: 409,
|
|
4303
|
+
Gone: 410,
|
|
4304
|
+
LengthRequired: 411,
|
|
4305
|
+
PreconditionFailed: 412,
|
|
4306
|
+
PayloadTooLarge: 413,
|
|
4307
|
+
UriTooLong: 414,
|
|
4308
|
+
UnsupportedMediaType: 415,
|
|
4309
|
+
RangeNotSatisfiable: 416,
|
|
4310
|
+
ExpectationFailed: 417,
|
|
4311
|
+
ImATeapot: 418,
|
|
4312
|
+
MisdirectedRequest: 421,
|
|
4313
|
+
UnprocessableEntity: 422,
|
|
4314
|
+
Locked: 423,
|
|
4315
|
+
FailedDependency: 424,
|
|
4316
|
+
TooEarly: 425,
|
|
4317
|
+
UpgradeRequired: 426,
|
|
4318
|
+
PreconditionRequired: 428,
|
|
4319
|
+
TooManyRequests: 429,
|
|
4320
|
+
RequestHeaderFieldsTooLarge: 431,
|
|
4321
|
+
UnavailableForLegalReasons: 451,
|
|
4322
|
+
InternalServerError: 500,
|
|
4323
|
+
NotImplemented: 501,
|
|
4324
|
+
BadGateway: 502,
|
|
4325
|
+
ServiceUnavailable: 503,
|
|
4326
|
+
GatewayTimeout: 504,
|
|
4327
|
+
HttpVersionNotSupported: 505,
|
|
4328
|
+
VariantAlsoNegotiates: 506,
|
|
4329
|
+
InsufficientStorage: 507,
|
|
4330
|
+
LoopDetected: 508,
|
|
4331
|
+
NotExtended: 510,
|
|
4332
|
+
NetworkAuthenticationRequired: 511
|
|
4333
|
+
};
|
|
4334
|
+
var fromLiteral = (literal) => codeByLiteral[literal];
|
|
4335
|
+
|
|
4336
|
+
export {
|
|
4337
|
+
isHttpBody,
|
|
4338
|
+
uint8Array,
|
|
4339
|
+
text,
|
|
4340
|
+
jsonUnsafe,
|
|
4341
|
+
urlParams,
|
|
4342
|
+
HttpBody_exports,
|
|
4343
|
+
isHttpClientError,
|
|
4344
|
+
HttpClientError,
|
|
4345
|
+
TransportError,
|
|
4346
|
+
StatusCodeError,
|
|
4347
|
+
DecodeError,
|
|
4348
|
+
HttpClientError_exports,
|
|
4349
|
+
hasBody,
|
|
4350
|
+
make2 as make,
|
|
4351
|
+
get4 as get,
|
|
4352
|
+
post,
|
|
4353
|
+
setHeaders,
|
|
4354
|
+
setUrl,
|
|
4355
|
+
prependUrl,
|
|
4356
|
+
appendUrlParams,
|
|
4357
|
+
setBody,
|
|
4358
|
+
bodyFormData,
|
|
4359
|
+
HttpClientRequest_exports,
|
|
4360
|
+
fromWeb2 as fromWeb,
|
|
4361
|
+
HttpTraceContext_exports,
|
|
4362
|
+
HttpClient,
|
|
4363
|
+
transformResponse,
|
|
4364
|
+
filterStatusOk2 as filterStatusOk,
|
|
4365
|
+
make3 as make2,
|
|
4366
|
+
mapRequest,
|
|
4367
|
+
retryTransient,
|
|
4368
|
+
TracerPropagationEnabled,
|
|
4369
|
+
layerMergedContext,
|
|
4370
|
+
HttpClient_exports,
|
|
4371
|
+
HttpServerResponse_exports,
|
|
4372
|
+
HttpServerRequest_exports,
|
|
4373
|
+
prefixPath,
|
|
4374
|
+
fromLiteral
|
|
4375
|
+
};
|