apps 0.0.1-beta.125 → 0.0.1-beta.127
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/framework-reference.json +1 -1
- package/js/{chunk-7TDDMSZI.js → chunk-2XVGONUX.js} +6 -6
- package/js/{chunk-V3HWVVFZ.js → chunk-3CDTMIVU.js} +3 -3
- package/js/{chunk-7ASLJHSD.js → chunk-3II7MIAQ.js} +6 -6
- package/js/{chunk-3KNB4HRA.js → chunk-53GRY7ZE.js} +3 -3
- package/js/{chunk-7ZYZWLXS.js → chunk-5CMAHXQD.js} +60 -61
- package/js/{chunk-VXBCDIWD.js → chunk-5H5IO2NZ.js} +778 -213
- package/js/{chunk-2AI3RZXP.js → chunk-5WCWPY23.js} +10 -10
- package/js/{chunk-MJUHAHDG.js → chunk-67DM7ASO.js} +2 -2
- package/js/{chunk-QUFLMMTG.js → chunk-DJNOADLI.js} +182 -61
- package/js/{chunk-KJW5IPM4.js → chunk-FXJUHTFE.js} +1 -1
- package/js/{chunk-VEQDEM6J.js → chunk-J3CZECVS.js} +13 -13
- package/js/{chunk-SO33LZ7J.js → chunk-KKKUQPWD.js} +2 -2
- package/js/{chunk-CCJUTN55.js → chunk-LC6YCEVL.js} +1 -1
- package/js/chunk-N7HXZNBD.js +161 -0
- package/js/{chunk-5TYZML5C.js → chunk-NGL6EJL6.js} +1775 -626
- package/js/{chunk-2EEUUSL7.js → chunk-NMSQJSBM.js} +308 -331
- package/js/{chunk-TTMRK64V.js → chunk-O46YT2VS.js} +2 -2
- package/js/{chunk-5LGG5YSE.js → chunk-PZBT2QO5.js} +2 -2
- package/js/{chunk-U2GHFWX2.js → chunk-QYHUNAWH.js} +7415 -3500
- package/js/{chunk-EPZ3P7IX.js → chunk-SA7FJGUX.js} +2 -2
- package/js/{chunk-LOHZM4RK.js → chunk-UJWZMRV6.js} +5 -5
- package/js/{chunk-MVAS3VFK.js → chunk-V2TAC4IJ.js} +8 -8
- package/js/{chunk-NCOPALJZ.js → chunk-WE4FZOSH.js} +1 -1
- package/js/{chunk-GWAA3COO.js → chunk-ZU2ECYYF.js} +4 -4
- package/js/{chunk-55QLA7T7.js → chunk-ZU77L7HU.js} +6 -6
- package/js/client.js +75 -18
- package/js/contracts.js +7 -7
- package/js/effect.js +18 -18
- package/js/graphql.js +20 -20
- package/js/host.js +18 -18
- package/js/index.js +13 -13
- package/js/mcp/effect.js +19 -19
- package/js/mcp.js +21 -21
- package/js/openapi.js +16 -16
- package/js/react.js +2 -2
- package/js/skills/effect.js +6 -6
- package/js/skills.js +15 -15
- package/js/ui/auth/contracts.js +2 -2
- package/js/ui/auth.js +5 -5
- package/js/ui/contracts.js +5 -5
- package/js/ui/serving.js +10 -10
- package/package.json +2 -2
- package/runtime.json +1 -1
- package/types/telemetry/src/layer.d.ts +1 -1
- package/js/chunk-EAPSQBFN.js +0 -75
|
@@ -4,11 +4,16 @@ import {
|
|
|
4
4
|
HttpClientError,
|
|
5
5
|
StatusCodeError,
|
|
6
6
|
appendUrlParams,
|
|
7
|
+
blankType,
|
|
7
8
|
bodyFormData,
|
|
9
|
+
contentType,
|
|
10
|
+
fixedMember,
|
|
8
11
|
fromLiteral,
|
|
9
12
|
get,
|
|
13
|
+
getClosingParenthensePosition,
|
|
10
14
|
hasBody,
|
|
11
15
|
isHttpBody,
|
|
16
|
+
isSocket,
|
|
12
17
|
make as make2,
|
|
13
18
|
mapRequest,
|
|
14
19
|
prefixPath,
|
|
@@ -16,36 +21,49 @@ import {
|
|
|
16
21
|
setBody,
|
|
17
22
|
setHeaders,
|
|
18
23
|
setUrl,
|
|
24
|
+
stream,
|
|
19
25
|
text,
|
|
20
26
|
uint8Array,
|
|
27
|
+
upgrade,
|
|
21
28
|
urlParams
|
|
22
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-NGL6EJL6.js";
|
|
23
30
|
import {
|
|
24
31
|
Cause,
|
|
32
|
+
CurrentRedactedNames,
|
|
33
|
+
CurrentRedactedNames2,
|
|
25
34
|
Defect,
|
|
26
35
|
Forbidden,
|
|
27
36
|
InvalidValue,
|
|
28
37
|
Literal,
|
|
29
38
|
Never,
|
|
39
|
+
Never2,
|
|
40
|
+
NonEmptyArray,
|
|
41
|
+
Objects,
|
|
42
|
+
PropertySignature,
|
|
30
43
|
RecordFromUrlParams,
|
|
44
|
+
SchemaError,
|
|
31
45
|
Service,
|
|
32
46
|
String as String2,
|
|
33
47
|
Struct,
|
|
34
48
|
TaggedClass,
|
|
35
49
|
TaggedError,
|
|
50
|
+
Transformation,
|
|
36
51
|
Uint8Array as Uint8Array2,
|
|
37
52
|
Undefined,
|
|
38
53
|
UndefinedOr,
|
|
39
54
|
Union,
|
|
55
|
+
Union2,
|
|
40
56
|
Unknown,
|
|
41
57
|
UnknownFromJsonString,
|
|
42
58
|
Void,
|
|
43
59
|
add,
|
|
44
60
|
all,
|
|
61
|
+
applyToSelfOrLastLinkEncodingIdempotent,
|
|
45
62
|
as,
|
|
46
63
|
assignProperty,
|
|
47
64
|
brand,
|
|
48
65
|
catchCause,
|
|
66
|
+
catchIf,
|
|
49
67
|
combine2 as combine,
|
|
50
68
|
constVoid,
|
|
51
69
|
context,
|
|
@@ -53,19 +71,26 @@ import {
|
|
|
53
71
|
decode2 as decode,
|
|
54
72
|
decodeText,
|
|
55
73
|
decodeTo,
|
|
74
|
+
decodeTo2,
|
|
56
75
|
decodeUnknownEffect2 as decodeUnknownEffect,
|
|
76
|
+
die,
|
|
77
|
+
done,
|
|
57
78
|
empty,
|
|
58
|
-
|
|
79
|
+
empty6 as empty2,
|
|
59
80
|
encodeSync,
|
|
60
81
|
encodeUnknownEffect2 as encodeUnknownEffect,
|
|
61
82
|
ensure,
|
|
83
|
+
escape,
|
|
62
84
|
fail,
|
|
63
85
|
fail2,
|
|
64
86
|
fail4 as fail3,
|
|
65
87
|
failCause2 as failCause,
|
|
88
|
+
filter,
|
|
66
89
|
flatMap2 as flatMap,
|
|
67
90
|
fnUntraced,
|
|
68
91
|
fromInput3 as fromInput,
|
|
92
|
+
fromInputUnsafe,
|
|
93
|
+
fromInputUnsafe2,
|
|
69
94
|
fromJsonString,
|
|
70
95
|
fromTransform,
|
|
71
96
|
gen,
|
|
@@ -73,33 +98,50 @@ import {
|
|
|
73
98
|
getOrUndefined2 as getOrUndefined,
|
|
74
99
|
hasProperty,
|
|
75
100
|
identity,
|
|
101
|
+
ignore,
|
|
76
102
|
instanceOf,
|
|
77
103
|
isArrayNonEmpty,
|
|
78
104
|
isCause,
|
|
79
105
|
isLiteral,
|
|
106
|
+
isNotUndefined,
|
|
80
107
|
isNull,
|
|
81
108
|
isObject,
|
|
82
109
|
isObjects,
|
|
110
|
+
isOptional,
|
|
111
|
+
isReadonlyArrayNonEmpty,
|
|
83
112
|
isSchema,
|
|
84
113
|
isStream,
|
|
85
114
|
isSuspend,
|
|
86
115
|
isUnion,
|
|
87
116
|
isVoid,
|
|
88
|
-
|
|
117
|
+
make3 as make,
|
|
89
118
|
map2 as map,
|
|
90
119
|
map3 as map2,
|
|
91
120
|
map4 as map3,
|
|
92
|
-
|
|
121
|
+
map5 as map4,
|
|
122
|
+
map6 as map5,
|
|
123
|
+
map8 as map6,
|
|
124
|
+
mapArrayEffect,
|
|
125
|
+
mapEffect,
|
|
93
126
|
mapError,
|
|
127
|
+
mapError3 as mapError2,
|
|
128
|
+
mapOrSame,
|
|
129
|
+
matchEffect,
|
|
130
|
+
mebibytes,
|
|
94
131
|
memoize,
|
|
95
132
|
merge,
|
|
96
133
|
millis,
|
|
134
|
+
of,
|
|
135
|
+
onError,
|
|
97
136
|
optional,
|
|
137
|
+
passthrough2 as passthrough,
|
|
98
138
|
pipeArguments,
|
|
99
139
|
pipeThroughChannel,
|
|
100
140
|
pipeTo,
|
|
101
141
|
provideContext,
|
|
142
|
+
replaceContext,
|
|
102
143
|
resolveAt,
|
|
144
|
+
scoped,
|
|
103
145
|
succeed,
|
|
104
146
|
succeed4 as succeed2,
|
|
105
147
|
suspend,
|
|
@@ -108,18 +150,23 @@ import {
|
|
|
108
150
|
toCodecJson,
|
|
109
151
|
toCodecStringTree,
|
|
110
152
|
toEncoded,
|
|
153
|
+
toNumberUnsafe,
|
|
111
154
|
toString,
|
|
112
155
|
toType,
|
|
113
156
|
transform,
|
|
114
157
|
transformEffect,
|
|
158
|
+
transformOptional,
|
|
115
159
|
transformPull,
|
|
160
|
+
uninterruptibleMask,
|
|
161
|
+
unwrap2 as unwrap,
|
|
162
|
+
updateService,
|
|
116
163
|
void_2 as void_
|
|
117
|
-
} from "./chunk-
|
|
164
|
+
} from "./chunk-QYHUNAWH.js";
|
|
118
165
|
import {
|
|
119
166
|
__export
|
|
120
167
|
} from "./chunk-CZ7CSFO4.js";
|
|
121
168
|
|
|
122
|
-
// ../../node_modules/.bun/effect@4.
|
|
169
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/HttpApiSchema.js
|
|
123
170
|
var HttpApiSchema_exports = {};
|
|
124
171
|
__export(HttpApiSchema_exports, {
|
|
125
172
|
Accepted: () => Accepted,
|
|
@@ -128,8 +175,10 @@ __export(HttpApiSchema_exports, {
|
|
|
128
175
|
MultipartStreamTypeId: () => MultipartStreamTypeId,
|
|
129
176
|
MultipartTypeId: () => MultipartTypeId,
|
|
130
177
|
NoContent: () => NoContent,
|
|
178
|
+
StreamNdjson: () => StreamNdjson,
|
|
131
179
|
StreamSse: () => StreamSse,
|
|
132
180
|
StreamUint8Array: () => StreamUint8Array,
|
|
181
|
+
Upgrade: () => Upgrade,
|
|
133
182
|
WithHeaders: () => WithHeaders,
|
|
134
183
|
WithHeadersTypeId: () => WithHeadersTypeId,
|
|
135
184
|
WithHeadersValueTypeId: () => WithHeadersValueTypeId,
|
|
@@ -138,9 +187,11 @@ __export(HttpApiSchema_exports, {
|
|
|
138
187
|
asMultipart: () => asMultipart,
|
|
139
188
|
asMultipartStream: () => asMultipartStream,
|
|
140
189
|
asNoContent: () => asNoContent,
|
|
190
|
+
asProblem: () => asProblem,
|
|
141
191
|
asText: () => asText,
|
|
142
192
|
asUint8Array: () => asUint8Array,
|
|
143
193
|
encodeToWithHeaders: () => encodeToWithHeaders,
|
|
194
|
+
getEncodeToWithHeadersParts: () => getEncodeToWithHeadersParts,
|
|
144
195
|
getPayloadEncoding: () => getPayloadEncoding,
|
|
145
196
|
getResponseEncoding: () => getResponseEncoding,
|
|
146
197
|
getResponseEncodingSchema: () => getResponseEncodingSchema,
|
|
@@ -150,17 +201,20 @@ __export(HttpApiSchema_exports, {
|
|
|
150
201
|
getStatusSuccessSchema: () => getStatusSuccessSchema,
|
|
151
202
|
getWithHeadersAnnotation: () => getWithHeadersAnnotation,
|
|
152
203
|
isNoContent: () => isNoContent,
|
|
204
|
+
isStreamNdjson: () => isStreamNdjson,
|
|
153
205
|
isStreamSchema: () => isStreamSchema,
|
|
154
206
|
isStreamSse: () => isStreamSse,
|
|
155
207
|
isStreamUint8Array: () => isStreamUint8Array,
|
|
208
|
+
isUpgrade: () => isUpgrade,
|
|
156
209
|
isWithHeaders: () => isWithHeaders,
|
|
157
210
|
isWithHeadersValue: () => isWithHeadersValue,
|
|
211
|
+
rebuildUpgrade: () => rebuildUpgrade,
|
|
158
212
|
rebuildWithHeaders: () => rebuildWithHeaders,
|
|
159
213
|
status: () => status,
|
|
160
214
|
withHeaders: () => withHeaders
|
|
161
215
|
});
|
|
162
216
|
|
|
163
|
-
// ../../node_modules/.bun/effect@4.
|
|
217
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/encoding/Sse.js
|
|
164
218
|
var SseErrorTypeId = "~effect/encoding/Sse/SseError";
|
|
165
219
|
var EventTooLarge = class extends (/* @__PURE__ */ TaggedError("EventTooLarge")) {
|
|
166
220
|
get message() {
|
|
@@ -216,14 +270,15 @@ var decode2 = (options2) => fromTransform((upstream, _scope) => sync(() => {
|
|
|
216
270
|
return flatMap(pump, loop);
|
|
217
271
|
});
|
|
218
272
|
}));
|
|
219
|
-
var decodeSchema = (schema, options2, parseOptions) => pipeTo(decode2(options2), decode(Event.pipe(
|
|
273
|
+
var decodeSchema = (schema, options2, parseOptions) => pipeTo(decode2(options2), decode(Event.pipe(decodeTo2(schema, transformEvent)), parseOptions)());
|
|
220
274
|
function makeParser(onParse, options2) {
|
|
221
275
|
const maxEventSize = options2?.maxEventSize ?? defaultMaxEventSize;
|
|
276
|
+
const dispatchEmptyNamedEvents = options2?.dispatchEmptyNamedEvents === true;
|
|
222
277
|
let isFirstChunk;
|
|
223
|
-
let
|
|
224
|
-
let
|
|
225
|
-
let startingFieldLength;
|
|
278
|
+
let pending;
|
|
279
|
+
let pendingLength;
|
|
226
280
|
let discardTrailingNewline;
|
|
281
|
+
let generation = 0;
|
|
227
282
|
let lastEventId;
|
|
228
283
|
let eventName;
|
|
229
284
|
let data;
|
|
@@ -233,61 +288,58 @@ function makeParser(onParse, options2) {
|
|
|
233
288
|
reset
|
|
234
289
|
};
|
|
235
290
|
function reset() {
|
|
291
|
+
generation++;
|
|
236
292
|
isFirstChunk = true;
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
startingFieldLength = -1;
|
|
293
|
+
pending = [];
|
|
294
|
+
pendingLength = 0;
|
|
240
295
|
discardTrailingNewline = false;
|
|
241
296
|
lastEventId = void 0;
|
|
242
297
|
eventName = void 0;
|
|
243
298
|
data = "";
|
|
244
299
|
}
|
|
245
300
|
function feed(chunk) {
|
|
246
|
-
|
|
247
|
-
if (isFirstChunk &&
|
|
248
|
-
|
|
301
|
+
if (chunk.length === 0) return;
|
|
302
|
+
if (isFirstChunk && chunk.startsWith(BOM)) {
|
|
303
|
+
chunk = chunk.slice(BOM.length);
|
|
249
304
|
}
|
|
250
305
|
isFirstChunk = false;
|
|
251
|
-
const length =
|
|
306
|
+
const length = chunk.length;
|
|
307
|
+
const currentGeneration = generation;
|
|
252
308
|
let position = 0;
|
|
253
309
|
while (position < length) {
|
|
254
310
|
if (discardTrailingNewline) {
|
|
255
|
-
|
|
311
|
+
discardTrailingNewline = false;
|
|
312
|
+
if (chunk.charCodeAt(position) === LF) {
|
|
256
313
|
++position;
|
|
314
|
+
continue;
|
|
257
315
|
}
|
|
258
|
-
discardTrailingNewline = false;
|
|
259
316
|
}
|
|
260
|
-
let
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
if (character === ":" && fieldLength < 0) {
|
|
266
|
-
fieldLength = index - position;
|
|
267
|
-
} else if (character === "\r") {
|
|
268
|
-
discardTrailingNewline = true;
|
|
269
|
-
lineLength = index - position;
|
|
270
|
-
} else if (character === "\n") {
|
|
271
|
-
lineLength = index - position;
|
|
272
|
-
}
|
|
317
|
+
let lineEnd = position;
|
|
318
|
+
while (lineEnd < length) {
|
|
319
|
+
const code = chunk.charCodeAt(lineEnd);
|
|
320
|
+
if (code === CR || code === LF) break;
|
|
321
|
+
++lineEnd;
|
|
273
322
|
}
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
|
|
323
|
+
if (lineEnd === length) {
|
|
324
|
+
pending.push(chunk.slice(position));
|
|
325
|
+
pendingLength += length - position;
|
|
277
326
|
break;
|
|
278
|
-
} else {
|
|
279
|
-
startingPosition = 0;
|
|
280
|
-
startingFieldLength = -1;
|
|
281
327
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
328
|
+
discardTrailingNewline = chunk.charCodeAt(lineEnd) === CR;
|
|
329
|
+
let line = chunk.slice(position, lineEnd);
|
|
330
|
+
if (pending.length > 0) {
|
|
331
|
+
pending.push(line);
|
|
332
|
+
line = pending.join("");
|
|
333
|
+
pending = [];
|
|
334
|
+
pendingLength = 0;
|
|
335
|
+
}
|
|
336
|
+
parseLine2(line);
|
|
337
|
+
if (generation !== currentGeneration) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
position = lineEnd + 1;
|
|
289
341
|
}
|
|
290
|
-
if (
|
|
342
|
+
if (pendingLength + data.length > maxEventSize) {
|
|
291
343
|
const error = new SseError({
|
|
292
344
|
reason: new EventTooLarge({
|
|
293
345
|
maxEventSize
|
|
@@ -297,37 +349,33 @@ function makeParser(onParse, options2) {
|
|
|
297
349
|
return error;
|
|
298
350
|
}
|
|
299
351
|
}
|
|
300
|
-
function
|
|
301
|
-
if (
|
|
302
|
-
|
|
352
|
+
function parseLine2(line) {
|
|
353
|
+
if (line.length === 0) {
|
|
354
|
+
const named = eventName !== void 0 && eventName !== "";
|
|
355
|
+
const event = eventName || "message";
|
|
356
|
+
const eventData = data;
|
|
357
|
+
eventName = void 0;
|
|
358
|
+
data = "";
|
|
359
|
+
if (eventData.length > 0 || dispatchEmptyNamedEvents && named) {
|
|
303
360
|
onParse({
|
|
304
361
|
_tag: "Event",
|
|
305
362
|
id: lastEventId,
|
|
306
|
-
event
|
|
307
|
-
data:
|
|
363
|
+
event,
|
|
364
|
+
data: eventData.slice(0, -1)
|
|
308
365
|
// remove trailing newline
|
|
309
366
|
});
|
|
310
|
-
data = "";
|
|
311
367
|
}
|
|
312
|
-
eventName = void 0;
|
|
313
368
|
return;
|
|
314
369
|
}
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
let
|
|
318
|
-
if (
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
step = fieldLength + 2;
|
|
322
|
-
} else {
|
|
323
|
-
step = fieldLength + 1;
|
|
370
|
+
const colon = line.indexOf(":");
|
|
371
|
+
let field = line;
|
|
372
|
+
let value = "";
|
|
373
|
+
if (colon >= 0) {
|
|
374
|
+
field = line.slice(0, colon);
|
|
375
|
+
value = line.slice(line.charCodeAt(colon + 1) === SPACE ? colon + 2 : colon + 1);
|
|
324
376
|
}
|
|
325
|
-
const position = index + step;
|
|
326
|
-
const valueLength = lineLength - step;
|
|
327
|
-
const value = lineBuffer.slice(position, position + valueLength).toString();
|
|
328
377
|
if (field === "data") {
|
|
329
|
-
data += value
|
|
330
|
-
` : "\n";
|
|
378
|
+
data += value + "\n";
|
|
331
379
|
} else if (field === "event") {
|
|
332
380
|
eventName = value;
|
|
333
381
|
} else if (field === "id" && !value.includes("\0")) {
|
|
@@ -342,6 +390,9 @@ function makeParser(onParse, options2) {
|
|
|
342
390
|
}
|
|
343
391
|
}
|
|
344
392
|
var BOM = "\uFEFF";
|
|
393
|
+
var LF = 10;
|
|
394
|
+
var CR = 13;
|
|
395
|
+
var SPACE = 32;
|
|
345
396
|
var EventEncoded = /* @__PURE__ */ Struct({
|
|
346
397
|
id: /* @__PURE__ */ optional(String2),
|
|
347
398
|
event: String2,
|
|
@@ -398,11 +449,20 @@ var Retry = class _Retry extends (/* @__PURE__ */ TaggedClass("Retry")) {
|
|
|
398
449
|
}
|
|
399
450
|
};
|
|
400
451
|
|
|
401
|
-
// ../../node_modules/.bun/effect@4.
|
|
452
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/internal/mediaType.js
|
|
453
|
+
function normalize(contentType2) {
|
|
454
|
+
const normalized = contentType2.toLowerCase().trim();
|
|
455
|
+
const index = normalized.indexOf(";");
|
|
456
|
+
return index === -1 ? normalized : normalized.slice(0, index).trim();
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/HttpApiSchema.js
|
|
402
460
|
var StreamSchemaTypeId = "~effect/http-api/HttpApiSchema/Stream";
|
|
403
461
|
function status(code) {
|
|
404
462
|
const statusCode = typeof code === "string" ? fromLiteral(code) : code;
|
|
405
|
-
return (self) => self.
|
|
463
|
+
return (self) => findHttpApiStatusAnnotation(self.ast) === void 0 ? self.annotateKey({
|
|
464
|
+
httpApiStatus: statusCode
|
|
465
|
+
}) : self.annotate({
|
|
406
466
|
httpApiStatus: statusCode
|
|
407
467
|
});
|
|
408
468
|
}
|
|
@@ -412,17 +472,41 @@ var Created = /* @__PURE__ */ Empty(201);
|
|
|
412
472
|
var Accepted = /* @__PURE__ */ Empty(202);
|
|
413
473
|
function asNoContent(options2) {
|
|
414
474
|
return (self) => {
|
|
415
|
-
return Void.pipe(
|
|
475
|
+
return Void.pipe(decodeTo2(toType(self), transform({
|
|
416
476
|
decode: options2.decode,
|
|
417
477
|
encode: constVoid
|
|
418
478
|
})));
|
|
419
479
|
};
|
|
420
480
|
}
|
|
481
|
+
function asProblem(options2) {
|
|
482
|
+
return (self) => {
|
|
483
|
+
const status2 = getStatusError(self.ast);
|
|
484
|
+
const type = options2.type ?? blankType;
|
|
485
|
+
const body = {
|
|
486
|
+
type,
|
|
487
|
+
status: status2,
|
|
488
|
+
title: options2.title
|
|
489
|
+
};
|
|
490
|
+
const decode4 = options2.decode ?? (() => new self());
|
|
491
|
+
const problem = Struct({
|
|
492
|
+
type: tag(type),
|
|
493
|
+
status: fixedMember(status2),
|
|
494
|
+
title: fixedMember(options2.title)
|
|
495
|
+
});
|
|
496
|
+
return problem.pipe(decodeTo2(toType(self), transform({
|
|
497
|
+
decode: decode4,
|
|
498
|
+
encode: () => body
|
|
499
|
+
})), asJson({
|
|
500
|
+
contentType
|
|
501
|
+
}));
|
|
502
|
+
};
|
|
503
|
+
}
|
|
421
504
|
var streamSchema = /* @__PURE__ */ declare(isStream);
|
|
505
|
+
var defaultMaxElementBytes = /* @__PURE__ */ mebibytes(1);
|
|
422
506
|
var StreamSse = (options2) => {
|
|
423
507
|
const events = options2.events ?? (options2.data === void 0 ? void 0 : Struct({
|
|
424
508
|
...EventEncoded.fields,
|
|
425
|
-
data: fromJsonString(options2.data)
|
|
509
|
+
data: fromJsonString(toCodecJson(options2.data))
|
|
426
510
|
}));
|
|
427
511
|
if (events === void 0) {
|
|
428
512
|
throw new Error("StreamSse requires either an events schema or a data schema");
|
|
@@ -432,26 +516,77 @@ var StreamSse = (options2) => {
|
|
|
432
516
|
_tag: "StreamSse",
|
|
433
517
|
mode: "sse",
|
|
434
518
|
sseMode: options2.events === void 0 ? "data" : "events",
|
|
435
|
-
|
|
519
|
+
...streamContentTypes(options2.contentType, "sse"),
|
|
436
520
|
events,
|
|
437
|
-
error: options2.error ??
|
|
521
|
+
error: options2.error ?? Never2,
|
|
522
|
+
keepAlive: options2.keepAlive === void 0 ? void 0 : fromInputUnsafe(options2.keepAlive)
|
|
438
523
|
});
|
|
439
524
|
};
|
|
440
525
|
var StreamUint8Array = (options2) => make(streamSchema.ast, {
|
|
441
526
|
[StreamSchemaTypeId]: StreamSchemaTypeId,
|
|
442
527
|
_tag: "StreamUint8Array",
|
|
443
528
|
mode: "uint8array",
|
|
444
|
-
|
|
529
|
+
...streamContentTypes(options2?.contentType, "uint8array"),
|
|
530
|
+
maxBytes: options2?.maxBytes === void 0 ? void 0 : fromInputUnsafe2(options2.maxBytes)
|
|
531
|
+
});
|
|
532
|
+
var StreamNdjson = (options2) => make(streamSchema.ast, {
|
|
533
|
+
[StreamSchemaTypeId]: StreamSchemaTypeId,
|
|
534
|
+
_tag: "StreamNdjson",
|
|
535
|
+
mode: "ndjson",
|
|
536
|
+
...streamContentTypes(options2.contentType, "ndjson"),
|
|
537
|
+
schema: options2.schema,
|
|
538
|
+
maxBytes: options2.maxBytes === void 0 ? void 0 : fromInputUnsafe2(options2.maxBytes),
|
|
539
|
+
maxElementBytes: options2.maxElementBytes === void 0 ? defaultMaxElementBytes : fromInputUnsafe2(options2.maxElementBytes)
|
|
445
540
|
});
|
|
446
541
|
var isStreamSchema = (u) => isSchema(u) && hasProperty(u, StreamSchemaTypeId);
|
|
447
542
|
var isStreamSse = (u) => isStreamSchema(u) && u._tag === "StreamSse";
|
|
448
543
|
var isStreamUint8Array = (u) => isStreamSchema(u) && u._tag === "StreamUint8Array";
|
|
544
|
+
var isStreamNdjson = (u) => isStreamSchema(u) && u._tag === "StreamNdjson";
|
|
545
|
+
var UpgradeTypeId = "~effect/http-api/HttpApiSchema/Upgrade";
|
|
546
|
+
var upgradeSchema = /* @__PURE__ */ declare(isSocket).pipe(/* @__PURE__ */ status(101));
|
|
547
|
+
function Upgrade(options2) {
|
|
548
|
+
if (options2.protocol.toLowerCase() === "websocket") {
|
|
549
|
+
throw new Error("Upgrade does not support WebSocket");
|
|
550
|
+
}
|
|
551
|
+
const headers = options2.headers === void 0 || isSchema(options2.headers) ? options2.headers : Struct(options2.headers);
|
|
552
|
+
return rebuildUpgrade(options2.protocol, headers);
|
|
553
|
+
}
|
|
554
|
+
var rebuildUpgrade = (protocol, headers) => make(upgradeSchema.ast, {
|
|
555
|
+
[UpgradeTypeId]: UpgradeTypeId,
|
|
556
|
+
protocol,
|
|
557
|
+
headers
|
|
558
|
+
});
|
|
559
|
+
var isUpgrade = (u) => isSchema(u) && hasProperty(u, UpgradeTypeId);
|
|
560
|
+
function streamContentTypes(contentType2, mode) {
|
|
561
|
+
if (contentType2 === void 0) contentType2 = defaultStreamContentType(mode);
|
|
562
|
+
if (typeof contentType2 === "string") return {
|
|
563
|
+
contentType: contentType2,
|
|
564
|
+
contentTypes: [contentType2]
|
|
565
|
+
};
|
|
566
|
+
if (!isReadonlyArrayNonEmpty(contentType2)) {
|
|
567
|
+
throw new Error("Stream schemas require at least one content type");
|
|
568
|
+
}
|
|
569
|
+
const seen = /* @__PURE__ */ new Set();
|
|
570
|
+
for (const entry of contentType2) {
|
|
571
|
+
const normalized = normalize(entry);
|
|
572
|
+
if (seen.has(normalized)) {
|
|
573
|
+
throw new Error(`Duplicate stream content type: ${entry}`);
|
|
574
|
+
}
|
|
575
|
+
seen.add(normalized);
|
|
576
|
+
}
|
|
577
|
+
return {
|
|
578
|
+
contentType: contentType2[0],
|
|
579
|
+
contentTypes: contentType2
|
|
580
|
+
};
|
|
581
|
+
}
|
|
449
582
|
function defaultStreamContentType(mode) {
|
|
450
583
|
switch (mode) {
|
|
451
584
|
case "sse":
|
|
452
585
|
return "text/event-stream";
|
|
453
586
|
case "uint8array":
|
|
454
587
|
return "application/octet-stream";
|
|
588
|
+
case "ndjson":
|
|
589
|
+
return "application/x-ndjson";
|
|
455
590
|
}
|
|
456
591
|
}
|
|
457
592
|
var WithHeadersTypeId = "~effect/http-api/HttpApiSchema/WithHeaders";
|
|
@@ -462,6 +597,9 @@ function WithHeaders(schema, headers) {
|
|
|
462
597
|
if (isWithHeaders(schema)) {
|
|
463
598
|
throw new Error("WithHeaders schemas cannot be nested");
|
|
464
599
|
}
|
|
600
|
+
if (isUpgrade(schema)) {
|
|
601
|
+
throw new Error("WithHeaders cannot wrap an upgrade");
|
|
602
|
+
}
|
|
465
603
|
return make(withHeadersValueSchema.ast, {
|
|
466
604
|
[WithHeadersTypeId]: WithHeadersTypeId,
|
|
467
605
|
schema,
|
|
@@ -484,13 +622,16 @@ function rebuildWithHeaders(self, schema, headers) {
|
|
|
484
622
|
function encodeToWithHeaders(options2, transformation) {
|
|
485
623
|
return (self) => {
|
|
486
624
|
const body = options2.body;
|
|
625
|
+
if (isUpgrade(body)) {
|
|
626
|
+
throw new Error("encodeToWithHeaders cannot wrap an upgrade");
|
|
627
|
+
}
|
|
487
628
|
const headers = Struct(options2.headers);
|
|
488
629
|
const status2 = resolveHttpApiStatus(body.ast);
|
|
489
630
|
const encoding = resolveHttpApiEncoding(body.ast);
|
|
490
631
|
return Struct({
|
|
491
632
|
body,
|
|
492
633
|
headers
|
|
493
|
-
}).pipe(
|
|
634
|
+
}).pipe(decodeTo2(toType(self), transform(transformation))).annotate({
|
|
494
635
|
"~httpApiWithHeaders": {
|
|
495
636
|
body,
|
|
496
637
|
headers,
|
|
@@ -581,7 +722,32 @@ var isNoContent = (ast) => {
|
|
|
581
722
|
};
|
|
582
723
|
var resolveHttpApiEncoding = /* @__PURE__ */ resolveAt("~httpApiEncoding");
|
|
583
724
|
var getWithHeadersAnnotation = /* @__PURE__ */ resolveAt("~httpApiWithHeaders");
|
|
584
|
-
|
|
725
|
+
function getEncodeToWithHeadersParts(schema) {
|
|
726
|
+
const annotation = getWithHeadersAnnotation(schema.ast);
|
|
727
|
+
return annotation === void 0 ? void 0 : {
|
|
728
|
+
body: annotation.body,
|
|
729
|
+
headers: annotation.headers
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
function findHttpApiStatusAnnotation(ast) {
|
|
733
|
+
if (ast.checks) {
|
|
734
|
+
for (let i = ast.checks.length - 1; i >= 0; i--) {
|
|
735
|
+
const check = ast.checks[i];
|
|
736
|
+
if (check.annotations && "httpApiStatus" in check.annotations) return check.annotations;
|
|
737
|
+
if (check._tag === "FilterGroup") {
|
|
738
|
+
const annotations2 = findHttpApiStatusAnnotation(check);
|
|
739
|
+
if (annotations2 !== void 0) return annotations2;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
const annotations = ast.annotations;
|
|
744
|
+
return annotations && "httpApiStatus" in annotations ? annotations : void 0;
|
|
745
|
+
}
|
|
746
|
+
function resolveHttpApiStatus(ast) {
|
|
747
|
+
const annotations = findHttpApiStatusAnnotation(ast);
|
|
748
|
+
if (annotations !== void 0) return annotations.httpApiStatus;
|
|
749
|
+
return ast.context?.annotations?.httpApiStatus;
|
|
750
|
+
}
|
|
585
751
|
var defaultJsonEncoding = {
|
|
586
752
|
_tag: "Json",
|
|
587
753
|
contentType: "application/json"
|
|
@@ -630,7 +796,7 @@ function getStatusErrorSchema(schema) {
|
|
|
630
796
|
return getStatusError(schema.ast);
|
|
631
797
|
}
|
|
632
798
|
|
|
633
|
-
// ../../node_modules/.bun/effect@4.
|
|
799
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/HttpApiEndpoint.js
|
|
634
800
|
var HttpApiEndpoint_exports = {};
|
|
635
801
|
__export(HttpApiEndpoint_exports, {
|
|
636
802
|
delete: () => del,
|
|
@@ -648,14 +814,37 @@ __export(HttpApiEndpoint_exports, {
|
|
|
648
814
|
query: () => query
|
|
649
815
|
});
|
|
650
816
|
|
|
651
|
-
// ../../node_modules/.bun/effect@4.
|
|
652
|
-
function
|
|
653
|
-
const
|
|
654
|
-
|
|
655
|
-
return index === -1 ? normalized : normalized.slice(0, index).trim();
|
|
817
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/internal/toCodecHttpProperties.js
|
|
818
|
+
function toCodecHttpProperties(schema) {
|
|
819
|
+
const codec = toCodecStringTree(schema);
|
|
820
|
+
return codec.rebuild(normalizeProperties(codec.ast));
|
|
656
821
|
}
|
|
822
|
+
var omitUndefined = /* @__PURE__ */ new Transformation(/* @__PURE__ */ passthrough(), /* @__PURE__ */ transformOptional(/* @__PURE__ */ filter(isNotUndefined)));
|
|
823
|
+
var present = /* @__PURE__ */ memoize((ast) => {
|
|
824
|
+
if (ast._tag === "Undefined") return new Never(ast.annotations, void 0, void 0, ast.context);
|
|
825
|
+
if (ast._tag === "Suspend") return ast.recur(present);
|
|
826
|
+
if (ast._tag !== "Union") return ast;
|
|
827
|
+
const members = mapOrSame(ast.types, present);
|
|
828
|
+
if (members === ast.types) return ast;
|
|
829
|
+
const types = members.filter((member) => member._tag !== "Never");
|
|
830
|
+
if (types.length === 1 && ast.checks === void 0 && ast.annotations === void 0) {
|
|
831
|
+
return replaceContext(types[0], ast.context);
|
|
832
|
+
}
|
|
833
|
+
return new Union(types, ast.options, ast.annotations, ast.checks, void 0, ast.context);
|
|
834
|
+
});
|
|
835
|
+
var normalizeProperties = /* @__PURE__ */ applyToSelfOrLastLinkEncodingIdempotent((ast) => {
|
|
836
|
+
if (ast._tag === "Union" || ast._tag === "Suspend") return ast.recur(normalizeProperties);
|
|
837
|
+
if (ast._tag !== "Objects") return ast;
|
|
838
|
+
const properties = mapOrSame(ast.propertySignatures, (ps) => {
|
|
839
|
+
const encoded = toEncoded(ps.type);
|
|
840
|
+
if (!isOptional(encoded)) return ps;
|
|
841
|
+
const wire = present(encoded);
|
|
842
|
+
return wire === encoded ? ps : new PropertySignature(ps.name, decodeTo(wire, ps.type, omitUndefined));
|
|
843
|
+
});
|
|
844
|
+
return properties === ast.propertySignatures ? ast : new Objects(properties, ast.indexSignatures, ast.annotations, ast.checks, void 0, ast.context, ast.encodingChecks);
|
|
845
|
+
});
|
|
657
846
|
|
|
658
|
-
// ../../node_modules/.bun/effect@4.
|
|
847
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/HttpApiEndpoint.js
|
|
659
848
|
var TypeId = "~effect/http-api/HttpApiEndpoint";
|
|
660
849
|
var isHttpApiEndpoint = (u) => hasProperty(u, TypeId);
|
|
661
850
|
function getPayloadSchemas(endpoint2) {
|
|
@@ -734,16 +923,17 @@ function makeProto(options2) {
|
|
|
734
923
|
}
|
|
735
924
|
var make3 = (method) => (identifier, path, options2) => {
|
|
736
925
|
const disableCodecs = options2?.disableCodecs ?? false;
|
|
737
|
-
const
|
|
926
|
+
const transformProperties = disableCodecs ? identity : toCodecHttpProperties;
|
|
927
|
+
const payload = getPayload(options2?.payload, method, disableCodecs);
|
|
738
928
|
return makeProto({
|
|
739
929
|
identifier,
|
|
740
930
|
path,
|
|
741
931
|
method,
|
|
742
|
-
params: ensureStruct(options2?.params,
|
|
743
|
-
query: ensureStruct(options2?.query,
|
|
744
|
-
headers: ensureStruct(options2?.headers,
|
|
745
|
-
payload
|
|
746
|
-
success: getSuccessResponse(options2?.success, method, disableCodecs),
|
|
932
|
+
params: ensureStruct(options2?.params, transformProperties),
|
|
933
|
+
query: ensureStruct(options2?.query, transformProperties),
|
|
934
|
+
headers: ensureStruct(options2?.headers, transformProperties),
|
|
935
|
+
payload,
|
|
936
|
+
success: getSuccessResponse(options2?.success, method, payload, disableCodecs),
|
|
747
937
|
error: getErrorResponse(options2?.error, disableCodecs),
|
|
748
938
|
annotations: empty(),
|
|
749
939
|
middlewares: /* @__PURE__ */ new Set(),
|
|
@@ -760,11 +950,41 @@ function getPayload(payload, method, disableCodecs) {
|
|
|
760
950
|
if (payload === void 0) return result;
|
|
761
951
|
const schemas = Array.isArray(payload) ? payload : isSchema(payload) ? [payload] : [Struct(payload).pipe(asFormUrlEncoded())];
|
|
762
952
|
const transform2 = disableCodecs ? identity : transformPayload;
|
|
953
|
+
let hasStream = false;
|
|
763
954
|
for (const schema of schemas) {
|
|
955
|
+
if (isStreamSchema(schema)) {
|
|
956
|
+
if (isStreamSse(schema)) {
|
|
957
|
+
throw new Error("StreamSse is response-only and cannot be used as a payload");
|
|
958
|
+
}
|
|
959
|
+
if (!hasBody(method)) {
|
|
960
|
+
throw new Error(`${method} endpoints cannot declare a streaming payload`);
|
|
961
|
+
}
|
|
962
|
+
if (hasStream) {
|
|
963
|
+
throw new Error("Multiple streaming payloads are not supported");
|
|
964
|
+
}
|
|
965
|
+
hasStream = true;
|
|
966
|
+
for (const declared of schema.contentTypes) {
|
|
967
|
+
const contentType3 = normalize(declared);
|
|
968
|
+
if (result.has(contentType3)) {
|
|
969
|
+
throw new Error(`Cannot combine buffered and streaming payloads for content-type: ${declared}`);
|
|
970
|
+
}
|
|
971
|
+
result.set(contentType3, {
|
|
972
|
+
encoding: {
|
|
973
|
+
_tag: "Stream",
|
|
974
|
+
contentType: declared
|
|
975
|
+
},
|
|
976
|
+
schemas: [schema]
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
continue;
|
|
980
|
+
}
|
|
764
981
|
const encoding = getPayloadEncoding(schema.ast, method);
|
|
765
|
-
const
|
|
766
|
-
const existing = result.get(
|
|
982
|
+
const contentType2 = normalize(encoding.contentType);
|
|
983
|
+
const existing = result.get(contentType2);
|
|
767
984
|
if (existing) {
|
|
985
|
+
if (existing.encoding._tag === "Stream") {
|
|
986
|
+
throw new Error(`Cannot combine buffered and streaming payloads for content-type: ${encoding.contentType}`);
|
|
987
|
+
}
|
|
768
988
|
if (existing.encoding._tag !== encoding._tag) {
|
|
769
989
|
throw new Error(`Multiple payload encodings for content-type: ${encoding.contentType}`);
|
|
770
990
|
}
|
|
@@ -773,7 +993,7 @@ function getPayload(payload, method, disableCodecs) {
|
|
|
773
993
|
}
|
|
774
994
|
existing.schemas.push(transform2(schema, method));
|
|
775
995
|
} else {
|
|
776
|
-
result.set(
|
|
996
|
+
result.set(contentType2, {
|
|
777
997
|
encoding,
|
|
778
998
|
schemas: [transform2(schema, method)]
|
|
779
999
|
});
|
|
@@ -782,17 +1002,20 @@ function getPayload(payload, method, disableCodecs) {
|
|
|
782
1002
|
return result;
|
|
783
1003
|
}
|
|
784
1004
|
var reservedStreamFailureEvent = "effect/http-api/stream/failure";
|
|
785
|
-
function getSuccessResponse(success, method, disableCodecs) {
|
|
1005
|
+
function getSuccessResponse(success, method, payload, disableCodecs) {
|
|
786
1006
|
if (success === void 0) return /* @__PURE__ */ new Set();
|
|
787
1007
|
const schemas = ensure(success);
|
|
788
|
-
validateSuccessResponse(schemas, method);
|
|
1008
|
+
validateSuccessResponse(schemas, method, payload);
|
|
789
1009
|
return new Set(disableCodecs ? schemas : schemas.map(transformResponseSchema));
|
|
790
1010
|
}
|
|
791
1011
|
var transformResponseSchema = /* @__PURE__ */ memoize((schema) => {
|
|
792
1012
|
if (isStreamSchema(schema)) return schema;
|
|
1013
|
+
if (isUpgrade(schema)) {
|
|
1014
|
+
return schema.headers === void 0 ? schema : rebuildUpgrade(schema.protocol, toCodecHttpProperties(schema.headers));
|
|
1015
|
+
}
|
|
793
1016
|
if (isWithHeaders(schema)) {
|
|
794
1017
|
const inner = isStreamSchema(schema.schema) ? schema.schema : applyResponseEncoding(schema.schema, getResponseEncodingSchema(schema));
|
|
795
|
-
return rebuildWithHeaders(schema, inner,
|
|
1018
|
+
return rebuildWithHeaders(schema, inner, toCodecHttpProperties(schema.headers));
|
|
796
1019
|
}
|
|
797
1020
|
return transformResponse(schema);
|
|
798
1021
|
});
|
|
@@ -804,17 +1027,44 @@ function getErrorResponse(error, disableCodecs) {
|
|
|
804
1027
|
if (isStreamSchema(body)) {
|
|
805
1028
|
throw new Error("Streaming schemas are not supported in error responses");
|
|
806
1029
|
}
|
|
1030
|
+
if (isUpgrade(body)) {
|
|
1031
|
+
throw new Error("Upgrade schemas are not supported in error responses");
|
|
1032
|
+
}
|
|
807
1033
|
}
|
|
808
1034
|
validateResponseExclusivity(schemas, getStatusErrorSchema);
|
|
809
1035
|
return new Set(disableCodecs ? schemas : schemas.map(transformResponseSchema));
|
|
810
1036
|
}
|
|
811
|
-
function validateSuccessResponse(schemas, method) {
|
|
1037
|
+
function validateSuccessResponse(schemas, method, payload) {
|
|
1038
|
+
const upgrades = schemas.filter(isUpgrade);
|
|
1039
|
+
if (upgrades.length > 1) {
|
|
1040
|
+
throw new Error("Cannot declare more than one upgrade");
|
|
1041
|
+
}
|
|
1042
|
+
const hasUpgrade = upgrades.length === 1;
|
|
1043
|
+
if (hasUpgrade) {
|
|
1044
|
+
if (method === "HEAD") {
|
|
1045
|
+
throw new Error("HEAD endpoints cannot declare an upgrade");
|
|
1046
|
+
}
|
|
1047
|
+
for (const {
|
|
1048
|
+
encoding
|
|
1049
|
+
} of payload.values()) {
|
|
1050
|
+
if (encoding._tag === "Stream" || encoding._tag === "Multipart" && encoding.mode === "stream") {
|
|
1051
|
+
throw new Error("Upgrade endpoints cannot declare a streaming payload");
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
812
1055
|
let hasStream = false;
|
|
813
1056
|
const statuses = /* @__PURE__ */ new Map();
|
|
814
1057
|
for (const schema of schemas) {
|
|
1058
|
+
if (isUpgrade(schema)) continue;
|
|
815
1059
|
const inner = isWithHeaders(schema) ? schema.schema : schema;
|
|
816
1060
|
const status2 = getStatusSuccessSchema(schema);
|
|
1061
|
+
if (hasUpgrade && status2 === 101) {
|
|
1062
|
+
throw new Error("Cannot combine an upgrade with another success response for status: 101");
|
|
1063
|
+
}
|
|
817
1064
|
if (isStreamSchema(inner)) {
|
|
1065
|
+
if (hasUpgrade) {
|
|
1066
|
+
throw new Error("Cannot combine an upgrade with a streaming success response");
|
|
1067
|
+
}
|
|
818
1068
|
validateStreamSuccess(inner, method);
|
|
819
1069
|
if (hasStream) {
|
|
820
1070
|
throw new Error("Multiple streaming success responses are not supported");
|
|
@@ -824,8 +1074,10 @@ function validateSuccessResponse(schemas, method) {
|
|
|
824
1074
|
if (entry.noContent) {
|
|
825
1075
|
throw new Error(`Cannot combine no-content and streaming success responses for status: ${status2}`);
|
|
826
1076
|
}
|
|
827
|
-
|
|
828
|
-
|
|
1077
|
+
for (const declared of inner.contentTypes) {
|
|
1078
|
+
if (entry.bufferedContentTypes.has(normalize(declared))) {
|
|
1079
|
+
throw new Error(`Cannot combine buffered and streaming success responses for status ${status2} and content-type: ${declared}`);
|
|
1080
|
+
}
|
|
829
1081
|
}
|
|
830
1082
|
statuses.set(status2, {
|
|
831
1083
|
...entry,
|
|
@@ -839,7 +1091,8 @@ function validateSuccessResponse(schemas, method) {
|
|
|
839
1091
|
throw new Error(`Cannot combine no-content and streaming success responses for status: ${status2}`);
|
|
840
1092
|
}
|
|
841
1093
|
const encoding = getResponseEncodingSchema(schema);
|
|
842
|
-
|
|
1094
|
+
const contentType2 = normalize(encoding.contentType);
|
|
1095
|
+
if (entry.stream.contentTypes.some((declared) => normalize(declared) === contentType2)) {
|
|
843
1096
|
throw new Error(`Cannot combine buffered and streaming success responses for status ${status2} and content-type: ${encoding.contentType}`);
|
|
844
1097
|
}
|
|
845
1098
|
}
|
|
@@ -868,7 +1121,7 @@ function validateResponseExclusivity(schemas, getStatus) {
|
|
|
868
1121
|
const status2 = getStatus(schema);
|
|
869
1122
|
const withHeadersAnnotation = getWithHeadersAnnotation(schema.ast);
|
|
870
1123
|
const body = isWithHeaders(schema) ? schema.schema : withHeadersAnnotation?.body ?? schema;
|
|
871
|
-
const
|
|
1124
|
+
const contentType2 = isNoContent(body.ast) ? "" : normalize(isStreamSchema(body) ? body.contentType : getResponseEncodingSchema(schema).contentType);
|
|
872
1125
|
let entry = statuses.get(status2);
|
|
873
1126
|
if (entry === void 0) {
|
|
874
1127
|
entry = {
|
|
@@ -877,16 +1130,16 @@ function validateResponseExclusivity(schemas, getStatus) {
|
|
|
877
1130
|
};
|
|
878
1131
|
statuses.set(status2, entry);
|
|
879
1132
|
}
|
|
880
|
-
const combineError = () => new Error(`Cannot combine a response with headers with another response for status ${status2} and content-type: ${
|
|
1133
|
+
const combineError = () => new Error(`Cannot combine a response with headers with another response for status ${status2} and content-type: ${contentType2 || "<no content>"}`);
|
|
881
1134
|
if (isWithHeaders(schema) || withHeadersAnnotation !== void 0) {
|
|
882
1135
|
if (entry.headerContentType !== void 0) {
|
|
883
1136
|
throw new Error(`Cannot declare multiple responses with headers for status ${status2}`);
|
|
884
1137
|
}
|
|
885
|
-
if (entry.plainContentTypes.has(
|
|
886
|
-
entry.headerContentType =
|
|
1138
|
+
if (entry.plainContentTypes.has(contentType2)) throw combineError();
|
|
1139
|
+
entry.headerContentType = contentType2;
|
|
887
1140
|
} else {
|
|
888
|
-
if (entry.headerContentType ===
|
|
889
|
-
entry.plainContentTypes.add(
|
|
1141
|
+
if (entry.headerContentType === contentType2) throw combineError();
|
|
1142
|
+
entry.plainContentTypes.add(contentType2);
|
|
890
1143
|
}
|
|
891
1144
|
}
|
|
892
1145
|
}
|
|
@@ -942,7 +1195,7 @@ function transformResponse(schema) {
|
|
|
942
1195
|
"~httpApiWithHeaders": {
|
|
943
1196
|
...withHeaders2,
|
|
944
1197
|
bodyCodec: applyResponseEncoding(withHeaders2.body, encoding),
|
|
945
|
-
headersCodec:
|
|
1198
|
+
headersCodec: toCodecHttpProperties(withHeaders2.headers)
|
|
946
1199
|
}
|
|
947
1200
|
});
|
|
948
1201
|
}
|
|
@@ -958,6 +1211,7 @@ function applyResponseEncoding(schema, encoding) {
|
|
|
958
1211
|
}
|
|
959
1212
|
}
|
|
960
1213
|
function transformPayload(schema, method) {
|
|
1214
|
+
if (!hasBody(method)) return toCodecHttpProperties(schema);
|
|
961
1215
|
const encoding = getPayloadEncoding(schema.ast, method);
|
|
962
1216
|
switch (encoding._tag) {
|
|
963
1217
|
case "Json":
|
|
@@ -979,7 +1233,7 @@ var del = /* @__PURE__ */ make3("DELETE");
|
|
|
979
1233
|
var head = /* @__PURE__ */ make3("HEAD");
|
|
980
1234
|
var options = /* @__PURE__ */ make3("OPTIONS");
|
|
981
1235
|
|
|
982
|
-
// ../../node_modules/.bun/effect@4.
|
|
1236
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/HttpApi.js
|
|
983
1237
|
var HttpApi_exports = {};
|
|
984
1238
|
__export(HttpApi_exports, {
|
|
985
1239
|
AdditionalSchemas: () => AdditionalSchemas,
|
|
@@ -989,7 +1243,9 @@ __export(HttpApi_exports, {
|
|
|
989
1243
|
ParseOptions: () => ParseOptions,
|
|
990
1244
|
PayloadParseOptions: () => PayloadParseOptions,
|
|
991
1245
|
QueryParseOptions: () => QueryParseOptions,
|
|
1246
|
+
RedactedNames: () => RedactedNames,
|
|
992
1247
|
SuccessParseOptions: () => SuccessParseOptions,
|
|
1248
|
+
getEndpointRedactedNames: () => getEndpointRedactedNames,
|
|
993
1249
|
getSlotParseOptions: () => getSlotParseOptions,
|
|
994
1250
|
isHttpApi: () => isHttpApi,
|
|
995
1251
|
make: () => make4,
|
|
@@ -1099,7 +1355,7 @@ var extractResponseContent = (schemas, getStatus) => {
|
|
|
1099
1355
|
return map7;
|
|
1100
1356
|
function add2(schema) {
|
|
1101
1357
|
const body = isWithHeaders(schema) ? schema.schema : schema;
|
|
1102
|
-
if (isStreamSchema(body)) return;
|
|
1358
|
+
if (isStreamSchema(body) || isUpgrade(body)) return;
|
|
1103
1359
|
const status2 = getStatus(schema);
|
|
1104
1360
|
const schemas2 = map7.get(status2);
|
|
1105
1361
|
if (schemas2 === void 0) {
|
|
@@ -1125,6 +1381,8 @@ var SuccessParseOptions = class extends (/* @__PURE__ */ Service()("effect/http-
|
|
|
1125
1381
|
};
|
|
1126
1382
|
var ErrorParseOptions = class extends (/* @__PURE__ */ Service()("effect/http-api/HttpApi/ErrorParseOptions")) {
|
|
1127
1383
|
};
|
|
1384
|
+
var RedactedNames = class extends (/* @__PURE__ */ Service()("effect/http-api/HttpApi/RedactedNames")) {
|
|
1385
|
+
};
|
|
1128
1386
|
var getSlotParseOptions = (annotations) => {
|
|
1129
1387
|
const fallback = getOrUndefined(annotations, ParseOptions);
|
|
1130
1388
|
return {
|
|
@@ -1136,8 +1394,25 @@ var getSlotParseOptions = (annotations) => {
|
|
|
1136
1394
|
error: getOrUndefined(annotations, ErrorParseOptions) ?? fallback
|
|
1137
1395
|
};
|
|
1138
1396
|
};
|
|
1397
|
+
var getEndpointRedactedNames = (api, group2, endpoint2) => {
|
|
1398
|
+
const query2 = [];
|
|
1399
|
+
const headers = [];
|
|
1400
|
+
for (const annotations of [api.annotations, group2.annotations, endpoint2.annotations]) {
|
|
1401
|
+
const options2 = getOrUndefined(annotations, RedactedNames);
|
|
1402
|
+
if (options2 === void 0) continue;
|
|
1403
|
+
for (const name of options2.query ?? []) {
|
|
1404
|
+
query2.push(name);
|
|
1405
|
+
if (typeof name === "string") query2.push(new RegExp(`^${escape(name)}\\[`, "i"));
|
|
1406
|
+
}
|
|
1407
|
+
if (options2.headers !== void 0) headers.push(...options2.headers);
|
|
1408
|
+
}
|
|
1409
|
+
return query2.length === 0 && headers.length === 0 ? void 0 : {
|
|
1410
|
+
query: query2,
|
|
1411
|
+
headers
|
|
1412
|
+
};
|
|
1413
|
+
};
|
|
1139
1414
|
|
|
1140
|
-
// ../../node_modules/.bun/effect@4.
|
|
1415
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/HttpApiGroup.js
|
|
1141
1416
|
var HttpApiGroup_exports = {};
|
|
1142
1417
|
__export(HttpApiGroup_exports, {
|
|
1143
1418
|
isHttpApiGroup: () => isHttpApiGroup,
|
|
@@ -1219,24 +1494,211 @@ var make5 = (identifier, options2) => makeProto3({
|
|
|
1219
1494
|
annotations: empty()
|
|
1220
1495
|
});
|
|
1221
1496
|
|
|
1222
|
-
// ../../node_modules/.bun/effect@4.
|
|
1497
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/encoding/Ndjson.js
|
|
1498
|
+
var NdjsonErrorTypeId = "~effect/encoding/Ndjson/NdjsonError";
|
|
1499
|
+
var encoder = /* @__PURE__ */ new TextEncoder();
|
|
1500
|
+
var utf8Decoder = /* @__PURE__ */ new TextDecoder("utf-8", {
|
|
1501
|
+
fatal: true,
|
|
1502
|
+
ignoreBOM: true
|
|
1503
|
+
});
|
|
1504
|
+
var NdjsonError = class extends (/* @__PURE__ */ TaggedError("NdjsonError")) {
|
|
1505
|
+
/**
|
|
1506
|
+
* Marks this value as an NDJSON encoding or decoding error for runtime guards.
|
|
1507
|
+
*
|
|
1508
|
+
* @stability unstable
|
|
1509
|
+
* @since 4.0.0
|
|
1510
|
+
*/
|
|
1511
|
+
[NdjsonErrorTypeId] = NdjsonErrorTypeId;
|
|
1512
|
+
/**
|
|
1513
|
+
* Uses the failed NDJSON operation as the public message.
|
|
1514
|
+
*
|
|
1515
|
+
* @stability unstable
|
|
1516
|
+
* @since 4.0.0
|
|
1517
|
+
*/
|
|
1518
|
+
get message() {
|
|
1519
|
+
return this.kind;
|
|
1520
|
+
}
|
|
1521
|
+
};
|
|
1522
|
+
var isNdjsonError = (u) => hasProperty(u, NdjsonErrorTypeId);
|
|
1523
|
+
var encodeString = () => fromTransform((upstream, _scope) => succeed2(flatMap(upstream, (input) => {
|
|
1524
|
+
try {
|
|
1525
|
+
return succeed2(of(input.map((item) => {
|
|
1526
|
+
const output = JSON.stringify(item);
|
|
1527
|
+
if (output === void 0) {
|
|
1528
|
+
throw new TypeError("Value cannot be represented as JSON");
|
|
1529
|
+
}
|
|
1530
|
+
return output;
|
|
1531
|
+
}).join("\n") + "\n"));
|
|
1532
|
+
} catch (cause) {
|
|
1533
|
+
return fail3(new NdjsonError({
|
|
1534
|
+
kind: "Pack",
|
|
1535
|
+
cause
|
|
1536
|
+
}));
|
|
1537
|
+
}
|
|
1538
|
+
})));
|
|
1539
|
+
var encode2 = () => map4(encodeString(), map2((_) => encoder.encode(_)));
|
|
1540
|
+
var makeDecodePull = (upstream, step, flush) => {
|
|
1541
|
+
let failure;
|
|
1542
|
+
let done2;
|
|
1543
|
+
const emit = (out, error) => {
|
|
1544
|
+
failure = error;
|
|
1545
|
+
if (isArrayNonEmpty(out)) return succeed2(out);
|
|
1546
|
+
return error !== void 0 ? fail3(error) : void 0;
|
|
1547
|
+
};
|
|
1548
|
+
const pull = suspend(() => {
|
|
1549
|
+
if (failure !== void 0) return fail3(failure);
|
|
1550
|
+
if (done2 !== void 0) return done(done2.leftover);
|
|
1551
|
+
return matchEffect(upstream, {
|
|
1552
|
+
onSuccess: (input) => {
|
|
1553
|
+
const out = [];
|
|
1554
|
+
return emit(out, step(input, out)) ?? pull;
|
|
1555
|
+
},
|
|
1556
|
+
onFailure: failCause,
|
|
1557
|
+
onDone: (leftover) => {
|
|
1558
|
+
done2 = {
|
|
1559
|
+
leftover
|
|
1560
|
+
};
|
|
1561
|
+
const out = [];
|
|
1562
|
+
return emit(out, flush(out)) ?? done(leftover);
|
|
1563
|
+
}
|
|
1564
|
+
});
|
|
1565
|
+
});
|
|
1566
|
+
return pull;
|
|
1567
|
+
};
|
|
1568
|
+
var parseLine = (line, out, ignoreEmptyLines, unterminated) => {
|
|
1569
|
+
if (ignoreEmptyLines && /^[ \t]*$/.test(line)) return;
|
|
1570
|
+
try {
|
|
1571
|
+
out.push(JSON.parse(line));
|
|
1572
|
+
} catch (cause) {
|
|
1573
|
+
return new NdjsonError({
|
|
1574
|
+
kind: "Unpack",
|
|
1575
|
+
reason: "InvalidJson",
|
|
1576
|
+
unterminated,
|
|
1577
|
+
cause
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
var LF2 = 10;
|
|
1582
|
+
var CR2 = 13;
|
|
1583
|
+
var emptyBytes = /* @__PURE__ */ new Uint8Array(0);
|
|
1584
|
+
var decode3 = (options2) => fromTransform((upstream, _scope) => sync(() => {
|
|
1585
|
+
const ignoreEmptyLines = options2?.ignoreEmptyLines === true;
|
|
1586
|
+
const maxLineBytes = options2?.maxLineBytes ?? Number.POSITIVE_INFINITY;
|
|
1587
|
+
let decoder = new TextDecoder("utf-8", {
|
|
1588
|
+
fatal: true
|
|
1589
|
+
});
|
|
1590
|
+
let pending = [];
|
|
1591
|
+
let pendingBytes = 0;
|
|
1592
|
+
let afterCR = false;
|
|
1593
|
+
const takeLine = (chunk, start, end) => {
|
|
1594
|
+
if (pendingBytes === 0) return chunk.subarray(start, end);
|
|
1595
|
+
const line = new Uint8Array(pendingBytes + end - start);
|
|
1596
|
+
let offset = 0;
|
|
1597
|
+
for (const bytes of pending) {
|
|
1598
|
+
line.set(bytes, offset);
|
|
1599
|
+
offset += bytes.length;
|
|
1600
|
+
}
|
|
1601
|
+
line.set(chunk.subarray(start, end), offset);
|
|
1602
|
+
pending = [];
|
|
1603
|
+
pendingBytes = 0;
|
|
1604
|
+
return line;
|
|
1605
|
+
};
|
|
1606
|
+
const decodeLine = (bytes, out, unterminated) => {
|
|
1607
|
+
let line;
|
|
1608
|
+
try {
|
|
1609
|
+
line = decoder.decode(bytes);
|
|
1610
|
+
} catch (cause) {
|
|
1611
|
+
return new NdjsonError({
|
|
1612
|
+
kind: "Unpack",
|
|
1613
|
+
reason: "InvalidUtf8",
|
|
1614
|
+
unterminated,
|
|
1615
|
+
cause
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
const firstLine = decoder !== utf8Decoder;
|
|
1619
|
+
decoder = utf8Decoder;
|
|
1620
|
+
if (firstLine && unterminated && line.length === 0) return;
|
|
1621
|
+
return parseLine(line, out, ignoreEmptyLines, unterminated);
|
|
1622
|
+
};
|
|
1623
|
+
const step = (chunks, out) => {
|
|
1624
|
+
for (const chunk of chunks) {
|
|
1625
|
+
let start = 0;
|
|
1626
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
1627
|
+
const byte = chunk[i];
|
|
1628
|
+
if (byte === LF2 || byte === CR2) {
|
|
1629
|
+
if (byte === LF2 && afterCR) {
|
|
1630
|
+
start = i + 1;
|
|
1631
|
+
} else {
|
|
1632
|
+
const error = decodeLine(takeLine(chunk, start, i), out, false);
|
|
1633
|
+
if (error !== void 0) return error;
|
|
1634
|
+
start = i + 1;
|
|
1635
|
+
}
|
|
1636
|
+
afterCR = byte === CR2;
|
|
1637
|
+
} else {
|
|
1638
|
+
afterCR = false;
|
|
1639
|
+
if (pendingBytes + i + 1 - start > maxLineBytes) {
|
|
1640
|
+
return new NdjsonError({
|
|
1641
|
+
kind: "Unpack",
|
|
1642
|
+
reason: "LineTooLarge",
|
|
1643
|
+
unterminated: false,
|
|
1644
|
+
cause: new RangeError(`NDJSON line exceeds maxLineBytes of ${maxLineBytes}`)
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
if (start < chunk.length) {
|
|
1650
|
+
pending.push(chunk.slice(start));
|
|
1651
|
+
pendingBytes += chunk.length - start;
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
};
|
|
1655
|
+
const flush = (out) => pendingBytes === 0 ? void 0 : decodeLine(takeLine(emptyBytes, 0, 0), out, true);
|
|
1656
|
+
return makeDecodePull(upstream, step, flush);
|
|
1657
|
+
}));
|
|
1658
|
+
|
|
1659
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/internal/path.js
|
|
1223
1660
|
var emptyParamNames = /* @__PURE__ */ new Set();
|
|
1224
1661
|
function getParamNames(schema) {
|
|
1225
1662
|
if (schema === void 0) return emptyParamNames;
|
|
1226
1663
|
const ast = getLastEncoding(schema.ast);
|
|
1227
1664
|
return isObjects(ast) && ast.indexSignatures.length === 0 ? new Set(ast.propertySignatures.map((ps) => String(ps.name))) : void 0;
|
|
1228
1665
|
}
|
|
1666
|
+
function replaceParams(path, paramNames, replace) {
|
|
1667
|
+
const params = /::|:(\w+)/g;
|
|
1668
|
+
let out = "";
|
|
1669
|
+
let last = 0;
|
|
1670
|
+
for (let param = params.exec(path); param !== null; param = params.exec(path)) {
|
|
1671
|
+
const name = param[1];
|
|
1672
|
+
if (name === void 0 || paramNames !== void 0 && !paramNames.has(name)) continue;
|
|
1673
|
+
let end = params.lastIndex;
|
|
1674
|
+
if (path[end] === "(") end = getClosingParenthensePosition(path, end) + 1;
|
|
1675
|
+
const optional2 = path[end] === "?";
|
|
1676
|
+
if (optional2) end++;
|
|
1677
|
+
const value = replace(name, optional2);
|
|
1678
|
+
let start = param.index;
|
|
1679
|
+
if (value === void 0 && path[start - 1] === "/") start--;
|
|
1680
|
+
out += path.slice(last, start) + (value ?? "");
|
|
1681
|
+
params.lastIndex = end;
|
|
1682
|
+
last = end;
|
|
1683
|
+
}
|
|
1684
|
+
return out + path.slice(last);
|
|
1685
|
+
}
|
|
1229
1686
|
|
|
1230
|
-
// ../../node_modules/.bun/effect@4.
|
|
1687
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/HttpApiClient.js
|
|
1231
1688
|
var HttpApiClient_exports = {};
|
|
1232
1689
|
__export(HttpApiClient_exports, {
|
|
1690
|
+
UpgradedTypeId: () => UpgradedTypeId,
|
|
1691
|
+
decodeResponse: () => decodeResponse,
|
|
1233
1692
|
endpoint: () => endpoint,
|
|
1234
1693
|
group: () => group,
|
|
1694
|
+
isUpgraded: () => isUpgraded,
|
|
1235
1695
|
make: () => make6,
|
|
1236
1696
|
makeClient: () => makeClient,
|
|
1237
1697
|
makeWith: () => makeWith,
|
|
1238
1698
|
urlBuilder: () => urlBuilder
|
|
1239
1699
|
});
|
|
1700
|
+
var UpgradedTypeId = "~effect/http-api/HttpApiClient/Upgraded";
|
|
1701
|
+
var isUpgraded = (u) => hasProperty(u, UpgradedTypeId);
|
|
1240
1702
|
var makeClient = (api, options2) => gen(function* () {
|
|
1241
1703
|
const services = yield* context();
|
|
1242
1704
|
const httpClient = options2.httpClient.pipe(options2?.baseUrl === void 0 ? identity : mapRequest(prependUrl(options2.baseUrl.toString())));
|
|
@@ -1266,51 +1728,31 @@ var makeClient = (api, options2) => gen(function* () {
|
|
|
1266
1728
|
const {
|
|
1267
1729
|
group: group2,
|
|
1268
1730
|
endpoint: endpoint2,
|
|
1269
|
-
errors,
|
|
1270
|
-
successes,
|
|
1271
1731
|
mergedAnnotations
|
|
1272
1732
|
} = onEndpointOptions;
|
|
1273
1733
|
const parseOptions = getSlotParseOptions(mergedAnnotations);
|
|
1274
1734
|
const makeUrl = compilePath(endpoint2.path, endpoint2.params);
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
const
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1735
|
+
const upgrade2 = getUpgradeSuccessSchema(endpoint2);
|
|
1736
|
+
const decodeEndpointResponse = makeEndpointDecoder(onEndpointOptions);
|
|
1737
|
+
const encodeParams = map6(endpoint2.params, (schema) => encodeUnknownEffect(schema, parseOptions.params));
|
|
1738
|
+
const payloadSchemas = [];
|
|
1739
|
+
let streamPayload;
|
|
1740
|
+
for (const schema of getPayloadSchemas(endpoint2)) {
|
|
1741
|
+
if (isStreamUint8Array(schema) || isStreamNdjson(schema)) {
|
|
1742
|
+
streamPayload = schema;
|
|
1743
|
+
} else {
|
|
1744
|
+
payloadSchemas.push(schema);
|
|
1283
1745
|
}
|
|
1284
1746
|
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
})), cause))), fail3);
|
|
1293
|
-
}
|
|
1294
|
-
const successAlternatives = /* @__PURE__ */ new Map();
|
|
1295
|
-
for (const [status2, schemas] of successes.entries()) {
|
|
1296
|
-
const grouped = groupSchemasByContentType(schemas);
|
|
1297
|
-
for (const [contentType, schemas2] of grouped.entries()) {
|
|
1298
|
-
addResponseAlternative(successAlternatives, status2, contentType, schemasToResponse(schemas2, parseOptions.success, parseOptions.headers));
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
for (const streamSuccess of getStreamSuccessSchemas(endpoint2)) {
|
|
1302
|
-
const streamSchema2 = isWithHeadersStreamSuccess(streamSuccess) ? streamSuccess.schema : streamSuccess;
|
|
1303
|
-
addResponseAlternative(successAlternatives, getStatusSuccessSchema(streamSuccess), streamSchema2.contentType, streamToResponse(streamSuccess, parseOptions.success, parseOptions.headers));
|
|
1304
|
-
}
|
|
1305
|
-
for (const [status2, alternatives] of successAlternatives.entries()) {
|
|
1306
|
-
decodeMap[status2] = makeResponseDecoder(alternatives);
|
|
1307
|
-
}
|
|
1308
|
-
const encodeParams = map4(endpoint2.params, (schema) => encodeUnknownEffect(schema, parseOptions.params));
|
|
1309
|
-
const payloadSchemas = getPayloadSchemas(endpoint2);
|
|
1310
|
-
const encodePayload = isArrayNonEmpty(payloadSchemas) ? encodeUnknownEffect(hasBody(endpoint2.method) ? getEncodePayloadSchema(payloadSchemas, endpoint2.method) : Union(payloadSchemas), parseOptions.payload) : void 0;
|
|
1311
|
-
const encodeHeaders = map4(endpoint2.headers, (schema) => encodeUnknownEffect(schema, parseOptions.headers));
|
|
1312
|
-
const encodeQuery = map4(endpoint2.query, (schema) => encodeUnknownEffect(schema, parseOptions.query));
|
|
1747
|
+
const streamPayloadEncoder = map6(streamPayload, (schema) => ({
|
|
1748
|
+
contentType: schema.contentType,
|
|
1749
|
+
encode: makeStreamPayloadEncoder(schema, parseOptions.payload)
|
|
1750
|
+
}));
|
|
1751
|
+
const encodePayload = isArrayNonEmpty(payloadSchemas) ? encodeUnknownEffect(hasBody(endpoint2.method) ? getEncodePayloadSchema(payloadSchemas, endpoint2.method) : Union2(payloadSchemas), parseOptions.payload) : void 0;
|
|
1752
|
+
const encodeHeaders = map6(endpoint2.headers, (schema) => encodeUnknownEffect(schema, parseOptions.headers));
|
|
1753
|
+
const encodeQuery = map6(endpoint2.query, (schema) => encodeUnknownEffect(schema, parseOptions.query));
|
|
1313
1754
|
const middlewareKeys = Array.from(onEndpointOptions.middleware, (tag2) => `${tag2.key}/Client`);
|
|
1755
|
+
const redactedNames = getEndpointRedactedNames(api, group2, endpoint2);
|
|
1314
1756
|
const endpointFn = fnUntraced(function* (request) {
|
|
1315
1757
|
let httpRequest = make2(endpoint2.method)(endpoint2.path);
|
|
1316
1758
|
if (request !== void 0) {
|
|
@@ -1318,7 +1760,10 @@ var makeClient = (api, options2) => gen(function* () {
|
|
|
1318
1760
|
const params = yield* encodeParams(request.params);
|
|
1319
1761
|
httpRequest = setUrl(httpRequest, makeUrl(params));
|
|
1320
1762
|
}
|
|
1321
|
-
if (
|
|
1763
|
+
if (streamPayloadEncoder !== void 0 && isStream(request.payload)) {
|
|
1764
|
+
const context2 = yield* context();
|
|
1765
|
+
httpRequest = setBody(httpRequest, stream(provideContext(streamPayloadEncoder.encode(request.payload), context2), streamPayloadEncoder.contentType));
|
|
1766
|
+
} else if (encodePayload !== void 0) {
|
|
1322
1767
|
if (hasBody(endpoint2.method)) {
|
|
1323
1768
|
if (request.payload instanceof FormData) {
|
|
1324
1769
|
httpRequest = bodyFormData(httpRequest, request.payload);
|
|
@@ -1330,6 +1775,10 @@ var makeClient = (api, options2) => gen(function* () {
|
|
|
1330
1775
|
const urlParams2 = yield* encodePayload(request.payload);
|
|
1331
1776
|
httpRequest = appendUrlParams(httpRequest, urlParams2);
|
|
1332
1777
|
}
|
|
1778
|
+
} else if (streamPayloadEncoder !== void 0) {
|
|
1779
|
+
return yield* new SchemaError(new InvalidValue({
|
|
1780
|
+
message: "Expected a Stream payload"
|
|
1781
|
+
}, request.payload));
|
|
1333
1782
|
}
|
|
1334
1783
|
if (encodeHeaders !== void 0) {
|
|
1335
1784
|
const headers = yield* encodeHeaders(request.headers);
|
|
@@ -1340,11 +1789,15 @@ var makeClient = (api, options2) => gen(function* () {
|
|
|
1340
1789
|
httpRequest = appendUrlParams(httpRequest, query2);
|
|
1341
1790
|
}
|
|
1342
1791
|
}
|
|
1343
|
-
|
|
1792
|
+
if (upgrade2 !== void 0) {
|
|
1793
|
+
httpRequest = upgrade(httpRequest, upgrade2.protocol);
|
|
1794
|
+
}
|
|
1795
|
+
const execute = executeMiddleware(group2, endpoint2, httpRequest, middlewareKeys, middlewareKeys.length - 1);
|
|
1796
|
+
const response = yield* redactedNames === void 0 ? execute : withRedactedNames(execute, redactedNames);
|
|
1344
1797
|
if (request?.responseMode === "response-only") {
|
|
1345
1798
|
return response;
|
|
1346
1799
|
}
|
|
1347
|
-
const decoded = (
|
|
1800
|
+
const decoded = decodeEndpointResponse(response, request?.sseOptions);
|
|
1348
1801
|
const value = yield* options2.transformResponse === void 0 ? decoded : options2.transformResponse(decoded);
|
|
1349
1802
|
return request?.responseMode === "decoded-and-response" ? [value, response] : value;
|
|
1350
1803
|
});
|
|
@@ -1355,6 +1808,7 @@ var makeClient = (api, options2) => gen(function* () {
|
|
|
1355
1808
|
}
|
|
1356
1809
|
});
|
|
1357
1810
|
});
|
|
1811
|
+
var withRedactedNames = (effect, redactedNames) => effect.pipe(updateService(CurrentRedactedNames2, (names) => [...names, ...redactedNames.query]), updateService(CurrentRedactedNames, (names) => [...names, ...redactedNames.headers]));
|
|
1358
1812
|
var make6 = (api, options2) => flatMap(HttpClient, (httpClient) => makeWith(api, {
|
|
1359
1813
|
...options2,
|
|
1360
1814
|
httpClient: options2?.transformClient ? options2.transformClient(httpClient) : httpClient
|
|
@@ -1391,7 +1845,7 @@ var group = (api, options2) => {
|
|
|
1391
1845
|
}) {
|
|
1392
1846
|
assignProperty(client, endpoint2.identifier, endpointFn);
|
|
1393
1847
|
}
|
|
1394
|
-
}).pipe(
|
|
1848
|
+
}).pipe(map3(() => client));
|
|
1395
1849
|
};
|
|
1396
1850
|
var endpoint = (api, options2) => {
|
|
1397
1851
|
let client = void 0;
|
|
@@ -1407,7 +1861,22 @@ var endpoint = (api, options2) => {
|
|
|
1407
1861
|
}) {
|
|
1408
1862
|
client = endpointFn;
|
|
1409
1863
|
}
|
|
1410
|
-
}).pipe(
|
|
1864
|
+
}).pipe(map3(() => client));
|
|
1865
|
+
};
|
|
1866
|
+
var decodeResponse = (api, options2) => {
|
|
1867
|
+
let decode4;
|
|
1868
|
+
reflect(api, {
|
|
1869
|
+
predicate: ({
|
|
1870
|
+
endpoint: endpoint2,
|
|
1871
|
+
group: group2
|
|
1872
|
+
}) => group2.identifier === options2.group && endpoint2.identifier === options2.endpoint,
|
|
1873
|
+
onGroup() {
|
|
1874
|
+
},
|
|
1875
|
+
onEndpoint(endpointOptions) {
|
|
1876
|
+
decode4 = makeEndpointDecoder(endpointOptions);
|
|
1877
|
+
}
|
|
1878
|
+
});
|
|
1879
|
+
return (response, decodeOptions) => decode4(response, decodeOptions?.sseOptions);
|
|
1411
1880
|
};
|
|
1412
1881
|
var urlBuilder = (api, options2) => {
|
|
1413
1882
|
const builder = {};
|
|
@@ -1439,7 +1908,7 @@ var urlBuilder = (api, options2) => {
|
|
|
1439
1908
|
const url = new URL(prependUrl(get(path), options2.baseUrl.toString()).url);
|
|
1440
1909
|
for (const [key, value] of urlParams2.params) {
|
|
1441
1910
|
if (value !== void 0) {
|
|
1442
|
-
url.searchParams.append(key, value);
|
|
1911
|
+
url.searchParams.append(key, unwrap(value));
|
|
1443
1912
|
}
|
|
1444
1913
|
}
|
|
1445
1914
|
return url.toString();
|
|
@@ -1449,36 +1918,29 @@ var urlBuilder = (api, options2) => {
|
|
|
1449
1918
|
});
|
|
1450
1919
|
return builder;
|
|
1451
1920
|
};
|
|
1452
|
-
var paramsRegExp = /(\/?):(\w+)(\?)?/g;
|
|
1453
1921
|
var compilePath = (path, schema) => {
|
|
1454
1922
|
if (schema === void 0 || !path.includes(":")) {
|
|
1455
1923
|
return (_) => path;
|
|
1456
1924
|
}
|
|
1457
1925
|
const paramNames = getParamNames(schema);
|
|
1458
|
-
return (params) => {
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
}
|
|
1468
|
-
throw new Error(`Missing path parameter: ${key}`);
|
|
1469
|
-
}
|
|
1470
|
-
return `${slash}${encodeURIComponent(value)}`;
|
|
1471
|
-
});
|
|
1472
|
-
};
|
|
1926
|
+
return (params) => replaceParams(path, paramNames, (key, optional2) => {
|
|
1927
|
+
const value = params[key];
|
|
1928
|
+
if (value === "." || value === "..") {
|
|
1929
|
+
throw new Error(`Invalid path parameter: ${key}`);
|
|
1930
|
+
}
|
|
1931
|
+
if (value !== void 0) return encodeURIComponent(value);
|
|
1932
|
+
if (optional2) return void 0;
|
|
1933
|
+
throw new Error(`Missing path parameter: ${key}`);
|
|
1934
|
+
});
|
|
1473
1935
|
};
|
|
1474
1936
|
function schemasToResponse(schemas, options2, headersOptions) {
|
|
1475
1937
|
const hasWithHeaders = schemas.some((schema) => isWithHeaders(schema) || getWithHeadersAnnotation(schema.ast) !== void 0);
|
|
1476
|
-
const codec = hasWithHeaders ?
|
|
1477
|
-
const
|
|
1478
|
-
return (response) => flatMap(response.arrayBuffer, hasWithHeaders ? (body) =>
|
|
1938
|
+
const codec = hasWithHeaders ? Union2(schemas.map((schema) => toCodecArrayBufferWithHeaders(schema, options2, headersOptions))) : toCodecArrayBuffer(schemas);
|
|
1939
|
+
const decode4 = decodeUnknownEffect(codec, options2);
|
|
1940
|
+
return (response) => flatMap(response.arrayBuffer, hasWithHeaders ? (body) => decode4({
|
|
1479
1941
|
body,
|
|
1480
1942
|
headers: response.headers
|
|
1481
|
-
}) :
|
|
1943
|
+
}) : decode4);
|
|
1482
1944
|
}
|
|
1483
1945
|
var ResponsePair = /* @__PURE__ */ Struct({
|
|
1484
1946
|
body: Unknown,
|
|
@@ -1499,70 +1961,139 @@ function toCodecArrayBufferWithHeaders(schema, options2, headersOptions) {
|
|
|
1499
1961
|
headers: Unknown,
|
|
1500
1962
|
toValue: (pair) => pair.body
|
|
1501
1963
|
};
|
|
1502
|
-
const decodeBody = decodeUnknownEffect(fromArrayBuffer(parts.body).pipe(
|
|
1964
|
+
const decodeBody = decodeUnknownEffect(fromArrayBuffer(parts.body).pipe(decodeTo2(parts.body)), options2);
|
|
1503
1965
|
const decodeHeaders = decodeUnknownEffect(parts.headers, headersOptions);
|
|
1504
|
-
return ResponsePair.pipe(
|
|
1966
|
+
return ResponsePair.pipe(decodeTo2(isWithHeaders(schema) ? schema : toType(schema), transformEffect({
|
|
1505
1967
|
decode: (pair) => all({
|
|
1506
1968
|
body: decodeBody(pair.body),
|
|
1507
1969
|
headers: decodeHeaders(pair.headers)
|
|
1508
|
-
}).pipe(
|
|
1970
|
+
}).pipe(map3(parts.toValue), mapError((error) => error.issue)),
|
|
1509
1971
|
encode: (input, options3) => fail3(new Forbidden({
|
|
1510
1972
|
message: "Decode only schema"
|
|
1511
1973
|
}, input, options3))
|
|
1512
1974
|
})));
|
|
1513
1975
|
}
|
|
1514
|
-
|
|
1515
|
-
const
|
|
1976
|
+
var makeEndpointDecoder = (options2) => {
|
|
1977
|
+
const {
|
|
1978
|
+
endpoint: endpoint2,
|
|
1979
|
+
errors,
|
|
1980
|
+
successes,
|
|
1981
|
+
mergedAnnotations
|
|
1982
|
+
} = options2;
|
|
1983
|
+
const parseOptions = getSlotParseOptions(mergedAnnotations);
|
|
1984
|
+
const decodeMap = {
|
|
1985
|
+
orElse: statusOrElse
|
|
1986
|
+
};
|
|
1987
|
+
const errorAlternatives = /* @__PURE__ */ new Map();
|
|
1988
|
+
for (const [status2, schemas] of errors.entries()) {
|
|
1989
|
+
const grouped = groupSchemasByContentType(schemas);
|
|
1990
|
+
for (const [contentType2, schemas2] of grouped.entries()) {
|
|
1991
|
+
addResponseAlternative(errorAlternatives, status2, contentType2, schemasToResponse(schemas2, parseOptions.error, parseOptions.headers));
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
for (const [status2, alternatives] of errorAlternatives.entries()) {
|
|
1995
|
+
const decode4 = makeResponseDecoder(alternatives);
|
|
1996
|
+
decodeMap[status2] = (response) => flatMap(catchCause(decode4(response), (cause) => failCause(combine(fail2(new HttpClientError({
|
|
1997
|
+
reason: new StatusCodeError({
|
|
1998
|
+
request: response.request,
|
|
1999
|
+
response
|
|
2000
|
+
})
|
|
2001
|
+
})), cause))), fail3);
|
|
2002
|
+
}
|
|
2003
|
+
const successAlternatives = /* @__PURE__ */ new Map();
|
|
2004
|
+
for (const [status2, schemas] of successes.entries()) {
|
|
2005
|
+
const grouped = groupSchemasByContentType(schemas);
|
|
2006
|
+
for (const [contentType2, schemas2] of grouped.entries()) {
|
|
2007
|
+
addResponseAlternative(successAlternatives, status2, contentType2, schemasToResponse(schemas2, parseOptions.success, parseOptions.headers));
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
for (const streamSuccess of getStreamSuccessSchemas(endpoint2)) {
|
|
2011
|
+
const streamSchema2 = isWithHeadersStreamSuccess(streamSuccess) ? streamSuccess.schema : streamSuccess;
|
|
2012
|
+
const status2 = getStatusSuccessSchema(streamSuccess);
|
|
2013
|
+
const decode4 = streamToResponse(streamSuccess, parseOptions.success, parseOptions.headers);
|
|
2014
|
+
for (const contentType2 of streamSchema2.contentTypes) {
|
|
2015
|
+
addResponseAlternative(successAlternatives, status2, contentType2, decode4);
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
for (const [status2, alternatives] of successAlternatives.entries()) {
|
|
2019
|
+
decodeMap[status2] = makeResponseDecoder(alternatives);
|
|
2020
|
+
}
|
|
2021
|
+
const upgrade2 = getUpgradeSuccessSchema(endpoint2);
|
|
2022
|
+
if (upgrade2 !== void 0) {
|
|
2023
|
+
const decodeHeaders = upgrade2.headers === void 0 ? succeed2 : decodeUnknownEffect(upgrade2.headers, parseOptions.headers);
|
|
2024
|
+
decodeMap[101] = (response) => (
|
|
2025
|
+
// the cleanup must be in place before an interruption can be observed
|
|
2026
|
+
uninterruptibleMask((restore) => flatMap(response.upgrade, (socket) => restore(decodeHeaders(response.headers)).pipe(
|
|
2027
|
+
map3((headers) => ({
|
|
2028
|
+
[UpgradedTypeId]: UpgradedTypeId,
|
|
2029
|
+
headers,
|
|
2030
|
+
socket
|
|
2031
|
+
})),
|
|
2032
|
+
// nothing takes the connection on failure, so close it: releasing
|
|
2033
|
+
// the reader's scope closes the connection
|
|
2034
|
+
onError(() => ignore(scoped(socket.reader)))
|
|
2035
|
+
)))
|
|
2036
|
+
);
|
|
2037
|
+
}
|
|
2038
|
+
return (response, sseOptions) => (decodeMap[response.status] ?? decodeMap.orElse)(response, sseOptions);
|
|
2039
|
+
};
|
|
2040
|
+
function addResponseAlternative(map7, status2, contentType2, decode4) {
|
|
2041
|
+
const normalizedContentType = normalize(contentType2);
|
|
1516
2042
|
const alternatives = map7.get(status2);
|
|
1517
2043
|
if (alternatives === void 0) {
|
|
1518
2044
|
map7.set(status2, [{
|
|
1519
2045
|
contentType: normalizedContentType,
|
|
1520
|
-
decode:
|
|
2046
|
+
decode: decode4
|
|
1521
2047
|
}]);
|
|
1522
2048
|
} else {
|
|
1523
2049
|
alternatives.push({
|
|
1524
2050
|
contentType: normalizedContentType,
|
|
1525
|
-
decode:
|
|
2051
|
+
decode: decode4
|
|
1526
2052
|
});
|
|
1527
2053
|
}
|
|
1528
2054
|
}
|
|
1529
2055
|
function makeResponseDecoder(alternatives) {
|
|
1530
2056
|
const first = alternatives[0];
|
|
1531
|
-
if (
|
|
2057
|
+
if (first !== void 0 && alternatives.every((alternative) => alternative.decode === first.decode)) {
|
|
1532
2058
|
return first.decode;
|
|
1533
2059
|
}
|
|
1534
2060
|
return (response, sseOptions) => {
|
|
1535
|
-
const
|
|
1536
|
-
const alternative = alternatives.find((alternative2) => alternative2.contentType ===
|
|
1537
|
-
return alternative === void 0 ? failUnsupportedContentType(response,
|
|
2061
|
+
const contentType2 = normalize(response.headers["content-type"] ?? "");
|
|
2062
|
+
const alternative = alternatives.find((alternative2) => alternative2.contentType === contentType2);
|
|
2063
|
+
return alternative === void 0 ? failUnsupportedContentType(response, contentType2, alternatives) : alternative.decode(response, sseOptions);
|
|
1538
2064
|
};
|
|
1539
2065
|
}
|
|
1540
2066
|
function groupSchemasByContentType(schemas) {
|
|
1541
2067
|
const grouped = /* @__PURE__ */ new Map();
|
|
1542
2068
|
for (const schema of schemas) {
|
|
1543
2069
|
const body = isWithHeaders(schema) ? schema.schema : schema;
|
|
1544
|
-
const
|
|
1545
|
-
const existing = grouped.get(
|
|
2070
|
+
const contentType2 = isNoContent(body.ast) ? "" : normalize(getResponseEncodingSchema(schema).contentType);
|
|
2071
|
+
const existing = grouped.get(contentType2);
|
|
1546
2072
|
if (existing === void 0) {
|
|
1547
|
-
grouped.set(
|
|
2073
|
+
grouped.set(contentType2, [schema]);
|
|
1548
2074
|
} else {
|
|
1549
2075
|
existing.push(schema);
|
|
1550
2076
|
}
|
|
1551
2077
|
}
|
|
1552
2078
|
return grouped;
|
|
1553
2079
|
}
|
|
1554
|
-
function failUnsupportedContentType(response,
|
|
2080
|
+
function failUnsupportedContentType(response, contentType2, alternatives) {
|
|
1555
2081
|
const expected = Array.from(new Set(alternatives.map((alternative) => alternative.contentType))).join(", ");
|
|
1556
2082
|
return fail3(new HttpClientError({
|
|
1557
2083
|
reason: new DecodeError({
|
|
1558
2084
|
request: response.request,
|
|
1559
2085
|
response,
|
|
1560
|
-
description: `Unsupported response content-type for status ${response.status}: ${
|
|
2086
|
+
description: `Unsupported response content-type for status ${response.status}: ${contentType2 || "<missing>"}. Expected one of: ${expected}`
|
|
1561
2087
|
})
|
|
1562
2088
|
}));
|
|
1563
2089
|
}
|
|
1564
2090
|
var reservedStreamFailureEvent2 = "effect/http-api/stream/failure";
|
|
1565
2091
|
var isWithHeadersStreamSuccess = (schema) => isWithHeaders(schema);
|
|
2092
|
+
function getUpgradeSuccessSchema(endpoint2) {
|
|
2093
|
+
for (const schema of endpoint2.success) {
|
|
2094
|
+
if (isUpgrade(schema)) return schema;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
1566
2097
|
function getStreamSuccessSchemas(endpoint2) {
|
|
1567
2098
|
const schemas = [];
|
|
1568
2099
|
for (const schema of endpoint2.success) {
|
|
@@ -1576,20 +2107,46 @@ function getStreamSuccessSchemas(endpoint2) {
|
|
|
1576
2107
|
function streamToResponse(successSchema, options2, headersOptions) {
|
|
1577
2108
|
const isWithHeaders2 = isWithHeadersStreamSuccess(successSchema);
|
|
1578
2109
|
const streamSchema2 = isWithHeaders2 ? successSchema.schema : successSchema;
|
|
1579
|
-
const
|
|
1580
|
-
|
|
1581
|
-
decoder: makeSseDecoder(streamSchema2, options2)
|
|
1582
|
-
};
|
|
1583
|
-
const toStream = (response, sseOptions) => map2(context(), (context2) => provideContext(sse === void 0 ? response.stream : decodeSseStream(response.stream, sse.declaration, sse.decoder(sseOptions)), context2));
|
|
2110
|
+
const decodeBody = makeStreamBodyDecoder(streamSchema2, options2);
|
|
2111
|
+
const toStream = (response, sseOptions) => map3(context(), (context2) => provideContext(decodeBody(response, sseOptions), context2));
|
|
1584
2112
|
if (!isWithHeaders2) return toStream;
|
|
1585
2113
|
const decodeHeaders = decodeUnknownEffect(successSchema.headers, headersOptions);
|
|
1586
|
-
return (response, sseOptions) => flatMap(decodeHeaders(response.headers), (headers) =>
|
|
2114
|
+
return (response, sseOptions) => flatMap(decodeHeaders(response.headers), (headers) => map3(toStream(response, sseOptions), (body) => withHeaders({
|
|
1587
2115
|
body,
|
|
1588
2116
|
headers
|
|
1589
2117
|
})));
|
|
1590
2118
|
}
|
|
2119
|
+
function makeStreamBodyDecoder(streamSchema2, options2) {
|
|
2120
|
+
if (isStreamUint8Array(streamSchema2)) {
|
|
2121
|
+
return (response) => response.stream;
|
|
2122
|
+
}
|
|
2123
|
+
if (isStreamNdjson(streamSchema2)) {
|
|
2124
|
+
const decodeElement = decodeUnknownEffect(toCodecJson(streamSchema2.schema), options2);
|
|
2125
|
+
const maxElementBytes = toNumberUnsafe(streamSchema2.maxElementBytes);
|
|
2126
|
+
return (response) => response.stream.pipe(pipeThroughChannel(decode3({
|
|
2127
|
+
ignoreEmptyLines: true,
|
|
2128
|
+
maxLineBytes: maxElementBytes
|
|
2129
|
+
})), mapError2((error) => {
|
|
2130
|
+
if (!isNdjsonError(error)) return error;
|
|
2131
|
+
if (error.reason !== "LineTooLarge") return ndjsonSchemaError(error);
|
|
2132
|
+
return new HttpClientError({
|
|
2133
|
+
reason: new DecodeError({
|
|
2134
|
+
request: response.request,
|
|
2135
|
+
response,
|
|
2136
|
+
description: `NDJSON line exceeds maxElementBytes of ${maxElementBytes} bytes`
|
|
2137
|
+
})
|
|
2138
|
+
});
|
|
2139
|
+
}), mapEffect((json) => decodeElement(json)));
|
|
2140
|
+
}
|
|
2141
|
+
const decoder = makeSseDecoder(streamSchema2, options2);
|
|
2142
|
+
return (response, sseOptions) => decodeSseStream(response.stream, streamSchema2, decoder(sseOptions));
|
|
2143
|
+
}
|
|
2144
|
+
var isNdjsonPackError = (error) => isNdjsonError(error) && error.kind === "Pack";
|
|
2145
|
+
var ndjsonSchemaError = (error) => new SchemaError(new InvalidValue({
|
|
2146
|
+
message: error.reason === "InvalidUtf8" ? "Expected valid UTF-8" : error.unterminated ? "Expected a valid JSON line, got an unterminated final line" : "Expected a valid JSON line"
|
|
2147
|
+
}));
|
|
1591
2148
|
function makeSseDecoder(declaration, parseOptions) {
|
|
1592
|
-
const Event2 =
|
|
2149
|
+
const Event2 = Union2([Struct({
|
|
1593
2150
|
id: optional(String2),
|
|
1594
2151
|
event: Literal(reservedStreamFailureEvent2),
|
|
1595
2152
|
data: fromJsonString(toCodecJson(Cause(declaration.error, Defect())))
|
|
@@ -1597,8 +2154,8 @@ function makeSseDecoder(declaration, parseOptions) {
|
|
|
1597
2154
|
const defaultDecoder = decodeSchema(Event2, void 0, parseOptions);
|
|
1598
2155
|
return (options2) => options2 === void 0 ? defaultDecoder : decodeSchema(Event2, options2, parseOptions);
|
|
1599
2156
|
}
|
|
1600
|
-
function decodeSseStream(
|
|
1601
|
-
const events = transformPull(
|
|
2157
|
+
function decodeSseStream(stream2, declaration, decoder) {
|
|
2158
|
+
const events = transformPull(stream2.pipe(decodeText, pipeThroughChannel(decoder)), (pull) => sync(() => {
|
|
1602
2159
|
let pendingFailureCause = void 0;
|
|
1603
2160
|
return suspend(() => {
|
|
1604
2161
|
if (pendingFailureCause !== void 0) {
|
|
@@ -1621,14 +2178,14 @@ function decodeSseStream(stream, declaration, decoder) {
|
|
|
1621
2178
|
});
|
|
1622
2179
|
}));
|
|
1623
2180
|
if (declaration.sseMode === "data") {
|
|
1624
|
-
return
|
|
2181
|
+
return map5(events, (event) => event.data);
|
|
1625
2182
|
}
|
|
1626
2183
|
return events;
|
|
1627
2184
|
}
|
|
1628
2185
|
var ArrayBuffer = /* @__PURE__ */ instanceOf(globalThis.ArrayBuffer, {
|
|
1629
2186
|
expected: "ArrayBuffer"
|
|
1630
2187
|
});
|
|
1631
|
-
var Uint8ArrayFromArrayBuffer = /* @__PURE__ */ ArrayBuffer.pipe(/* @__PURE__ */
|
|
2188
|
+
var Uint8ArrayFromArrayBuffer = /* @__PURE__ */ ArrayBuffer.pipe(/* @__PURE__ */ decodeTo2(Uint8Array2, /* @__PURE__ */ transform({
|
|
1632
2189
|
decode(fromA) {
|
|
1633
2190
|
return new Uint8Array(fromA);
|
|
1634
2191
|
},
|
|
@@ -1636,7 +2193,7 @@ var Uint8ArrayFromArrayBuffer = /* @__PURE__ */ ArrayBuffer.pipe(/* @__PURE__ */
|
|
|
1636
2193
|
return arr.byteLength === arr.buffer.byteLength ? arr.buffer : arr.buffer.slice(arr.byteOffset, arr.byteOffset + arr.byteLength);
|
|
1637
2194
|
}
|
|
1638
2195
|
})));
|
|
1639
|
-
var StringFromArrayBuffer = /* @__PURE__ */ ArrayBuffer.pipe(/* @__PURE__ */
|
|
2196
|
+
var StringFromArrayBuffer = /* @__PURE__ */ ArrayBuffer.pipe(/* @__PURE__ */ decodeTo2(String2, /* @__PURE__ */ transform({
|
|
1640
2197
|
decode(fromA) {
|
|
1641
2198
|
return new TextDecoder().decode(fromA);
|
|
1642
2199
|
},
|
|
@@ -1645,18 +2202,18 @@ var StringFromArrayBuffer = /* @__PURE__ */ ArrayBuffer.pipe(/* @__PURE__ */ dec
|
|
|
1645
2202
|
return arr.byteLength === arr.buffer.byteLength ? arr.buffer : arr.buffer.slice(arr.byteOffset, arr.byteOffset + arr.byteLength);
|
|
1646
2203
|
}
|
|
1647
2204
|
})));
|
|
1648
|
-
var UnknownFromArrayBuffer = /* @__PURE__ */ StringFromArrayBuffer.pipe(/* @__PURE__ */
|
|
2205
|
+
var UnknownFromArrayBuffer = /* @__PURE__ */ StringFromArrayBuffer.pipe(/* @__PURE__ */ decodeTo2(/* @__PURE__ */ Union2([
|
|
1649
2206
|
// Handle No Content
|
|
1650
|
-
/* @__PURE__ */ Literal("").pipe(/* @__PURE__ */
|
|
2207
|
+
/* @__PURE__ */ Literal("").pipe(/* @__PURE__ */ decodeTo2(Undefined, /* @__PURE__ */ transform({
|
|
1651
2208
|
decode: () => void 0,
|
|
1652
2209
|
encode: () => ""
|
|
1653
2210
|
}))),
|
|
1654
2211
|
UnknownFromJsonString
|
|
1655
2212
|
])));
|
|
1656
2213
|
function toCodecArrayBuffer(schemas) {
|
|
1657
|
-
return
|
|
2214
|
+
return Union2(schemas.map(onSchema));
|
|
1658
2215
|
function onSchema(schema) {
|
|
1659
|
-
return fromArrayBuffer(schema).pipe(
|
|
2216
|
+
return fromArrayBuffer(schema).pipe(decodeTo2(schema));
|
|
1660
2217
|
}
|
|
1661
2218
|
}
|
|
1662
2219
|
function fromArrayBuffer(schema) {
|
|
@@ -1664,13 +2221,13 @@ function fromArrayBuffer(schema) {
|
|
|
1664
2221
|
switch (encoding._tag) {
|
|
1665
2222
|
case "Json": {
|
|
1666
2223
|
const encodedIsNull = isNull(toEncoded(schema.ast));
|
|
1667
|
-
return encodedIsNull ? UnknownFromArrayBuffer.pipe(
|
|
2224
|
+
return encodedIsNull ? UnknownFromArrayBuffer.pipe(decodeTo2(Unknown, transform({
|
|
1668
2225
|
decode: (a) => a === void 0 ? null : a,
|
|
1669
2226
|
encode: (a) => a === null ? void 0 : a
|
|
1670
2227
|
}))) : UnknownFromArrayBuffer;
|
|
1671
2228
|
}
|
|
1672
2229
|
case "FormUrlEncoded":
|
|
1673
|
-
return StringFromArrayBuffer.pipe(
|
|
2230
|
+
return StringFromArrayBuffer.pipe(decodeTo2(RecordFromUrlParams, transform({
|
|
1674
2231
|
decode: (text2) => fromInput(new URLSearchParams(text2)),
|
|
1675
2232
|
encode: toString
|
|
1676
2233
|
})));
|
|
@@ -1683,12 +2240,20 @@ function fromArrayBuffer(schema) {
|
|
|
1683
2240
|
var statusOrElse = (response) => fail3(new HttpClientError({
|
|
1684
2241
|
reason: new DecodeError({
|
|
1685
2242
|
request: response.request,
|
|
1686
|
-
response
|
|
2243
|
+
response,
|
|
2244
|
+
description: "undeclared status code"
|
|
1687
2245
|
})
|
|
1688
2246
|
}));
|
|
1689
2247
|
var $HttpBody = /* @__PURE__ */ declare(isHttpBody);
|
|
2248
|
+
function makeStreamPayloadEncoder(schema, options2) {
|
|
2249
|
+
if (isStreamUint8Array(schema)) {
|
|
2250
|
+
return (stream2) => stream2;
|
|
2251
|
+
}
|
|
2252
|
+
const encodeElements = encodeUnknownEffect(NonEmptyArray(toCodecJson(schema.schema)), options2);
|
|
2253
|
+
return (stream2) => stream2.pipe(mapArrayEffect((elements) => encodeElements(elements)), pipeThroughChannel(encode2()), catchIf(isNdjsonPackError, die));
|
|
2254
|
+
}
|
|
1690
2255
|
function getEncodePayloadSchema(schemas, method) {
|
|
1691
|
-
return
|
|
2256
|
+
return Union2(schemas.map((s) => getEncodePayloadSchemaFromBody(s, method)));
|
|
1692
2257
|
}
|
|
1693
2258
|
var bodyFromPayloadCache = /* @__PURE__ */ new WeakMap();
|
|
1694
2259
|
function getEncodePayloadSchemaFromBody(schema, method) {
|
|
@@ -1698,7 +2263,7 @@ function getEncodePayloadSchemaFromBody(schema, method) {
|
|
|
1698
2263
|
return cached;
|
|
1699
2264
|
}
|
|
1700
2265
|
const encoding = getPayloadEncoding(ast, method);
|
|
1701
|
-
const out = $HttpBody.pipe(
|
|
2266
|
+
const out = $HttpBody.pipe(decodeTo2(schema, transformEffect({
|
|
1702
2267
|
decode(input, options2) {
|
|
1703
2268
|
return fail3(new Forbidden({
|
|
1704
2269
|
message: "Encode only schema"
|