@akterjs/cli 0.0.0-stage → 0.1.1
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/LICENSE +201 -0
- package/README.md +47 -2
- package/dist/Argument-D81dqizB.mjs +57 -0
- package/dist/Array-B4kuTQeW.mjs +2323 -0
- package/dist/Boolean-kILIvmhE.mjs +26 -0
- package/dist/ChildProcess-BCIwxPGc.mjs +577 -0
- package/dist/CliError-Cf5xqkkj.mjs +633 -0
- package/dist/Command-Dzq9KM-h.mjs +5135 -0
- package/dist/Config-B6OND9WR.mjs +854 -0
- package/dist/Console-BKHUkH6a.mjs +141 -0
- package/dist/Data-CeCULr0-.mjs +251 -0
- package/dist/Digest-CBd3uv5B.mjs +348 -0
- package/dist/Duration-EH9Vy4U6.mjs +791 -0
- package/dist/Effect-CKFpqbmw.mjs +12911 -0
- package/dist/FileSystem-4pPcEb_i.mjs +1366 -0
- package/dist/HttpClientError-BUeMWx70.mjs +303 -0
- package/dist/HttpClientResponse-D5ZKICVV.mjs +855 -0
- package/dist/Match-CGPLZYrV.mjs +434 -0
- package/dist/MutableHashMap-f8nW8AJR.mjs +376 -0
- package/dist/MutableHashSet-_HI572Ya.mjs +155 -0
- package/dist/MutableRef-D4Qv592C.mjs +107 -0
- package/dist/Number-BvkRkfc-.mjs +137 -0
- package/dist/Option-DkxSnBhp.mjs +3967 -0
- package/dist/Order-C1JC991I.mjs +481 -0
- package/dist/Path-Djdv_eF5.mjs +130 -0
- package/dist/Queue-CO5UQ6os.mjs +1394 -0
- package/dist/Redacted-RkJrG5Me.mjs +160 -0
- package/dist/Ref-BIPOxJNH.mjs +267 -0
- package/dist/Runtime-BInIAwK3.mjs +297 -0
- package/dist/Schema-MiKt5K1v.mjs +10999 -0
- package/dist/SecureRandom-B_U4ysO3.mjs +279 -0
- package/dist/Semaphore-DOVJ4ZGS.mjs +177 -0
- package/dist/Stdio-KylmOBX_.mjs +74 -0
- package/dist/Stream-bK9QIETN.mjs +4012 -0
- package/dist/String-q5dcsVe4.mjs +351 -0
- package/dist/TerminalCapabilities-w_44MAca.mjs +1769 -0
- package/dist/WebCrypto-ZI_GNVlw.mjs +33 -0
- package/dist/actor-call.service-CGM_vD9u.mjs +1269 -0
- package/dist/actor-client.adapter-Coem7gF1.mjs +3691 -0
- package/dist/akter-program.config-D8yb9xQP.mjs +7034 -0
- package/dist/akter.cli.mjs +5 -0
- package/dist/app-cli.config.mjs +49 -0
- package/dist/app-entry.pure.mjs +31 -0
- package/dist/archive/akter-archive.schema.mjs +65 -0
- package/dist/archive/akter-archive.service.mjs +309 -0
- package/dist/archive/archive-cli.config.mjs +45 -0
- package/dist/archive/archive-invalid.errors.mjs +5 -0
- package/dist/archive/archived-lineage.pure.mjs +13 -0
- package/dist/archive/tar.pure.mjs +291 -0
- package/dist/archive/zstd.adapter.mjs +46 -0
- package/dist/bench/bench-report.pure.mjs +120 -0
- package/dist/bench/bench-runner.pure.mjs +89 -0
- package/dist/bench/bench.service.mjs +301 -0
- package/dist/cli-runtime.layer-BqK2mmVL.mjs +1191 -0
- package/dist/cli-runtime.layer.mjs +1 -0
- package/dist/cloud-client.adapter-Cy1BjDbG.mjs +3186 -0
- package/dist/cloud-client.adapter-DOVMoYAj.mjs +304 -0
- package/dist/command/akter-commands.config.mjs +32 -0
- package/dist/command/akter-program.config.mjs +1 -0
- package/dist/credentials/credentials.service.mjs +226 -0
- package/dist/credentials/keychain.adapter.mjs +92 -0
- package/dist/credentials/login.config.mjs +251 -0
- package/dist/deploy/auth/api-attempt.service.mjs +30 -0
- package/dist/deploy/auth/token-refresh.errors.mjs +4 -0
- package/dist/deploy/build-bundle.adapter.mjs +133 -0
- package/dist/deploy/build-manifest.pure.mjs +44 -0
- package/dist/deploy/cloud-client.adapter.mjs +1 -0
- package/dist/deploy/cloud-url.pure.mjs +17 -0
- package/dist/deploy/deploy-failed.errors.mjs +17 -0
- package/dist/deploy/deploy.service.mjs +156 -0
- package/dist/deploy/request-failure.pure.mjs +87 -0
- package/dist/dev-runner.pure.mjs +30 -0
- package/dist/docs/doc-topics.pure.mjs +21 -0
- package/dist/docs/docs.config.mjs +1 -0
- package/dist/docs.config-D2amjsje.mjs +190 -0
- package/dist/docs.config-D3zzLzLR.mjs +190 -0
- package/dist/export/actor-export.service.mjs +267 -0
- package/dist/export/export-failed.errors.mjs +4 -0
- package/dist/export/export-failure.pure.mjs +18 -0
- package/dist/export/ordered-lines.pure.mjs +43 -0
- package/dist/export/ranged-download.pure.mjs +66 -0
- package/dist/export/snapshot-download.pure.mjs +86 -0
- package/dist/history-runner.pure.mjs +186 -0
- package/dist/history-since.pure.mjs +17 -0
- package/dist/hosted-runtime.layer-Cx3IPsEd.mjs +16358 -0
- package/dist/local/environment-cli.config.mjs +90 -0
- package/dist/local/environment-runner.pure.mjs +75 -0
- package/dist/local/local-cli.config.mjs +159 -0
- package/dist/logs/log-follow.config.mjs +21 -0
- package/dist/logs/log-follow.service.mjs +87 -0
- package/dist/logs/log-lines.pure.mjs +44 -0
- package/dist/migrate-runner.pure.mjs +28 -0
- package/dist/operation-input.pure-CS9iUhqK.mjs +1383 -0
- package/dist/operation-registry.pure-DVC8EDgj.mjs +283 -0
- package/dist/registry/actor-call.service.mjs +1 -0
- package/dist/registry/actor-commands.config.mjs +127 -0
- package/dist/registry/actor-refusal.pure.mjs +34 -0
- package/dist/registry/approval.service.mjs +80 -0
- package/dist/registry/cloud-commands.config.mjs +151 -0
- package/dist/registry/cloud-served.pure.mjs +31 -0
- package/dist/registry/operation-call.service.mjs +262 -0
- package/dist/registry/operation-input.pure.mjs +1 -0
- package/dist/registry/operation-output.pure.mjs +91 -0
- package/dist/registry/served-command.config.mjs +57 -0
- package/dist/runner-exited.errors.mjs +10 -0
- package/dist/terminal/cli-exit.errors.mjs +38 -0
- package/dist/terminal/cli-failure.pure.mjs +31 -0
- package/dist/terminal/confirm.adapter.mjs +27 -0
- package/package.json +61 -3
|
@@ -0,0 +1,855 @@
|
|
|
1
|
+
import { Ct as NodeInspectSymbol, Et as format, Mt as redact, On as pipeArguments, S as none, St as Class, bn as dual, h as isNone, m as getOrUndefined, qt as hasProperty, u as fromNullishOr, w as some, xt as BaseProto } from "./Option-DkxSnBhp.mjs";
|
|
2
|
+
import { B as flatMap, M as fail, Vt as runSync, Xt as succeed, cn as tryPromise, dt as map, f as cached, hi as currentTimeMillis$1, ia as Reference, li as ClockRef, ln as try_ } from "./Effect-CKFpqbmw.mjs";
|
|
3
|
+
import { ot as try_$1, tt as isSuccess } from "./Array-B4kuTQeW.mjs";
|
|
4
|
+
import { $n as set, Bn as set$1, Hn as fromBody, Kn as empty$3, Ln as empty$2, Qn as remove, Rn as fromInput, Vn as setAll$1, Wn as unwrap, cn as toCodecJson, er as setAll, nr as fromSetCookie, pt as fromJsonString, qn as fromInput$1, tt as decodeEffect, zn as redactUrl } from "./Schema-MiKt5K1v.mjs";
|
|
5
|
+
import { i as TaggedError } from "./Data-CeCULr0-.mjs";
|
|
6
|
+
import { S as fromReadableStream, f as fail$1 } from "./Stream-bK9QIETN.mjs";
|
|
7
|
+
import { a as stringOrRedacted } from "./Redacted-RkJrG5Me.mjs";
|
|
8
|
+
import { i as HttpClientError, n as EmptyBodyError, s as StatusCodeError, t as DecodeError } from "./HttpClientError-BUeMWx70.mjs";
|
|
9
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Clock.js
|
|
10
|
+
/**
|
|
11
|
+
* Context reference for the active time service in the environment.
|
|
12
|
+
*
|
|
13
|
+
* **When to use**
|
|
14
|
+
*
|
|
15
|
+
* Use when you need to access or provide the full time service, including sleep
|
|
16
|
+
* operations, rather than a single timestamp accessor.
|
|
17
|
+
*
|
|
18
|
+
* **Example** (Accessing the Clock service)
|
|
19
|
+
*
|
|
20
|
+
* ```ts import.meta.vitest
|
|
21
|
+
* import { Clock, Effect } from "effect"
|
|
22
|
+
*
|
|
23
|
+
* const testClock: Clock.Clock = {
|
|
24
|
+
* currentTimeMillisUnsafe: () => 1_000,
|
|
25
|
+
* currentTimeMillis: Effect.succeed(1_000),
|
|
26
|
+
* monotonicTimeNanosUnsafe: () => 1_000_000_000n,
|
|
27
|
+
* monotonicTimeNanos: Effect.succeed(1_000_000_000n),
|
|
28
|
+
* currentTimeNanosUnsafe: () => 1_000_000_000n,
|
|
29
|
+
* currentTimeNanos: Effect.succeed(1_000_000_000n),
|
|
30
|
+
* sleep: () => Effect.void
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* const program = Effect.gen(function*() {
|
|
34
|
+
* const clock = yield* Clock.Clock
|
|
35
|
+
* return clock.currentTimeMillisUnsafe()
|
|
36
|
+
* })
|
|
37
|
+
*
|
|
38
|
+
* await Effect.runPromise(Effect.provideService(program, Clock.Clock, testClock)) // => 1_000
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @see {@link clockWith} for using the current Clock service inside an effect
|
|
42
|
+
* @see {@link currentTimeMillis} for reading the current time in milliseconds
|
|
43
|
+
* @see {@link currentTimeNanos} for reading the current time in nanoseconds
|
|
44
|
+
*
|
|
45
|
+
* @stability stable
|
|
46
|
+
* @category services
|
|
47
|
+
* @since 2.0.0
|
|
48
|
+
*/
|
|
49
|
+
const Clock = ClockRef;
|
|
50
|
+
/**
|
|
51
|
+
* Returns an Effect that succeeds with the current Unix time in milliseconds.
|
|
52
|
+
*
|
|
53
|
+
* **When to use**
|
|
54
|
+
*
|
|
55
|
+
* Use to create wall-clock timestamps from the active `Clock` service with
|
|
56
|
+
* millisecond precision.
|
|
57
|
+
*
|
|
58
|
+
* **Gotchas**
|
|
59
|
+
*
|
|
60
|
+
* The value can move backward or forward when the system wall clock is
|
|
61
|
+
* corrected, so it is not suitable for measuring elapsed time.
|
|
62
|
+
*
|
|
63
|
+
* **Example** (Reading milliseconds)
|
|
64
|
+
*
|
|
65
|
+
* ```ts import.meta.vitest
|
|
66
|
+
* import { Clock, Effect } from "effect"
|
|
67
|
+
*
|
|
68
|
+
* const testClock: Clock.Clock = {
|
|
69
|
+
* currentTimeMillisUnsafe: () => 1_000,
|
|
70
|
+
* currentTimeMillis: Effect.succeed(1_000),
|
|
71
|
+
* monotonicTimeNanosUnsafe: () => 1_000_000_000n,
|
|
72
|
+
* monotonicTimeNanos: Effect.succeed(1_000_000_000n),
|
|
73
|
+
* currentTimeNanosUnsafe: () => 1_000_000_000n,
|
|
74
|
+
* currentTimeNanos: Effect.succeed(1_000_000_000n),
|
|
75
|
+
* sleep: () => Effect.void
|
|
76
|
+
* }
|
|
77
|
+
*
|
|
78
|
+
* await Effect.runPromise(Effect.provideService(Clock.currentTimeMillis, Clock.Clock, testClock)) // => 1_000
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @see {@link currentTimeNanos} for nanosecond precision
|
|
82
|
+
* @see {@link monotonicTimeNanos} for measuring elapsed time
|
|
83
|
+
* @see {@link clockWith} for accessing the full Clock service
|
|
84
|
+
*
|
|
85
|
+
* @stability stable
|
|
86
|
+
* @category accessors
|
|
87
|
+
* @since 2.0.0
|
|
88
|
+
*/
|
|
89
|
+
const currentTimeMillis = currentTimeMillis$1;
|
|
90
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/http/HttpBody.js
|
|
91
|
+
const TypeId$3 = "~effect/http/HttpBody";
|
|
92
|
+
const HttpBodyErrorTypeId = "~effect/http/HttpBody/HttpBodyError";
|
|
93
|
+
/**
|
|
94
|
+
* Error produced while constructing an HTTP body from JSON or schema-encoded input.
|
|
95
|
+
*
|
|
96
|
+
* @stability unstable
|
|
97
|
+
* @category errors
|
|
98
|
+
* @since 4.0.0
|
|
99
|
+
*/
|
|
100
|
+
var HttpBodyError = class extends (/*#__PURE__*/ TaggedError("HttpBodyError")) {
|
|
101
|
+
/**
|
|
102
|
+
* Marks this value as an HTTP body error for runtime guards.
|
|
103
|
+
*
|
|
104
|
+
* @stability unstable
|
|
105
|
+
* @since 4.0.0
|
|
106
|
+
*/
|
|
107
|
+
[HttpBodyErrorTypeId] = HttpBodyErrorTypeId;
|
|
108
|
+
};
|
|
109
|
+
var Proto$1 = class {
|
|
110
|
+
[TypeId$3];
|
|
111
|
+
constructor() {
|
|
112
|
+
this[TypeId$3] = TypeId$3;
|
|
113
|
+
}
|
|
114
|
+
[NodeInspectSymbol]() {
|
|
115
|
+
return this.toJSON();
|
|
116
|
+
}
|
|
117
|
+
toString() {
|
|
118
|
+
return format(this, { ignoreToString: true });
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* HTTP body variant representing the absence of request content.
|
|
123
|
+
*
|
|
124
|
+
* @stability unstable
|
|
125
|
+
* @category models
|
|
126
|
+
* @since 4.0.0
|
|
127
|
+
*/
|
|
128
|
+
var Empty = class extends Proto$1 {
|
|
129
|
+
_tag = "Empty";
|
|
130
|
+
toJSON() {
|
|
131
|
+
return {
|
|
132
|
+
_id: "effect/HttpBody",
|
|
133
|
+
_tag: "Empty"
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Provides the singleton empty HTTP body.
|
|
139
|
+
*
|
|
140
|
+
* **When to use**
|
|
141
|
+
*
|
|
142
|
+
* Use when you need an HTTP body value that represents no body content.
|
|
143
|
+
*
|
|
144
|
+
* @stability unstable
|
|
145
|
+
* @category constants
|
|
146
|
+
* @since 4.0.0
|
|
147
|
+
*/
|
|
148
|
+
const empty$1 = /*#__PURE__*/ new Empty();
|
|
149
|
+
/**
|
|
150
|
+
* HTTP body variant backed by a `Uint8Array`.
|
|
151
|
+
*
|
|
152
|
+
* **Details**
|
|
153
|
+
*
|
|
154
|
+
* It stores the bytes, content type, and byte length.
|
|
155
|
+
*
|
|
156
|
+
* @stability unstable
|
|
157
|
+
* @category models
|
|
158
|
+
* @since 4.0.0
|
|
159
|
+
*/
|
|
160
|
+
var Uint8Array = class extends Proto$1 {
|
|
161
|
+
_tag = "Uint8Array";
|
|
162
|
+
contentType;
|
|
163
|
+
contentLength;
|
|
164
|
+
/** Original text retained for adapters that can skip encoding. */
|
|
165
|
+
text;
|
|
166
|
+
_body;
|
|
167
|
+
constructor(body, contentType, contentLength, text) {
|
|
168
|
+
super();
|
|
169
|
+
this._body = body;
|
|
170
|
+
this.text = text;
|
|
171
|
+
this.contentType = contentType;
|
|
172
|
+
this.contentLength = contentLength;
|
|
173
|
+
}
|
|
174
|
+
get body() {
|
|
175
|
+
return this._body ??= encodeText(this.text);
|
|
176
|
+
}
|
|
177
|
+
toJSON() {
|
|
178
|
+
return {
|
|
179
|
+
_id: "effect/HttpBody",
|
|
180
|
+
_tag: "Uint8Array",
|
|
181
|
+
body: this.contentType.startsWith("text/") || this.contentType.endsWith("json") ? new TextDecoder().decode(this.body) : `Uint8Array(${this.body.length})`,
|
|
182
|
+
contentType: this.contentType,
|
|
183
|
+
contentLength: this.contentLength
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Creates a byte-array HTTP body.
|
|
189
|
+
*
|
|
190
|
+
* **Details**
|
|
191
|
+
*
|
|
192
|
+
* The content type defaults to `application/octet-stream`, and the content length is the byte array length.
|
|
193
|
+
*
|
|
194
|
+
* @stability unstable
|
|
195
|
+
* @category constructors
|
|
196
|
+
* @since 4.0.0
|
|
197
|
+
*/
|
|
198
|
+
const uint8Array = (body, contentType) => new Uint8Array(body, contentType ?? "application/octet-stream", body.length);
|
|
199
|
+
const encoder = /*#__PURE__*/ new TextEncoder();
|
|
200
|
+
const buffer = globalThis.Buffer;
|
|
201
|
+
const encodeText = buffer !== void 0 ? (body) => buffer.from(body, "utf8") : (body) => encoder.encode(body);
|
|
202
|
+
/**
|
|
203
|
+
* Creates a UTF-8 encoded text HTTP body.
|
|
204
|
+
*
|
|
205
|
+
* **Details**
|
|
206
|
+
*
|
|
207
|
+
* The content type defaults to `text/plain`. Text bodies are encoded lazily.
|
|
208
|
+
*
|
|
209
|
+
* @stability unstable
|
|
210
|
+
* @category constructors
|
|
211
|
+
* @since 4.0.0
|
|
212
|
+
*/
|
|
213
|
+
const text = (body, contentType) => {
|
|
214
|
+
if (typeof body !== "string") body = body === void 0 ? "" : String(body);
|
|
215
|
+
if (buffer !== void 0) return new Uint8Array(void 0, contentType ?? "text/plain", buffer.byteLength(body, "utf8"), body);
|
|
216
|
+
const bytes = encoder.encode(body);
|
|
217
|
+
return new Uint8Array(bytes, contentType ?? "text/plain", bytes.length, body);
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Creates a JSON HTTP body using `JSON.stringify`, throwing if serialization fails.
|
|
221
|
+
*
|
|
222
|
+
* **Details**
|
|
223
|
+
*
|
|
224
|
+
* The content type defaults to `application/json`.
|
|
225
|
+
*
|
|
226
|
+
* @stability unstable
|
|
227
|
+
* @category constructors
|
|
228
|
+
* @since 4.0.0
|
|
229
|
+
*/
|
|
230
|
+
const jsonUnsafe = (body, contentType) => text(JSON.stringify(body), contentType ?? "application/json");
|
|
231
|
+
/**
|
|
232
|
+
* Creates a JSON HTTP body in an `Effect`.
|
|
233
|
+
*
|
|
234
|
+
* **Details**
|
|
235
|
+
*
|
|
236
|
+
* `JSON.stringify` failures are captured as `HttpBodyError` values, and the content type defaults to `application/json`.
|
|
237
|
+
*
|
|
238
|
+
* @stability unstable
|
|
239
|
+
* @category constructors
|
|
240
|
+
* @since 4.0.0
|
|
241
|
+
*/
|
|
242
|
+
const json = (body, contentType) => try_({
|
|
243
|
+
try: () => text(JSON.stringify(body), contentType ?? "application/json"),
|
|
244
|
+
catch: (cause) => new HttpBodyError({
|
|
245
|
+
reason: { _tag: "JsonError" },
|
|
246
|
+
cause
|
|
247
|
+
})
|
|
248
|
+
});
|
|
249
|
+
/**
|
|
250
|
+
* HTTP body variant backed by a stream of `Uint8Array` chunks.
|
|
251
|
+
*
|
|
252
|
+
* @stability unstable
|
|
253
|
+
* @category models
|
|
254
|
+
* @since 4.0.0
|
|
255
|
+
*/
|
|
256
|
+
var Stream = class extends Proto$1 {
|
|
257
|
+
_tag = "Stream";
|
|
258
|
+
stream;
|
|
259
|
+
contentType;
|
|
260
|
+
contentLength;
|
|
261
|
+
constructor(stream, contentType, contentLength) {
|
|
262
|
+
super();
|
|
263
|
+
this.stream = stream;
|
|
264
|
+
this.contentType = contentType;
|
|
265
|
+
this.contentLength = contentLength;
|
|
266
|
+
}
|
|
267
|
+
toJSON() {
|
|
268
|
+
return {
|
|
269
|
+
_id: "effect/HttpBody",
|
|
270
|
+
_tag: "Stream",
|
|
271
|
+
contentType: this.contentType,
|
|
272
|
+
contentLength: this.contentLength
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* Creates a streaming HTTP body from a stream of byte chunks.
|
|
278
|
+
*
|
|
279
|
+
* **Details**
|
|
280
|
+
*
|
|
281
|
+
* The content type defaults to `application/octet-stream`; content length is optional.
|
|
282
|
+
*
|
|
283
|
+
* @stability unstable
|
|
284
|
+
* @category constructors
|
|
285
|
+
* @since 4.0.0
|
|
286
|
+
*/
|
|
287
|
+
const stream = (body, contentType, contentLength) => new Stream(body, contentType ?? "application/octet-stream", contentLength);
|
|
288
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/http/internal/httpBody.js
|
|
289
|
+
/**
|
|
290
|
+
* @internal
|
|
291
|
+
*/
|
|
292
|
+
const updateHeaders = (headers, body) => {
|
|
293
|
+
if (body._tag === "Empty" || body._tag === "FormData") return remove(remove(headers, "content-type"), "content-length");
|
|
294
|
+
headers = body.contentType === void 0 ? remove(headers, "content-type") : set(headers, "content-type", body.contentType);
|
|
295
|
+
return updateContentLength(headers, body);
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* @internal
|
|
299
|
+
*/
|
|
300
|
+
const updateContentLength = (headers, body) => {
|
|
301
|
+
const contentLength = body._tag === "Empty" || body._tag === "FormData" ? void 0 : body.contentLength;
|
|
302
|
+
return contentLength === void 0 ? remove(headers, "content-length") : set(headers, "content-length", contentLength.toString());
|
|
303
|
+
};
|
|
304
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/http/Url.js
|
|
305
|
+
/**
|
|
306
|
+
* Error returned when constructing a `URL` fails.
|
|
307
|
+
*
|
|
308
|
+
* @stability unstable
|
|
309
|
+
* @category errors
|
|
310
|
+
* @since 4.0.0
|
|
311
|
+
*/
|
|
312
|
+
var UrlError = class extends (/*#__PURE__*/ TaggedError("UrlError")) {};
|
|
313
|
+
/**
|
|
314
|
+
* Creates a `URL` safely by appending `UrlParams` and an optional hash to a URL string.
|
|
315
|
+
*
|
|
316
|
+
* **Details**
|
|
317
|
+
*
|
|
318
|
+
* Returns a `Result` that fails with `UrlError` if the URL cannot be constructed.
|
|
319
|
+
*
|
|
320
|
+
* @stability unstable
|
|
321
|
+
* @category constructors
|
|
322
|
+
* @since 4.0.0
|
|
323
|
+
*/
|
|
324
|
+
const make$1 = (url, params, hash) => try_$1({
|
|
325
|
+
try: () => {
|
|
326
|
+
const urlInstance = new URL(url, baseUrl());
|
|
327
|
+
for (let i = 0; i < params.params.length; i++) {
|
|
328
|
+
const [key, value] = params.params[i];
|
|
329
|
+
if (value !== void 0) urlInstance.searchParams.append(key, unwrap(value));
|
|
330
|
+
}
|
|
331
|
+
if (hash !== void 0) urlInstance.hash = hash;
|
|
332
|
+
return urlInstance;
|
|
333
|
+
},
|
|
334
|
+
catch: (cause) => new UrlError({ cause })
|
|
335
|
+
});
|
|
336
|
+
const baseUrl = () => {
|
|
337
|
+
if ("location" in globalThis && globalThis.location !== void 0 && globalThis.location.origin !== void 0 && globalThis.location.pathname !== void 0) {
|
|
338
|
+
const base = location.origin + location.pathname;
|
|
339
|
+
try {
|
|
340
|
+
return new URL(base).href;
|
|
341
|
+
} catch {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/http/HttpClientRequest.js
|
|
347
|
+
const TypeId$2 = "~effect/http/HttpClientRequest";
|
|
348
|
+
/**
|
|
349
|
+
* Returns `true` when a value is an `HttpClientRequest`.
|
|
350
|
+
*
|
|
351
|
+
* @stability unstable
|
|
352
|
+
* @category guards
|
|
353
|
+
* @since 4.0.0
|
|
354
|
+
*/
|
|
355
|
+
const isHttpClientRequest = (u) => hasProperty(u, TypeId$2);
|
|
356
|
+
const Proto = {
|
|
357
|
+
[TypeId$2]: TypeId$2,
|
|
358
|
+
...BaseProto,
|
|
359
|
+
toJSON() {
|
|
360
|
+
return {
|
|
361
|
+
_id: "HttpClientRequest",
|
|
362
|
+
method: this.method,
|
|
363
|
+
url: redactUrl(this.url),
|
|
364
|
+
urlParams: this.urlParams,
|
|
365
|
+
hash: this.hash,
|
|
366
|
+
headers: redact(this.headers),
|
|
367
|
+
body: this.body.toJSON()
|
|
368
|
+
};
|
|
369
|
+
},
|
|
370
|
+
pipe() {
|
|
371
|
+
return pipeArguments(this, arguments);
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
* Constructs an `HttpClientRequest` from fully normalized request components.
|
|
376
|
+
*
|
|
377
|
+
* @stability unstable
|
|
378
|
+
* @category constructors
|
|
379
|
+
* @since 4.0.0
|
|
380
|
+
*/
|
|
381
|
+
function makeWith(method, url, urlParams, hash, headers, body) {
|
|
382
|
+
const self = Object.create(Proto);
|
|
383
|
+
self.method = method;
|
|
384
|
+
self.url = url;
|
|
385
|
+
self.urlParams = urlParams;
|
|
386
|
+
self.hash = hash;
|
|
387
|
+
self.headers = headers;
|
|
388
|
+
self.body = body;
|
|
389
|
+
return self;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* An empty `GET` request with no URL, query parameters, hash, headers, or body.
|
|
393
|
+
*
|
|
394
|
+
* @stability unstable
|
|
395
|
+
* @category constructors
|
|
396
|
+
* @since 4.0.0
|
|
397
|
+
*/
|
|
398
|
+
const empty = /*#__PURE__*/ makeWith("GET", "", empty$2, /*#__PURE__*/ none(), empty$3, empty$1);
|
|
399
|
+
/**
|
|
400
|
+
* Creates a request constructor for the specified HTTP method.
|
|
401
|
+
*
|
|
402
|
+
* @stability unstable
|
|
403
|
+
* @category constructors
|
|
404
|
+
* @since 4.0.0
|
|
405
|
+
*/
|
|
406
|
+
const make = (method) => (url, options) => modify(empty, {
|
|
407
|
+
method,
|
|
408
|
+
url,
|
|
409
|
+
...options ?? void 0
|
|
410
|
+
});
|
|
411
|
+
/**
|
|
412
|
+
* Creates a `GET` request for the specified URL.
|
|
413
|
+
*
|
|
414
|
+
* @stability unstable
|
|
415
|
+
* @category constructors
|
|
416
|
+
* @since 4.0.0
|
|
417
|
+
*/
|
|
418
|
+
const get = /*#__PURE__*/ make("GET");
|
|
419
|
+
/**
|
|
420
|
+
* Creates a `POST` request for the specified URL.
|
|
421
|
+
*
|
|
422
|
+
* @stability unstable
|
|
423
|
+
* @category constructors
|
|
424
|
+
* @since 4.0.0
|
|
425
|
+
*/
|
|
426
|
+
const post = /*#__PURE__*/ make("POST");
|
|
427
|
+
/**
|
|
428
|
+
* Creates a `PATCH` request for the specified URL.
|
|
429
|
+
*
|
|
430
|
+
* @stability unstable
|
|
431
|
+
* @category constructors
|
|
432
|
+
* @since 4.0.0
|
|
433
|
+
*/
|
|
434
|
+
const patch = /*#__PURE__*/ make("PATCH");
|
|
435
|
+
/**
|
|
436
|
+
* Creates a `PUT` request for the specified URL.
|
|
437
|
+
*
|
|
438
|
+
* @stability unstable
|
|
439
|
+
* @category constructors
|
|
440
|
+
* @since 4.0.0
|
|
441
|
+
*/
|
|
442
|
+
const put = /*#__PURE__*/ make("PUT");
|
|
443
|
+
const del = /*#__PURE__*/ make("DELETE");
|
|
444
|
+
/**
|
|
445
|
+
* Applies request options to an `HttpClientRequest`, returning a new request.
|
|
446
|
+
*
|
|
447
|
+
* @stability unstable
|
|
448
|
+
* @category combinators
|
|
449
|
+
* @since 4.0.0
|
|
450
|
+
*/
|
|
451
|
+
const modify = /*#__PURE__*/ dual(2, (self, options) => {
|
|
452
|
+
let result = self;
|
|
453
|
+
if (options.method) result = setMethod(result, options.method);
|
|
454
|
+
if (options.url) result = setUrl(result, options.url);
|
|
455
|
+
if (options.headers) result = setHeaders(result, options.headers);
|
|
456
|
+
if (options.urlParams) result = setUrlParams(result, options.urlParams);
|
|
457
|
+
if (options.hash) result = setHash(result, options.hash);
|
|
458
|
+
if (options.body) result = setBody(result, options.body);
|
|
459
|
+
if (options.accept) result = accept(result, options.accept);
|
|
460
|
+
if (options.acceptJson) result = acceptJson(result);
|
|
461
|
+
return result;
|
|
462
|
+
});
|
|
463
|
+
/**
|
|
464
|
+
* Sets the HTTP method on a request, returning a new request.
|
|
465
|
+
*
|
|
466
|
+
* @stability unstable
|
|
467
|
+
* @category combinators
|
|
468
|
+
* @since 4.0.0
|
|
469
|
+
*/
|
|
470
|
+
const setMethod = /*#__PURE__*/ dual(2, (self, method) => makeWith(method, self.url, self.urlParams, self.hash, self.headers, self.body));
|
|
471
|
+
/**
|
|
472
|
+
* Sets a single request header, replacing any existing value for that header.
|
|
473
|
+
*
|
|
474
|
+
* @stability unstable
|
|
475
|
+
* @category combinators
|
|
476
|
+
* @since 4.0.0
|
|
477
|
+
*/
|
|
478
|
+
const setHeader = /*#__PURE__*/ dual(3, (self, key, value) => makeWith(self.method, self.url, self.urlParams, self.hash, set(self.headers, key, value), self.body));
|
|
479
|
+
/**
|
|
480
|
+
* Sets multiple request headers from an input collection, replacing existing values with matching names.
|
|
481
|
+
*
|
|
482
|
+
* @stability unstable
|
|
483
|
+
* @category combinators
|
|
484
|
+
* @since 4.0.0
|
|
485
|
+
*/
|
|
486
|
+
const setHeaders = /*#__PURE__*/ dual(2, (self, input) => makeWith(self.method, self.url, self.urlParams, self.hash, setAll(self.headers, input), self.body));
|
|
487
|
+
/**
|
|
488
|
+
* Sets the `Authorization` header using a bearer token.
|
|
489
|
+
*
|
|
490
|
+
* @stability unstable
|
|
491
|
+
* @category combinators
|
|
492
|
+
* @since 4.0.0
|
|
493
|
+
*/
|
|
494
|
+
const bearerToken = /*#__PURE__*/ dual(2, (self, token) => setHeader(self, "Authorization", `Bearer ${stringOrRedacted(token)}`));
|
|
495
|
+
/**
|
|
496
|
+
* Sets the `Accept` header to the specified media type.
|
|
497
|
+
*
|
|
498
|
+
* @stability unstable
|
|
499
|
+
* @category combinators
|
|
500
|
+
* @since 4.0.0
|
|
501
|
+
*/
|
|
502
|
+
const accept = /*#__PURE__*/ dual(2, (self, mediaType) => setHeader(self, "Accept", mediaType));
|
|
503
|
+
/**
|
|
504
|
+
* Sets the `Accept` header to `application/json`.
|
|
505
|
+
*
|
|
506
|
+
* @stability unstable
|
|
507
|
+
* @category combinators
|
|
508
|
+
* @since 4.0.0
|
|
509
|
+
*/
|
|
510
|
+
const acceptJson = /*#__PURE__*/ accept("application/json");
|
|
511
|
+
/**
|
|
512
|
+
* Sets the request URL. When given a `URL`, its search parameters and hash are extracted into the request's structured fields.
|
|
513
|
+
*
|
|
514
|
+
* @stability unstable
|
|
515
|
+
* @category combinators
|
|
516
|
+
* @since 4.0.0
|
|
517
|
+
*/
|
|
518
|
+
const setUrl = /*#__PURE__*/ dual(2, (self, url) => {
|
|
519
|
+
if (typeof url === "string") return makeWith(self.method, url, self.urlParams, self.hash, self.headers, self.body);
|
|
520
|
+
const clone = new URL(url.toString());
|
|
521
|
+
const urlParams = fromInput(clone.searchParams);
|
|
522
|
+
const hash = fromNullishOr(clone.hash === "" ? void 0 : clone.hash.slice(1));
|
|
523
|
+
clone.search = "";
|
|
524
|
+
clone.hash = "";
|
|
525
|
+
return makeWith(self.method, clone.toString(), urlParams, hash, self.headers, self.body);
|
|
526
|
+
});
|
|
527
|
+
/**
|
|
528
|
+
* Prepends a URL segment to the request URL, inserting or trimming one slash as needed.
|
|
529
|
+
*
|
|
530
|
+
* @stability unstable
|
|
531
|
+
* @category combinators
|
|
532
|
+
* @since 4.0.0
|
|
533
|
+
*/
|
|
534
|
+
const prependUrl = /*#__PURE__*/ dual(2, (self, path) => {
|
|
535
|
+
if (path === "") return self;
|
|
536
|
+
return makeWith(self.method, joinSegments(path, self.url), self.urlParams, self.hash, self.headers, self.body);
|
|
537
|
+
});
|
|
538
|
+
const joinSegments = (first, second) => {
|
|
539
|
+
const endsWithSlash = first.endsWith("/");
|
|
540
|
+
const startsWithSlash = second.startsWith("/");
|
|
541
|
+
return endsWithSlash && startsWithSlash ? first + second.slice(1) : !endsWithSlash && !startsWithSlash ? first + "/" + second : first + second;
|
|
542
|
+
};
|
|
543
|
+
/**
|
|
544
|
+
* Sets one query parameter, replacing existing values for that parameter name.
|
|
545
|
+
*
|
|
546
|
+
* **Details**
|
|
547
|
+
*
|
|
548
|
+
* A `Redacted` value is sent unwrapped and stays redacted in inspection, errors and spans.
|
|
549
|
+
*
|
|
550
|
+
* @stability unstable
|
|
551
|
+
* @category combinators
|
|
552
|
+
* @since 4.0.0
|
|
553
|
+
*/
|
|
554
|
+
const setUrlParam = /*#__PURE__*/ dual(3, (self, key, value) => makeWith(self.method, self.url, set$1(self.urlParams, key, value), self.hash, self.headers, self.body));
|
|
555
|
+
/**
|
|
556
|
+
* Sets query parameters from an input collection, replacing existing values for matching names.
|
|
557
|
+
*
|
|
558
|
+
* @stability unstable
|
|
559
|
+
* @category combinators
|
|
560
|
+
* @since 4.0.0
|
|
561
|
+
*/
|
|
562
|
+
const setUrlParams = /*#__PURE__*/ dual(2, (self, input) => makeWith(self.method, self.url, setAll$1(self.urlParams, input), self.hash, self.headers, self.body));
|
|
563
|
+
/**
|
|
564
|
+
* Sets the URL fragment on a request without the leading `#`.
|
|
565
|
+
*
|
|
566
|
+
* @stability unstable
|
|
567
|
+
* @category combinators
|
|
568
|
+
* @since 4.0.0
|
|
569
|
+
*/
|
|
570
|
+
const setHash = /*#__PURE__*/ dual(2, (self, hash) => makeWith(self.method, self.url, self.urlParams, some(hash), self.headers, self.body));
|
|
571
|
+
/**
|
|
572
|
+
* Sets the request body and updates `Content-Type` and `Content-Length` headers from the body metadata when available.
|
|
573
|
+
*
|
|
574
|
+
* @stability unstable
|
|
575
|
+
* @category combinators
|
|
576
|
+
* @since 4.0.0
|
|
577
|
+
*/
|
|
578
|
+
const setBody = /*#__PURE__*/ dual(2, (self, body) => {
|
|
579
|
+
return makeWith(self.method, self.url, self.urlParams, self.hash, updateHeaders(self.headers, body), body);
|
|
580
|
+
});
|
|
581
|
+
/**
|
|
582
|
+
* Sets a `Uint8Array` request body with an optional content type.
|
|
583
|
+
*
|
|
584
|
+
* @stability unstable
|
|
585
|
+
* @category combinators
|
|
586
|
+
* @since 4.0.0
|
|
587
|
+
*/
|
|
588
|
+
const bodyUint8Array = /*#__PURE__*/ dual((args) => isHttpClientRequest(args[0]), (self, body, contentType) => setBody(self, uint8Array(body, contentType)));
|
|
589
|
+
/**
|
|
590
|
+
* Encodes a value as a JSON request body and sets it on the request, failing with `HttpBodyError` if encoding fails.
|
|
591
|
+
*
|
|
592
|
+
* @stability unstable
|
|
593
|
+
* @category combinators
|
|
594
|
+
* @since 4.0.0
|
|
595
|
+
*/
|
|
596
|
+
const bodyJson = /*#__PURE__*/ dual(2, (self, body) => map(json(body), (body) => setBody(self, body)));
|
|
597
|
+
/**
|
|
598
|
+
* Sets a JSON request body using unsafe JSON encoding.
|
|
599
|
+
*
|
|
600
|
+
* **When to use**
|
|
601
|
+
*
|
|
602
|
+
* Use when the request body is known to be JSON-serializable and a synchronous
|
|
603
|
+
* `HttpClientRequest` result is needed.
|
|
604
|
+
*
|
|
605
|
+
* **Gotchas**
|
|
606
|
+
*
|
|
607
|
+
* JSON encoding may throw instead of failing in the Effect error channel.
|
|
608
|
+
*
|
|
609
|
+
* @stability unstable
|
|
610
|
+
* @category combinators
|
|
611
|
+
* @since 4.0.0
|
|
612
|
+
*/
|
|
613
|
+
const bodyJsonUnsafe = /*#__PURE__*/ dual(2, (self, body) => setBody(self, jsonUnsafe(body)));
|
|
614
|
+
/**
|
|
615
|
+
* Builds a `URL` from the request URL, query parameters, and hash, returning `Option.none()` if the URL is invalid.
|
|
616
|
+
*
|
|
617
|
+
* @stability unstable
|
|
618
|
+
* @category combinators
|
|
619
|
+
* @since 4.0.0
|
|
620
|
+
*/
|
|
621
|
+
function toUrl(self) {
|
|
622
|
+
const r = make$1(self.url, self.urlParams, getOrUndefined(self.hash));
|
|
623
|
+
if (isSuccess(r)) return some(r.success);
|
|
624
|
+
return none();
|
|
625
|
+
}
|
|
626
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/http/HttpIncomingMessage.js
|
|
627
|
+
/**
|
|
628
|
+
* Type identifier for `HttpIncomingMessage` values.
|
|
629
|
+
*
|
|
630
|
+
* @stability unstable
|
|
631
|
+
* @category type IDs
|
|
632
|
+
* @since 4.0.0
|
|
633
|
+
*/
|
|
634
|
+
const TypeId$1 = "~effect/http/HttpIncomingMessage";
|
|
635
|
+
/**
|
|
636
|
+
* Creates a decoder that reads an incoming message's JSON body and decodes it with the supplied schema.
|
|
637
|
+
*
|
|
638
|
+
* @stability unstable
|
|
639
|
+
* @category schemas
|
|
640
|
+
* @since 4.0.0
|
|
641
|
+
*/
|
|
642
|
+
const schemaBodyJson = (schema, options) => {
|
|
643
|
+
const decode = decodeEffect(toCodecJson(schema));
|
|
644
|
+
const decodeJson = options?.reviver === void 0 ? void 0 : decodeEffect(fromJsonString(toCodecJson(schema), options));
|
|
645
|
+
return (self) => decodeJson === void 0 ? flatMap(self.json, (u) => decode(u, options)) : flatMap(self.text, (body) => body === "" ? flatMap(self.json, (u) => decode(u, options)) : decodeJson(body, options));
|
|
646
|
+
};
|
|
647
|
+
/**
|
|
648
|
+
* Context reference for the optional maximum size allowed when reading an incoming message body.
|
|
649
|
+
*
|
|
650
|
+
* @stability unstable
|
|
651
|
+
* @category references
|
|
652
|
+
* @since 4.0.0
|
|
653
|
+
*/
|
|
654
|
+
const MaxBodySize = /*#__PURE__*/ Reference("effect/http/HttpIncomingMessage/MaxBodySize", { defaultValue: () => void 0 });
|
|
655
|
+
/**
|
|
656
|
+
* Builds an inspectable object for an incoming message and redacts headers.
|
|
657
|
+
* The body is left unread.
|
|
658
|
+
*
|
|
659
|
+
* @stability unstable
|
|
660
|
+
* @category converting
|
|
661
|
+
* @since 4.0.0
|
|
662
|
+
*/
|
|
663
|
+
const inspect = (self, that) => {
|
|
664
|
+
return {
|
|
665
|
+
...that,
|
|
666
|
+
headers: redact(self.headers),
|
|
667
|
+
remoteAddress: self.remoteAddress
|
|
668
|
+
};
|
|
669
|
+
};
|
|
670
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/http/internal/webResponse.js
|
|
671
|
+
/**
|
|
672
|
+
* Returns the original Web `Response` of a fetch-backed client response.
|
|
673
|
+
* Wrappers forward it to the response they wrap.
|
|
674
|
+
*
|
|
675
|
+
* @internal
|
|
676
|
+
*/
|
|
677
|
+
const WebSourceSymbol = "~effect/http/HttpClientResponse/WebSource";
|
|
678
|
+
/**
|
|
679
|
+
* @internal
|
|
680
|
+
*/
|
|
681
|
+
const getWebSource = (self) => self[WebSourceSymbol]?.();
|
|
682
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/http/HttpClientResponse.js
|
|
683
|
+
/**
|
|
684
|
+
* Represents responses returned by the Effect HTTP client.
|
|
685
|
+
*
|
|
686
|
+
* An `HttpClientResponse` keeps the original request together with the response
|
|
687
|
+
* status, headers, cookies, and body accessors from the shared incoming-message
|
|
688
|
+
* model. This module includes constructors, schema-based decoders, helpers for
|
|
689
|
+
* streaming response bodies, and utilities for matching or filtering by HTTP
|
|
690
|
+
* status.
|
|
691
|
+
*
|
|
692
|
+
* @stability unstable
|
|
693
|
+
* @since 4.0.0
|
|
694
|
+
*/
|
|
695
|
+
/**
|
|
696
|
+
* Type identifier for `HttpClientResponse` values.
|
|
697
|
+
*
|
|
698
|
+
* @stability unstable
|
|
699
|
+
* @category type IDs
|
|
700
|
+
* @since 4.0.0
|
|
701
|
+
*/
|
|
702
|
+
const TypeId = "~effect/http/HttpClientResponse";
|
|
703
|
+
/**
|
|
704
|
+
* Wraps a Web `Response` and its original `HttpClientRequest` as an `HttpClientResponse`.
|
|
705
|
+
*
|
|
706
|
+
* @stability unstable
|
|
707
|
+
* @category constructors
|
|
708
|
+
* @since 4.0.0
|
|
709
|
+
*/
|
|
710
|
+
const fromWeb = (request, source) => new WebHttpClientResponse(request, source);
|
|
711
|
+
/**
|
|
712
|
+
* Pattern matches on a response status, checking exact status handlers before status-class handlers and `orElse`.
|
|
713
|
+
*
|
|
714
|
+
* @stability unstable
|
|
715
|
+
* @category pattern matching
|
|
716
|
+
* @since 4.0.0
|
|
717
|
+
*/
|
|
718
|
+
const matchStatus = /*#__PURE__*/ dual(2, (self, cases) => {
|
|
719
|
+
const status = self.status;
|
|
720
|
+
if (cases[status]) return cases[status](self);
|
|
721
|
+
else if (status >= 200 && status < 300 && cases["2xx"]) return cases["2xx"](self);
|
|
722
|
+
else if (status >= 300 && status < 400 && cases["3xx"]) return cases["3xx"](self);
|
|
723
|
+
else if (status >= 400 && status < 500 && cases["4xx"]) return cases["4xx"](self);
|
|
724
|
+
else if (status >= 500 && status < 600 && cases["5xx"]) return cases["5xx"](self);
|
|
725
|
+
return cases.orElse(self);
|
|
726
|
+
});
|
|
727
|
+
/**
|
|
728
|
+
* Succeeds with the response only when its status is in the 2xx range, otherwise fails with `HttpClientError`.
|
|
729
|
+
*
|
|
730
|
+
* @stability unstable
|
|
731
|
+
* @category filtering
|
|
732
|
+
* @since 4.0.0
|
|
733
|
+
*/
|
|
734
|
+
const filterStatusOk = (self) => self.status >= 200 && self.status < 300 ? succeed(self) : fail(new HttpClientError({ reason: new StatusCodeError({
|
|
735
|
+
response: self,
|
|
736
|
+
request: self.request,
|
|
737
|
+
description: "non 2xx status code"
|
|
738
|
+
}) }));
|
|
739
|
+
var WebHttpClientResponse = class extends Class {
|
|
740
|
+
[TypeId$1];
|
|
741
|
+
[TypeId];
|
|
742
|
+
request;
|
|
743
|
+
source;
|
|
744
|
+
constructor(request, source) {
|
|
745
|
+
super();
|
|
746
|
+
this.request = request;
|
|
747
|
+
this.source = source;
|
|
748
|
+
this[TypeId$1] = TypeId$1;
|
|
749
|
+
this[TypeId] = TypeId;
|
|
750
|
+
}
|
|
751
|
+
toJSON() {
|
|
752
|
+
return inspect(this, {
|
|
753
|
+
_id: "HttpClientResponse",
|
|
754
|
+
request: this.request.toJSON(),
|
|
755
|
+
status: this.status
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
get status() {
|
|
759
|
+
return this.source.status;
|
|
760
|
+
}
|
|
761
|
+
get url() {
|
|
762
|
+
if (this.source.url) return this.source.url.split("#")[0];
|
|
763
|
+
const url = toUrl(this.request);
|
|
764
|
+
if (isNone(url)) return "";
|
|
765
|
+
url.value.hash = "";
|
|
766
|
+
return url.value.href;
|
|
767
|
+
}
|
|
768
|
+
get headers() {
|
|
769
|
+
return fromInput$1(this.source.headers);
|
|
770
|
+
}
|
|
771
|
+
cachedCookies;
|
|
772
|
+
get cookies() {
|
|
773
|
+
if (this.cachedCookies) return this.cachedCookies;
|
|
774
|
+
return this.cachedCookies = fromSetCookie(this.source.headers.getSetCookie?.() ?? []);
|
|
775
|
+
}
|
|
776
|
+
get remoteAddress() {
|
|
777
|
+
return none();
|
|
778
|
+
}
|
|
779
|
+
[WebSourceSymbol]() {
|
|
780
|
+
return this.source;
|
|
781
|
+
}
|
|
782
|
+
get stream() {
|
|
783
|
+
return this.source.body ? fromReadableStream({
|
|
784
|
+
evaluate: () => this.source.body,
|
|
785
|
+
onError: (cause) => new HttpClientError({ reason: new DecodeError({
|
|
786
|
+
request: this.request,
|
|
787
|
+
response: this,
|
|
788
|
+
cause
|
|
789
|
+
}) })
|
|
790
|
+
}) : fail$1(new HttpClientError({ reason: new EmptyBodyError({
|
|
791
|
+
request: this.request,
|
|
792
|
+
response: this,
|
|
793
|
+
description: "can not create stream from empty body"
|
|
794
|
+
}) }));
|
|
795
|
+
}
|
|
796
|
+
get json() {
|
|
797
|
+
return flatMap(this.text, (text) => try_({
|
|
798
|
+
try: () => text === "" ? null : JSON.parse(text),
|
|
799
|
+
catch: (cause) => new HttpClientError({ reason: new DecodeError({
|
|
800
|
+
request: this.request,
|
|
801
|
+
response: this,
|
|
802
|
+
cause
|
|
803
|
+
}) })
|
|
804
|
+
}));
|
|
805
|
+
}
|
|
806
|
+
textBody;
|
|
807
|
+
get text() {
|
|
808
|
+
return this.textBody ??= map(this.arrayBuffer, (_) => new TextDecoder().decode(_));
|
|
809
|
+
}
|
|
810
|
+
get urlParamsBody() {
|
|
811
|
+
return flatMap(this.arrayBuffer, (bytes) => try_({
|
|
812
|
+
try: () => fromInput(fromBody(bytes)),
|
|
813
|
+
catch: (cause) => new HttpClientError({ reason: new DecodeError({
|
|
814
|
+
request: this.request,
|
|
815
|
+
response: this,
|
|
816
|
+
cause
|
|
817
|
+
}) })
|
|
818
|
+
}));
|
|
819
|
+
}
|
|
820
|
+
formDataBody;
|
|
821
|
+
get formData() {
|
|
822
|
+
return this.formDataBody ??= tryPromise({
|
|
823
|
+
try: () => this.source.formData(),
|
|
824
|
+
catch: (cause) => new HttpClientError({ reason: new DecodeError({
|
|
825
|
+
request: this.request,
|
|
826
|
+
response: this,
|
|
827
|
+
cause
|
|
828
|
+
}) })
|
|
829
|
+
}).pipe(cached, runSync);
|
|
830
|
+
}
|
|
831
|
+
arrayBufferBody;
|
|
832
|
+
get arrayBuffer() {
|
|
833
|
+
if (this.arrayBufferBody) return this.arrayBufferBody;
|
|
834
|
+
this.arrayBufferBody = tryPromise({
|
|
835
|
+
try: () => this.source.arrayBuffer(),
|
|
836
|
+
catch: (cause) => new HttpClientError({ reason: new DecodeError({
|
|
837
|
+
request: this.request,
|
|
838
|
+
response: this,
|
|
839
|
+
cause
|
|
840
|
+
}) })
|
|
841
|
+
}).pipe(cached, runSync);
|
|
842
|
+
return this.arrayBufferBody;
|
|
843
|
+
}
|
|
844
|
+
get upgrade() {
|
|
845
|
+
return fail(new HttpClientError({ reason: new StatusCodeError({
|
|
846
|
+
request: this.request,
|
|
847
|
+
response: this,
|
|
848
|
+
description: "fetch cannot hand over the connection of an HTTP upgrade"
|
|
849
|
+
}) }));
|
|
850
|
+
}
|
|
851
|
+
pipe() {
|
|
852
|
+
return pipeArguments(this, arguments);
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
export { stream as A, put as C, toUrl as D, setUrlParams as E, uint8Array as M, Clock as N, make$1 as O, currentTimeMillis as P, prependUrl as S, setUrlParam as T, empty as _, WebSourceSymbol as a, patch as b, TypeId$1 as c, acceptJson as d, bearerToken as f, del as g, bodyUint8Array as h, matchStatus as i, text as j, empty$1 as k, inspect as l, bodyJsonUnsafe as m, filterStatusOk as n, getWebSource as o, bodyJson as p, fromWeb as r, MaxBodySize as s, TypeId as t, schemaBodyJson as u, get as v, setHeaders as w, post as x, make as y };
|