apps 0.0.1-beta.13 → 0.0.1-beta.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -42
- package/framework-reference.json +1 -1
- package/js/{chunk-M3B3DE4K.js → chunk-2XDCAXAR.js} +612 -246
- package/js/{chunk-IPI4MFSN.js → chunk-34RH47V5.js} +2 -2
- package/js/chunk-3ICMSVNC.js +175 -0
- package/js/chunk-4SIYTPIK.js +724 -0
- package/js/{chunk-KUMBKVJD.js → chunk-6QZVXLF2.js} +2 -2
- package/js/chunk-7MPPHKRW.js +5418 -0
- package/js/chunk-AR22I6UO.js +1016 -0
- package/js/chunk-BMHEVNGF.js +49 -0
- package/js/{chunk-RFVIONFX.js → chunk-BSSBP57D.js} +136 -45
- package/js/{chunk-ODEIDRGW.js → chunk-DWYOLPWT.js} +1133 -503
- package/js/chunk-H2K7OZ47.js +90 -0
- package/js/chunk-I6QAWNUM.js +161 -0
- package/js/{chunk-QS6CAHKC.js → chunk-J52LZT2Y.js} +4 -3
- package/js/chunk-JLW4LQS7.js +335 -0
- package/js/chunk-L2RUGQAM.js +576 -0
- package/js/chunk-LSOHA2RH.js +88 -0
- package/js/{chunk-UK573G7W.js → chunk-MB6L5YZE.js} +1817 -632
- package/js/chunk-OBT33ZDK.js +95 -0
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-JU7VHODU.js → chunk-QTX7OUFH.js} +65 -10
- package/js/chunk-T7MXJSCW.js +1945 -0
- package/js/{chunk-VFZKSM3T.js → chunk-VX36SA7Y.js} +3 -3
- package/js/chunk-WX773GGX.js +449 -0
- package/js/{chunk-5T57N25Q.js → chunk-WXHRUWNT.js} +651 -70
- package/js/{chunk-CDL5PM2Q.js → chunk-YFSOSNF3.js} +17265 -12477
- package/js/{chunk-IJX4CYZO.js → chunk-YVN2AMAU.js} +976 -447
- package/js/client.js +234 -92
- package/js/contracts.js +154 -21
- package/js/effect.js +18 -19
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +231 -188
- package/js/host.js +138 -80
- package/js/index.js +153 -300
- package/js/mcp/effect.js +21 -21
- package/js/mcp.js +91 -57
- package/js/openapi.js +4357 -1415
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -3
- package/js/skills.js +220 -81
- package/js/storage/facet.js +1 -540
- package/js/ui/auth/contracts.js +2 -2
- package/js/ui/auth.js +5 -5
- package/js/ui/contracts.js +9 -8
- package/js/ui/serving.js +8618 -235
- package/package.json +3 -8
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +18 -0
- package/types/app-cache/src/index.d.ts +34 -2
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +56 -11
- package/types/apps/src/contracts/cache.d.ts +20 -0
- package/types/apps/src/contracts/context.d.ts +60 -17
- package/types/apps/src/contracts/elicitation.d.ts +23 -7
- package/types/apps/src/contracts/events.d.ts +94 -0
- package/types/apps/src/contracts/failure.d.ts +30 -1
- package/types/apps/src/contracts/graphql.d.ts +40 -2
- package/types/apps/src/contracts/help-text.d.ts +31 -0
- package/types/apps/src/contracts/host.d.ts +1493 -20
- package/types/apps/src/contracts/icons.d.ts +28 -0
- package/types/apps/src/contracts/live.d.ts +2 -0
- package/types/apps/src/contracts/mcp.d.ts +81 -20
- package/types/apps/src/contracts/network.d.ts +120 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
- package/types/apps/src/contracts/openapi-document.d.ts +1 -1
- package/types/apps/src/contracts/openapi.d.ts +40 -8
- package/types/apps/src/contracts/operations.d.ts +14 -7
- package/types/apps/src/contracts/placement.d.ts +102 -0
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +513 -15
- package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
- package/types/apps/src/contracts/protocols/11.d.ts +1149 -0
- package/types/apps/src/contracts/protocols/12.d.ts +3310 -0
- package/types/apps/src/contracts/protocols/13.d.ts +6001 -0
- package/types/apps/src/contracts/protocols/2.d.ts +9 -8
- package/types/apps/src/contracts/protocols/3.d.ts +73 -15
- package/types/apps/src/contracts/protocols/4.d.ts +22 -15
- package/types/apps/src/contracts/protocols/5.d.ts +37 -11
- package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
- package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
- package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
- package/types/apps/src/contracts/protocols/current.d.ts +7114 -0
- package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +56 -0
- package/types/apps/src/contracts/router.d.ts +2 -1
- package/types/apps/src/contracts/schedules.d.ts +7 -1
- package/types/apps/src/contracts/schema.d.ts +21 -0
- package/types/apps/src/contracts/shared-catalog.d.ts +11 -0
- package/types/apps/src/contracts/skills.d.ts +50 -13
- package/types/apps/src/contracts/sql.d.ts +63 -0
- package/types/apps/src/contracts/ui.d.ts +70 -30
- package/types/apps/src/contracts/webhooks.d.ts +24 -7
- package/types/apps/src/contracts/workflows.d.ts +56 -34
- package/types/apps/src/facet.d.ts +4 -5
- package/types/apps/src/host.d.ts +5 -0
- package/types/apps/src/implementation/account-router.d.ts +20 -3
- package/types/apps/src/implementation/app.d.ts +41 -14
- package/types/apps/src/implementation/authoring.d.ts +25 -5
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/cache.d.ts +29 -2
- package/types/apps/src/implementation/catalog-cache.d.ts +35 -4
- package/types/apps/src/implementation/elicitation.d.ts +16 -13
- package/types/apps/src/implementation/events.d.ts +64 -0
- package/types/apps/src/implementation/failure-detail.d.ts +28 -5
- package/types/apps/src/implementation/graphql-catalog.d.ts +3 -3
- package/types/apps/src/implementation/graphql.d.ts +4 -3
- package/types/apps/src/implementation/help-text.d.ts +5 -0
- package/types/apps/src/implementation/input-problems.d.ts +6 -2
- package/types/apps/src/implementation/invocation-timing.d.ts +18 -0
- package/types/apps/src/implementation/live.d.ts +2 -2
- package/types/apps/src/implementation/mcp-call.d.ts +6 -5
- package/types/apps/src/implementation/mcp-catalog.d.ts +6 -4
- package/types/apps/src/implementation/mcp-client.d.ts +17 -9
- package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
- package/types/apps/src/implementation/mcp.d.ts +20 -9
- package/types/apps/src/implementation/network.d.ts +16 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +38 -7
- package/types/apps/src/implementation/openapi-document.d.ts +50 -20
- package/types/apps/src/implementation/openapi-names.d.ts +9 -4
- package/types/apps/src/implementation/openapi-request.d.ts +10 -2
- package/types/apps/src/implementation/openapi-source.d.ts +23 -1
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +58 -7
- package/types/apps/src/implementation/optimistic.d.ts +1 -1
- package/types/apps/src/implementation/placement.d.ts +60 -0
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -0
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +20 -4
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +22 -97
- package/types/apps/src/implementation/router.d.ts +26 -6
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schedules.d.ts +39 -8
- package/types/apps/src/implementation/schema.d.ts +125 -17
- package/types/apps/src/implementation/skills.d.ts +18 -24
- package/types/apps/src/implementation/sql.d.ts +71 -0
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +1 -1
- package/types/apps/src/implementation/ui-client.d.ts +3 -3
- package/types/apps/src/implementation/ui-document.d.ts +5 -0
- package/types/apps/src/implementation/ui-errors.d.ts +1 -1
- package/types/apps/src/implementation/ui-serving.d.ts +38 -12
- package/types/apps/src/implementation/upstream-error.d.ts +17 -0
- package/types/apps/src/implementation/webhooks.d.ts +15 -6
- package/types/apps/src/implementation/workflow-context.d.ts +6 -2
- package/types/apps/src/implementation/workflows.d.ts +11 -4
- package/types/apps/src/index.d.ts +67 -17
- package/types/apps/src/mcp.d.ts +20 -1
- package/types/apps/src/openapi.d.ts +22 -1
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +10 -8
- package/types/apps/src/ui-serving.d.ts +1 -2
- package/types/telemetry/src/app-records.d.ts +42 -0
- package/types/telemetry/src/browser-operations.d.ts +2 -2
- package/types/telemetry/src/browser.d.ts +8 -3
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/telemetry/src/index.d.ts +3 -2
- package/types/telemetry/src/keepalive.d.ts +36 -0
- package/types/telemetry/src/layer.d.ts +10 -4
- package/types/telemetry/src/measurements.d.ts +6 -2
- package/types/telemetry/src/ownership.d.ts +60 -0
- package/types/telemetry/src/recorded-failure.d.ts +29 -0
- package/types/telemetry/src/relay.d.ts +25 -7
- package/types/telemetry/src/span-attributes.d.ts +22 -3
- package/types/telemetry/src/transport.d.ts +8 -1
- package/types/utils/src/api-error.d.ts +55 -0
- package/types/utils/src/connection-failure.d.ts +33 -0
- package/types/utils/src/legacy-keys.d.ts +20 -0
- package/types/utils/src/random-uuid.d.ts +6 -0
- package/types/utils/src/recorded-message.d.ts +18 -0
- package/types/utils/src/schema-definitions.d.ts +13 -0
- package/types/utils/src/user-facing-error.d.ts +83 -0
- package/js/chunk-27F7W2LG.js +0 -34
- package/js/chunk-4ASNKGCV.js +0 -242
- package/js/chunk-4DWF4ZWI.js +0 -1280
- package/js/chunk-57RKNWL2.js +0 -75
- package/js/chunk-6HSH75OI.js +0 -2688
- package/js/chunk-G4FT53I7.js +0 -224
- package/js/chunk-MKWZPDR6.js +0 -63
- package/js/chunk-N7YDVXYJ.js +0 -186
- package/js/chunk-NKLWZJLE.js +0 -172
- package/js/chunk-PJJ24GU7.js +0 -877
- package/js/chunk-PZB6T6KU.js +0 -19
- package/js/chunk-R3EV5FTO.js +0 -97
- package/js/chunk-S73JGVR5.js +0 -507
- package/js/chunk-TG6DOCRO.js +0 -299
- package/js/chunk-YPKG2QO5.js +0 -209
- package/js/chunk-ZQINWV4W.js +0 -630
- package/js/mcp/stdio.js +0 -128
- package/types/app-data/src/implementation/cursor.d.ts +0 -10
- package/types/app-data/src/implementation/index-key.d.ts +0 -7
- package/types/app-data/src/implementation/promise.d.ts +0 -68
- package/types/app-data/src/implementation/range.d.ts +0 -8
- package/types/app-data/src/implementation/schema.d.ts +0 -18
- package/types/app-data/src/implementation/sqlite.d.ts +0 -11
- package/types/app-data/src/index.d.ts +0 -4
- package/types/apps/src/contracts/storage.d.ts +0 -68
- package/types/apps/src/implementation/mcp-stdio.d.ts +0 -4
- package/types/apps/src/implementation/storage.d.ts +0 -15
- package/types/apps/src/implementation/ui-watch.d.ts +0 -2
- package/types/apps/src/mcp-stdio.d.ts +0 -5
|
@@ -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,60 +21,76 @@ 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-
|
|
23
|
-
import {
|
|
24
|
-
JsonValue
|
|
25
|
-
} from "./chunk-27F7W2LG.js";
|
|
29
|
+
} from "./chunk-MB6L5YZE.js";
|
|
26
30
|
import {
|
|
27
31
|
Cause,
|
|
32
|
+
CurrentRedactedNames,
|
|
33
|
+
CurrentRedactedNames2,
|
|
28
34
|
Defect,
|
|
29
35
|
Forbidden,
|
|
30
36
|
InvalidValue,
|
|
31
37
|
Literal,
|
|
32
38
|
Never,
|
|
39
|
+
Never2,
|
|
40
|
+
NonEmptyArray,
|
|
41
|
+
Objects,
|
|
42
|
+
PropertySignature,
|
|
33
43
|
RecordFromUrlParams,
|
|
34
|
-
|
|
44
|
+
SchemaError,
|
|
35
45
|
Service,
|
|
36
46
|
String as String2,
|
|
37
47
|
Struct,
|
|
38
48
|
TaggedClass,
|
|
39
49
|
TaggedError,
|
|
50
|
+
Transformation,
|
|
40
51
|
Uint8Array as Uint8Array2,
|
|
41
52
|
Undefined,
|
|
42
53
|
UndefinedOr,
|
|
43
54
|
Union,
|
|
55
|
+
Union2,
|
|
44
56
|
Unknown,
|
|
45
57
|
UnknownFromJsonString,
|
|
46
58
|
Void,
|
|
47
59
|
add,
|
|
60
|
+
all,
|
|
61
|
+
applyToSelfOrLastLinkEncodingIdempotent,
|
|
48
62
|
as,
|
|
49
63
|
assignProperty,
|
|
50
64
|
brand,
|
|
51
65
|
catchCause,
|
|
66
|
+
catchIf,
|
|
52
67
|
combine2 as combine,
|
|
53
68
|
constVoid,
|
|
54
69
|
context,
|
|
55
70
|
declare,
|
|
56
71
|
decode2 as decode,
|
|
57
|
-
decodeEffect,
|
|
58
72
|
decodeText,
|
|
59
73
|
decodeTo,
|
|
74
|
+
decodeTo2,
|
|
60
75
|
decodeUnknownEffect2 as decodeUnknownEffect,
|
|
61
|
-
|
|
76
|
+
die,
|
|
77
|
+
done,
|
|
78
|
+
empty,
|
|
62
79
|
empty6 as empty2,
|
|
63
80
|
encodeSync,
|
|
64
81
|
encodeUnknownEffect2 as encodeUnknownEffect,
|
|
65
82
|
ensure,
|
|
83
|
+
escape,
|
|
66
84
|
fail,
|
|
67
85
|
fail2,
|
|
68
86
|
fail4 as fail3,
|
|
69
87
|
failCause2 as failCause,
|
|
88
|
+
filter,
|
|
70
89
|
flatMap2 as flatMap,
|
|
71
90
|
fnUntraced,
|
|
72
91
|
fromInput3 as fromInput,
|
|
92
|
+
fromInputUnsafe,
|
|
93
|
+
fromInputUnsafe2,
|
|
73
94
|
fromJsonString,
|
|
74
95
|
fromTransform,
|
|
75
96
|
gen,
|
|
@@ -77,32 +98,50 @@ import {
|
|
|
77
98
|
getOrUndefined2 as getOrUndefined,
|
|
78
99
|
hasProperty,
|
|
79
100
|
identity,
|
|
101
|
+
ignore,
|
|
80
102
|
instanceOf,
|
|
81
103
|
isArrayNonEmpty,
|
|
82
104
|
isCause,
|
|
83
105
|
isLiteral,
|
|
106
|
+
isNotUndefined,
|
|
84
107
|
isNull,
|
|
85
108
|
isObject,
|
|
86
109
|
isObjects,
|
|
110
|
+
isOptional,
|
|
111
|
+
isReadonlyArrayNonEmpty,
|
|
87
112
|
isSchema,
|
|
88
113
|
isStream,
|
|
89
114
|
isSuspend,
|
|
90
115
|
isUnion,
|
|
91
116
|
isVoid,
|
|
92
|
-
|
|
117
|
+
make3 as make,
|
|
93
118
|
map2 as map,
|
|
94
119
|
map3 as map2,
|
|
95
120
|
map4 as map3,
|
|
96
|
-
|
|
121
|
+
map5 as map4,
|
|
122
|
+
map6 as map5,
|
|
123
|
+
map8 as map6,
|
|
124
|
+
mapArrayEffect,
|
|
125
|
+
mapEffect,
|
|
126
|
+
mapError,
|
|
127
|
+
mapError3 as mapError2,
|
|
128
|
+
mapOrSame,
|
|
129
|
+
matchEffect,
|
|
130
|
+
mebibytes,
|
|
97
131
|
memoize,
|
|
98
132
|
merge,
|
|
99
133
|
millis,
|
|
134
|
+
of,
|
|
135
|
+
onError,
|
|
100
136
|
optional,
|
|
137
|
+
passthrough2 as passthrough,
|
|
101
138
|
pipeArguments,
|
|
102
139
|
pipeThroughChannel,
|
|
103
140
|
pipeTo,
|
|
104
|
-
|
|
141
|
+
provideContext,
|
|
142
|
+
replaceContext,
|
|
105
143
|
resolveAt,
|
|
144
|
+
scoped,
|
|
106
145
|
succeed,
|
|
107
146
|
succeed4 as succeed2,
|
|
108
147
|
suspend,
|
|
@@ -111,47 +150,23 @@ import {
|
|
|
111
150
|
toCodecJson,
|
|
112
151
|
toCodecStringTree,
|
|
113
152
|
toEncoded,
|
|
114
|
-
|
|
153
|
+
toNumberUnsafe,
|
|
115
154
|
toString,
|
|
116
155
|
toType,
|
|
117
156
|
transform,
|
|
118
157
|
transformEffect,
|
|
158
|
+
transformOptional,
|
|
119
159
|
transformPull,
|
|
160
|
+
uninterruptibleMask,
|
|
161
|
+
unwrap2 as unwrap,
|
|
162
|
+
updateService,
|
|
120
163
|
void_2 as void_
|
|
121
|
-
} from "./chunk-
|
|
164
|
+
} from "./chunk-YFSOSNF3.js";
|
|
122
165
|
import {
|
|
123
166
|
__export
|
|
124
167
|
} from "./chunk-CZ7CSFO4.js";
|
|
125
168
|
|
|
126
|
-
// ../../node_modules/.bun/effect@
|
|
127
|
-
var HttpApi_exports = {};
|
|
128
|
-
__export(HttpApi_exports, {
|
|
129
|
-
AdditionalSchemas: () => AdditionalSchemas,
|
|
130
|
-
ParseOptions: () => ParseOptions,
|
|
131
|
-
isHttpApi: () => isHttpApi,
|
|
132
|
-
make: () => make4,
|
|
133
|
-
reflect: () => reflect
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/httpapi/HttpApiEndpoint.js
|
|
137
|
-
var HttpApiEndpoint_exports = {};
|
|
138
|
-
__export(HttpApiEndpoint_exports, {
|
|
139
|
-
delete: () => del,
|
|
140
|
-
get: () => get2,
|
|
141
|
-
getErrorSchemas: () => getErrorSchemas,
|
|
142
|
-
getPayloadSchemas: () => getPayloadSchemas,
|
|
143
|
-
getSuccessSchemas: () => getSuccessSchemas,
|
|
144
|
-
head: () => head,
|
|
145
|
-
isHttpApiEndpoint: () => isHttpApiEndpoint,
|
|
146
|
-
make: () => make3,
|
|
147
|
-
options: () => options,
|
|
148
|
-
patch: () => patch,
|
|
149
|
-
post: () => post,
|
|
150
|
-
put: () => put,
|
|
151
|
-
query: () => query
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/httpapi/HttpApiSchema.js
|
|
169
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/HttpApiSchema.js
|
|
155
170
|
var HttpApiSchema_exports = {};
|
|
156
171
|
__export(HttpApiSchema_exports, {
|
|
157
172
|
Accepted: () => Accepted,
|
|
@@ -160,8 +175,10 @@ __export(HttpApiSchema_exports, {
|
|
|
160
175
|
MultipartStreamTypeId: () => MultipartStreamTypeId,
|
|
161
176
|
MultipartTypeId: () => MultipartTypeId,
|
|
162
177
|
NoContent: () => NoContent,
|
|
178
|
+
StreamNdjson: () => StreamNdjson,
|
|
163
179
|
StreamSse: () => StreamSse,
|
|
164
180
|
StreamUint8Array: () => StreamUint8Array,
|
|
181
|
+
Upgrade: () => Upgrade,
|
|
165
182
|
WithHeaders: () => WithHeaders,
|
|
166
183
|
WithHeadersTypeId: () => WithHeadersTypeId,
|
|
167
184
|
WithHeadersValueTypeId: () => WithHeadersValueTypeId,
|
|
@@ -170,9 +187,11 @@ __export(HttpApiSchema_exports, {
|
|
|
170
187
|
asMultipart: () => asMultipart,
|
|
171
188
|
asMultipartStream: () => asMultipartStream,
|
|
172
189
|
asNoContent: () => asNoContent,
|
|
190
|
+
asProblem: () => asProblem,
|
|
173
191
|
asText: () => asText,
|
|
174
192
|
asUint8Array: () => asUint8Array,
|
|
175
193
|
encodeToWithHeaders: () => encodeToWithHeaders,
|
|
194
|
+
getEncodeToWithHeadersParts: () => getEncodeToWithHeadersParts,
|
|
176
195
|
getPayloadEncoding: () => getPayloadEncoding,
|
|
177
196
|
getResponseEncoding: () => getResponseEncoding,
|
|
178
197
|
getResponseEncodingSchema: () => getResponseEncodingSchema,
|
|
@@ -182,17 +201,20 @@ __export(HttpApiSchema_exports, {
|
|
|
182
201
|
getStatusSuccessSchema: () => getStatusSuccessSchema,
|
|
183
202
|
getWithHeadersAnnotation: () => getWithHeadersAnnotation,
|
|
184
203
|
isNoContent: () => isNoContent,
|
|
204
|
+
isStreamNdjson: () => isStreamNdjson,
|
|
185
205
|
isStreamSchema: () => isStreamSchema,
|
|
186
206
|
isStreamSse: () => isStreamSse,
|
|
187
207
|
isStreamUint8Array: () => isStreamUint8Array,
|
|
208
|
+
isUpgrade: () => isUpgrade,
|
|
188
209
|
isWithHeaders: () => isWithHeaders,
|
|
189
210
|
isWithHeadersValue: () => isWithHeadersValue,
|
|
211
|
+
rebuildUpgrade: () => rebuildUpgrade,
|
|
190
212
|
rebuildWithHeaders: () => rebuildWithHeaders,
|
|
191
213
|
status: () => status,
|
|
192
214
|
withHeaders: () => withHeaders
|
|
193
215
|
});
|
|
194
216
|
|
|
195
|
-
// ../../node_modules/.bun/effect@
|
|
217
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/encoding/Sse.js
|
|
196
218
|
var SseErrorTypeId = "~effect/encoding/Sse/SseError";
|
|
197
219
|
var EventTooLarge = class extends (/* @__PURE__ */ TaggedError("EventTooLarge")) {
|
|
198
220
|
get message() {
|
|
@@ -203,12 +225,14 @@ var SseError = class extends (/* @__PURE__ */ TaggedError("SseError")) {
|
|
|
203
225
|
/**
|
|
204
226
|
* Marks this value as an SSE decoding error.
|
|
205
227
|
*
|
|
228
|
+
* @stability unstable
|
|
206
229
|
* @since 4.0.0
|
|
207
230
|
*/
|
|
208
231
|
[SseErrorTypeId] = SseErrorTypeId;
|
|
209
232
|
/**
|
|
210
233
|
* Delegates the public message to the underlying SSE error reason.
|
|
211
234
|
*
|
|
235
|
+
* @stability unstable
|
|
212
236
|
* @since 4.0.0
|
|
213
237
|
*/
|
|
214
238
|
get message() {
|
|
@@ -246,14 +270,15 @@ var decode2 = (options2) => fromTransform((upstream, _scope) => sync(() => {
|
|
|
246
270
|
return flatMap(pump, loop);
|
|
247
271
|
});
|
|
248
272
|
}));
|
|
249
|
-
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)());
|
|
250
274
|
function makeParser(onParse, options2) {
|
|
251
275
|
const maxEventSize = options2?.maxEventSize ?? defaultMaxEventSize;
|
|
276
|
+
const dispatchEmptyNamedEvents = options2?.dispatchEmptyNamedEvents === true;
|
|
252
277
|
let isFirstChunk;
|
|
253
|
-
let
|
|
254
|
-
let
|
|
255
|
-
let startingFieldLength;
|
|
278
|
+
let pending;
|
|
279
|
+
let pendingLength;
|
|
256
280
|
let discardTrailingNewline;
|
|
281
|
+
let generation = 0;
|
|
257
282
|
let lastEventId;
|
|
258
283
|
let eventName;
|
|
259
284
|
let data;
|
|
@@ -263,61 +288,58 @@ function makeParser(onParse, options2) {
|
|
|
263
288
|
reset
|
|
264
289
|
};
|
|
265
290
|
function reset() {
|
|
291
|
+
generation++;
|
|
266
292
|
isFirstChunk = true;
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
startingFieldLength = -1;
|
|
293
|
+
pending = [];
|
|
294
|
+
pendingLength = 0;
|
|
270
295
|
discardTrailingNewline = false;
|
|
271
296
|
lastEventId = void 0;
|
|
272
297
|
eventName = void 0;
|
|
273
298
|
data = "";
|
|
274
299
|
}
|
|
275
300
|
function feed(chunk) {
|
|
276
|
-
|
|
277
|
-
if (isFirstChunk &&
|
|
278
|
-
|
|
301
|
+
if (chunk.length === 0) return;
|
|
302
|
+
if (isFirstChunk && chunk.startsWith(BOM)) {
|
|
303
|
+
chunk = chunk.slice(BOM.length);
|
|
279
304
|
}
|
|
280
305
|
isFirstChunk = false;
|
|
281
|
-
const length =
|
|
306
|
+
const length = chunk.length;
|
|
307
|
+
const currentGeneration = generation;
|
|
282
308
|
let position = 0;
|
|
283
309
|
while (position < length) {
|
|
284
310
|
if (discardTrailingNewline) {
|
|
285
|
-
|
|
311
|
+
discardTrailingNewline = false;
|
|
312
|
+
if (chunk.charCodeAt(position) === LF) {
|
|
286
313
|
++position;
|
|
314
|
+
continue;
|
|
287
315
|
}
|
|
288
|
-
discardTrailingNewline = false;
|
|
289
316
|
}
|
|
290
|
-
let
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (character === ":" && fieldLength < 0) {
|
|
296
|
-
fieldLength = index - position;
|
|
297
|
-
} else if (character === "\r") {
|
|
298
|
-
discardTrailingNewline = true;
|
|
299
|
-
lineLength = index - position;
|
|
300
|
-
} else if (character === "\n") {
|
|
301
|
-
lineLength = index - position;
|
|
302
|
-
}
|
|
317
|
+
let lineEnd = position;
|
|
318
|
+
while (lineEnd < length) {
|
|
319
|
+
const code = chunk.charCodeAt(lineEnd);
|
|
320
|
+
if (code === CR || code === LF) break;
|
|
321
|
+
++lineEnd;
|
|
303
322
|
}
|
|
304
|
-
if (
|
|
305
|
-
|
|
306
|
-
|
|
323
|
+
if (lineEnd === length) {
|
|
324
|
+
pending.push(chunk.slice(position));
|
|
325
|
+
pendingLength += length - position;
|
|
307
326
|
break;
|
|
308
|
-
} else {
|
|
309
|
-
startingPosition = 0;
|
|
310
|
-
startingFieldLength = -1;
|
|
311
327
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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;
|
|
319
341
|
}
|
|
320
|
-
if (
|
|
342
|
+
if (pendingLength + data.length > maxEventSize) {
|
|
321
343
|
const error = new SseError({
|
|
322
344
|
reason: new EventTooLarge({
|
|
323
345
|
maxEventSize
|
|
@@ -327,37 +349,33 @@ function makeParser(onParse, options2) {
|
|
|
327
349
|
return error;
|
|
328
350
|
}
|
|
329
351
|
}
|
|
330
|
-
function
|
|
331
|
-
if (
|
|
332
|
-
|
|
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) {
|
|
333
360
|
onParse({
|
|
334
361
|
_tag: "Event",
|
|
335
362
|
id: lastEventId,
|
|
336
|
-
event
|
|
337
|
-
data:
|
|
363
|
+
event,
|
|
364
|
+
data: eventData.slice(0, -1)
|
|
338
365
|
// remove trailing newline
|
|
339
366
|
});
|
|
340
|
-
data = "";
|
|
341
367
|
}
|
|
342
|
-
eventName = void 0;
|
|
343
368
|
return;
|
|
344
369
|
}
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
let
|
|
348
|
-
if (
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
step = fieldLength + 2;
|
|
352
|
-
} else {
|
|
353
|
-
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);
|
|
354
376
|
}
|
|
355
|
-
const position = index + step;
|
|
356
|
-
const valueLength = lineLength - step;
|
|
357
|
-
const value = lineBuffer.slice(position, position + valueLength).toString();
|
|
358
377
|
if (field === "data") {
|
|
359
|
-
data += value
|
|
360
|
-
` : "\n";
|
|
378
|
+
data += value + "\n";
|
|
361
379
|
} else if (field === "event") {
|
|
362
380
|
eventName = value;
|
|
363
381
|
} else if (field === "id" && !value.includes("\0")) {
|
|
@@ -372,6 +390,9 @@ function makeParser(onParse, options2) {
|
|
|
372
390
|
}
|
|
373
391
|
}
|
|
374
392
|
var BOM = "\uFEFF";
|
|
393
|
+
var LF = 10;
|
|
394
|
+
var CR = 13;
|
|
395
|
+
var SPACE = 32;
|
|
375
396
|
var EventEncoded = /* @__PURE__ */ Struct({
|
|
376
397
|
id: /* @__PURE__ */ optional(String2),
|
|
377
398
|
event: String2,
|
|
@@ -404,12 +425,14 @@ var Retry = class _Retry extends (/* @__PURE__ */ TaggedClass("Retry")) {
|
|
|
404
425
|
/**
|
|
405
426
|
* Marks this value as an SSE retry directive for runtime guards.
|
|
406
427
|
*
|
|
428
|
+
* @stability unstable
|
|
407
429
|
* @since 4.0.0
|
|
408
430
|
*/
|
|
409
431
|
[RetryTypeId] = RetryTypeId;
|
|
410
432
|
/**
|
|
411
433
|
* Returns `true` when the value is an SSE retry directive.
|
|
412
434
|
*
|
|
435
|
+
* @stability unstable
|
|
413
436
|
* @since 4.0.0
|
|
414
437
|
*/
|
|
415
438
|
static is(u) {
|
|
@@ -418,6 +441,7 @@ var Retry = class _Retry extends (/* @__PURE__ */ TaggedClass("Retry")) {
|
|
|
418
441
|
/**
|
|
419
442
|
* Separates SSE retry directives from regular event values.
|
|
420
443
|
*
|
|
444
|
+
* @stability unstable
|
|
421
445
|
* @since 4.0.0
|
|
422
446
|
*/
|
|
423
447
|
static filter(u) {
|
|
@@ -425,11 +449,20 @@ var Retry = class _Retry extends (/* @__PURE__ */ TaggedClass("Retry")) {
|
|
|
425
449
|
}
|
|
426
450
|
};
|
|
427
451
|
|
|
428
|
-
// ../../node_modules/.bun/effect@
|
|
429
|
-
|
|
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
|
|
460
|
+
var StreamSchemaTypeId = "~effect/http-api/HttpApiSchema/Stream";
|
|
430
461
|
function status(code) {
|
|
431
462
|
const statusCode = typeof code === "string" ? fromLiteral(code) : code;
|
|
432
|
-
return (self) => self.
|
|
463
|
+
return (self) => findHttpApiStatusAnnotation(self.ast) === void 0 ? self.annotateKey({
|
|
464
|
+
httpApiStatus: statusCode
|
|
465
|
+
}) : self.annotate({
|
|
433
466
|
httpApiStatus: statusCode
|
|
434
467
|
});
|
|
435
468
|
}
|
|
@@ -439,17 +472,41 @@ var Created = /* @__PURE__ */ Empty(201);
|
|
|
439
472
|
var Accepted = /* @__PURE__ */ Empty(202);
|
|
440
473
|
function asNoContent(options2) {
|
|
441
474
|
return (self) => {
|
|
442
|
-
return Void.pipe(
|
|
475
|
+
return Void.pipe(decodeTo2(toType(self), transform({
|
|
443
476
|
decode: options2.decode,
|
|
444
477
|
encode: constVoid
|
|
445
478
|
})));
|
|
446
479
|
};
|
|
447
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
|
+
}
|
|
448
504
|
var streamSchema = /* @__PURE__ */ declare(isStream);
|
|
505
|
+
var defaultMaxElementBytes = /* @__PURE__ */ mebibytes(1);
|
|
449
506
|
var StreamSse = (options2) => {
|
|
450
507
|
const events = options2.events ?? (options2.data === void 0 ? void 0 : Struct({
|
|
451
508
|
...EventEncoded.fields,
|
|
452
|
-
data: fromJsonString(options2.data)
|
|
509
|
+
data: fromJsonString(toCodecJson(options2.data))
|
|
453
510
|
}));
|
|
454
511
|
if (events === void 0) {
|
|
455
512
|
throw new Error("StreamSse requires either an events schema or a data schema");
|
|
@@ -459,36 +516,90 @@ var StreamSse = (options2) => {
|
|
|
459
516
|
_tag: "StreamSse",
|
|
460
517
|
mode: "sse",
|
|
461
518
|
sseMode: options2.events === void 0 ? "data" : "events",
|
|
462
|
-
|
|
519
|
+
...streamContentTypes(options2.contentType, "sse"),
|
|
463
520
|
events,
|
|
464
|
-
error: options2.error ??
|
|
521
|
+
error: options2.error ?? Never2,
|
|
522
|
+
keepAlive: options2.keepAlive === void 0 ? void 0 : fromInputUnsafe(options2.keepAlive)
|
|
465
523
|
});
|
|
466
524
|
};
|
|
467
525
|
var StreamUint8Array = (options2) => make(streamSchema.ast, {
|
|
468
526
|
[StreamSchemaTypeId]: StreamSchemaTypeId,
|
|
469
527
|
_tag: "StreamUint8Array",
|
|
470
528
|
mode: "uint8array",
|
|
471
|
-
|
|
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)
|
|
472
540
|
});
|
|
473
541
|
var isStreamSchema = (u) => isSchema(u) && hasProperty(u, StreamSchemaTypeId);
|
|
474
542
|
var isStreamSse = (u) => isStreamSchema(u) && u._tag === "StreamSse";
|
|
475
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
|
+
}
|
|
476
582
|
function defaultStreamContentType(mode) {
|
|
477
583
|
switch (mode) {
|
|
478
584
|
case "sse":
|
|
479
585
|
return "text/event-stream";
|
|
480
586
|
case "uint8array":
|
|
481
587
|
return "application/octet-stream";
|
|
588
|
+
case "ndjson":
|
|
589
|
+
return "application/x-ndjson";
|
|
482
590
|
}
|
|
483
591
|
}
|
|
484
|
-
var WithHeadersTypeId = "~effect/
|
|
485
|
-
var WithHeadersValueTypeId = "~effect/
|
|
592
|
+
var WithHeadersTypeId = "~effect/http-api/HttpApiSchema/WithHeaders";
|
|
593
|
+
var WithHeadersValueTypeId = "~effect/http-api/HttpApiSchema/WithHeadersValue";
|
|
486
594
|
var isWithHeadersValue = (u) => hasProperty(u, WithHeadersValueTypeId);
|
|
487
595
|
var withHeadersValueSchema = /* @__PURE__ */ declare(isWithHeadersValue);
|
|
488
596
|
function WithHeaders(schema, headers) {
|
|
489
597
|
if (isWithHeaders(schema)) {
|
|
490
598
|
throw new Error("WithHeaders schemas cannot be nested");
|
|
491
599
|
}
|
|
600
|
+
if (isUpgrade(schema)) {
|
|
601
|
+
throw new Error("WithHeaders cannot wrap an upgrade");
|
|
602
|
+
}
|
|
492
603
|
return make(withHeadersValueSchema.ast, {
|
|
493
604
|
[WithHeadersTypeId]: WithHeadersTypeId,
|
|
494
605
|
schema,
|
|
@@ -511,24 +622,29 @@ function rebuildWithHeaders(self, schema, headers) {
|
|
|
511
622
|
function encodeToWithHeaders(options2, transformation) {
|
|
512
623
|
return (self) => {
|
|
513
624
|
const body = options2.body;
|
|
625
|
+
if (isUpgrade(body)) {
|
|
626
|
+
throw new Error("encodeToWithHeaders cannot wrap an upgrade");
|
|
627
|
+
}
|
|
514
628
|
const headers = Struct(options2.headers);
|
|
515
629
|
const status2 = resolveHttpApiStatus(body.ast);
|
|
516
630
|
const encoding = resolveHttpApiEncoding(body.ast);
|
|
517
631
|
return Struct({
|
|
518
632
|
body,
|
|
519
633
|
headers
|
|
520
|
-
}).pipe(
|
|
634
|
+
}).pipe(decodeTo2(toType(self), transform(transformation))).annotate({
|
|
521
635
|
"~httpApiWithHeaders": {
|
|
522
636
|
body,
|
|
523
637
|
headers,
|
|
524
|
-
|
|
638
|
+
bodyCodec: body,
|
|
639
|
+
headersCodec: headers,
|
|
640
|
+
transformation
|
|
525
641
|
},
|
|
526
642
|
httpApiStatus: status2,
|
|
527
643
|
"~httpApiEncoding": encoding
|
|
528
644
|
});
|
|
529
645
|
};
|
|
530
646
|
}
|
|
531
|
-
var MultipartTypeId = "~effect/
|
|
647
|
+
var MultipartTypeId = "~effect/http-api/HttpApiSchema/Multipart";
|
|
532
648
|
function asMultipart(options2) {
|
|
533
649
|
return (self) => self.pipe(brand(MultipartTypeId)).annotate({
|
|
534
650
|
"~httpApiEncoding": {
|
|
@@ -539,7 +655,7 @@ function asMultipart(options2) {
|
|
|
539
655
|
}
|
|
540
656
|
});
|
|
541
657
|
}
|
|
542
|
-
var MultipartStreamTypeId = "~effect/
|
|
658
|
+
var MultipartStreamTypeId = "~effect/http-api/HttpApiSchema/MultipartStream";
|
|
543
659
|
function asMultipartStream(options2) {
|
|
544
660
|
return (self) => self.pipe(brand(MultipartStreamTypeId)).annotate({
|
|
545
661
|
"~httpApiEncoding": {
|
|
@@ -606,7 +722,32 @@ var isNoContent = (ast) => {
|
|
|
606
722
|
};
|
|
607
723
|
var resolveHttpApiEncoding = /* @__PURE__ */ resolveAt("~httpApiEncoding");
|
|
608
724
|
var getWithHeadersAnnotation = /* @__PURE__ */ resolveAt("~httpApiWithHeaders");
|
|
609
|
-
|
|
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
|
+
}
|
|
610
751
|
var defaultJsonEncoding = {
|
|
611
752
|
_tag: "Json",
|
|
612
753
|
contentType: "application/json"
|
|
@@ -655,15 +796,56 @@ function getStatusErrorSchema(schema) {
|
|
|
655
796
|
return getStatusError(schema.ast);
|
|
656
797
|
}
|
|
657
798
|
|
|
658
|
-
// ../../node_modules/.bun/effect@
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
799
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/HttpApiEndpoint.js
|
|
800
|
+
var HttpApiEndpoint_exports = {};
|
|
801
|
+
__export(HttpApiEndpoint_exports, {
|
|
802
|
+
delete: () => del,
|
|
803
|
+
get: () => get2,
|
|
804
|
+
getErrorSchemas: () => getErrorSchemas,
|
|
805
|
+
getPayloadSchemas: () => getPayloadSchemas,
|
|
806
|
+
getSuccessSchemas: () => getSuccessSchemas,
|
|
807
|
+
head: () => head,
|
|
808
|
+
isHttpApiEndpoint: () => isHttpApiEndpoint,
|
|
809
|
+
make: () => make3,
|
|
810
|
+
options: () => options,
|
|
811
|
+
patch: () => patch,
|
|
812
|
+
post: () => post,
|
|
813
|
+
put: () => put,
|
|
814
|
+
query: () => query
|
|
815
|
+
});
|
|
816
|
+
|
|
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));
|
|
663
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
|
+
});
|
|
664
846
|
|
|
665
|
-
// ../../node_modules/.bun/effect@
|
|
666
|
-
var TypeId = "~effect/
|
|
847
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/HttpApiEndpoint.js
|
|
848
|
+
var TypeId = "~effect/http-api/HttpApiEndpoint";
|
|
667
849
|
var isHttpApiEndpoint = (u) => hasProperty(u, TypeId);
|
|
668
850
|
function getPayloadSchemas(endpoint2) {
|
|
669
851
|
const result = [];
|
|
@@ -741,16 +923,17 @@ function makeProto(options2) {
|
|
|
741
923
|
}
|
|
742
924
|
var make3 = (method) => (identifier, path, options2) => {
|
|
743
925
|
const disableCodecs = options2?.disableCodecs ?? false;
|
|
744
|
-
const
|
|
926
|
+
const transformProperties = disableCodecs ? identity : toCodecHttpProperties;
|
|
927
|
+
const payload = getPayload(options2?.payload, method, disableCodecs);
|
|
745
928
|
return makeProto({
|
|
746
929
|
identifier,
|
|
747
930
|
path,
|
|
748
931
|
method,
|
|
749
|
-
params: ensureStruct(options2?.params,
|
|
750
|
-
query: ensureStruct(options2?.query,
|
|
751
|
-
headers: ensureStruct(options2?.headers,
|
|
752
|
-
payload
|
|
753
|
-
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),
|
|
754
937
|
error: getErrorResponse(options2?.error, disableCodecs),
|
|
755
938
|
annotations: empty(),
|
|
756
939
|
middlewares: /* @__PURE__ */ new Set(),
|
|
@@ -767,11 +950,41 @@ function getPayload(payload, method, disableCodecs) {
|
|
|
767
950
|
if (payload === void 0) return result;
|
|
768
951
|
const schemas = Array.isArray(payload) ? payload : isSchema(payload) ? [payload] : [Struct(payload).pipe(asFormUrlEncoded())];
|
|
769
952
|
const transform2 = disableCodecs ? identity : transformPayload;
|
|
953
|
+
let hasStream = false;
|
|
770
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
|
+
}
|
|
771
981
|
const encoding = getPayloadEncoding(schema.ast, method);
|
|
772
|
-
const
|
|
773
|
-
const existing = result.get(
|
|
982
|
+
const contentType2 = normalize(encoding.contentType);
|
|
983
|
+
const existing = result.get(contentType2);
|
|
774
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
|
+
}
|
|
775
988
|
if (existing.encoding._tag !== encoding._tag) {
|
|
776
989
|
throw new Error(`Multiple payload encodings for content-type: ${encoding.contentType}`);
|
|
777
990
|
}
|
|
@@ -780,7 +993,7 @@ function getPayload(payload, method, disableCodecs) {
|
|
|
780
993
|
}
|
|
781
994
|
existing.schemas.push(transform2(schema, method));
|
|
782
995
|
} else {
|
|
783
|
-
result.set(
|
|
996
|
+
result.set(contentType2, {
|
|
784
997
|
encoding,
|
|
785
998
|
schemas: [transform2(schema, method)]
|
|
786
999
|
});
|
|
@@ -788,18 +1001,21 @@ function getPayload(payload, method, disableCodecs) {
|
|
|
788
1001
|
}
|
|
789
1002
|
return result;
|
|
790
1003
|
}
|
|
791
|
-
var reservedStreamFailureEvent = "effect/
|
|
792
|
-
function getSuccessResponse(success, method, disableCodecs) {
|
|
1004
|
+
var reservedStreamFailureEvent = "effect/http-api/stream/failure";
|
|
1005
|
+
function getSuccessResponse(success, method, payload, disableCodecs) {
|
|
793
1006
|
if (success === void 0) return /* @__PURE__ */ new Set();
|
|
794
1007
|
const schemas = ensure(success);
|
|
795
|
-
validateSuccessResponse(schemas, method);
|
|
1008
|
+
validateSuccessResponse(schemas, method, payload);
|
|
796
1009
|
return new Set(disableCodecs ? schemas : schemas.map(transformResponseSchema));
|
|
797
1010
|
}
|
|
798
1011
|
var transformResponseSchema = /* @__PURE__ */ memoize((schema) => {
|
|
799
1012
|
if (isStreamSchema(schema)) return schema;
|
|
1013
|
+
if (isUpgrade(schema)) {
|
|
1014
|
+
return schema.headers === void 0 ? schema : rebuildUpgrade(schema.protocol, toCodecHttpProperties(schema.headers));
|
|
1015
|
+
}
|
|
800
1016
|
if (isWithHeaders(schema)) {
|
|
801
1017
|
const inner = isStreamSchema(schema.schema) ? schema.schema : applyResponseEncoding(schema.schema, getResponseEncodingSchema(schema));
|
|
802
|
-
return rebuildWithHeaders(schema, inner,
|
|
1018
|
+
return rebuildWithHeaders(schema, inner, toCodecHttpProperties(schema.headers));
|
|
803
1019
|
}
|
|
804
1020
|
return transformResponse(schema);
|
|
805
1021
|
});
|
|
@@ -811,17 +1027,44 @@ function getErrorResponse(error, disableCodecs) {
|
|
|
811
1027
|
if (isStreamSchema(body)) {
|
|
812
1028
|
throw new Error("Streaming schemas are not supported in error responses");
|
|
813
1029
|
}
|
|
1030
|
+
if (isUpgrade(body)) {
|
|
1031
|
+
throw new Error("Upgrade schemas are not supported in error responses");
|
|
1032
|
+
}
|
|
814
1033
|
}
|
|
815
1034
|
validateResponseExclusivity(schemas, getStatusErrorSchema);
|
|
816
1035
|
return new Set(disableCodecs ? schemas : schemas.map(transformResponseSchema));
|
|
817
1036
|
}
|
|
818
|
-
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
|
+
}
|
|
819
1055
|
let hasStream = false;
|
|
820
1056
|
const statuses = /* @__PURE__ */ new Map();
|
|
821
1057
|
for (const schema of schemas) {
|
|
1058
|
+
if (isUpgrade(schema)) continue;
|
|
822
1059
|
const inner = isWithHeaders(schema) ? schema.schema : schema;
|
|
823
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
|
+
}
|
|
824
1064
|
if (isStreamSchema(inner)) {
|
|
1065
|
+
if (hasUpgrade) {
|
|
1066
|
+
throw new Error("Cannot combine an upgrade with a streaming success response");
|
|
1067
|
+
}
|
|
825
1068
|
validateStreamSuccess(inner, method);
|
|
826
1069
|
if (hasStream) {
|
|
827
1070
|
throw new Error("Multiple streaming success responses are not supported");
|
|
@@ -831,8 +1074,10 @@ function validateSuccessResponse(schemas, method) {
|
|
|
831
1074
|
if (entry.noContent) {
|
|
832
1075
|
throw new Error(`Cannot combine no-content and streaming success responses for status: ${status2}`);
|
|
833
1076
|
}
|
|
834
|
-
|
|
835
|
-
|
|
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
|
+
}
|
|
836
1081
|
}
|
|
837
1082
|
statuses.set(status2, {
|
|
838
1083
|
...entry,
|
|
@@ -846,7 +1091,8 @@ function validateSuccessResponse(schemas, method) {
|
|
|
846
1091
|
throw new Error(`Cannot combine no-content and streaming success responses for status: ${status2}`);
|
|
847
1092
|
}
|
|
848
1093
|
const encoding = getResponseEncodingSchema(schema);
|
|
849
|
-
|
|
1094
|
+
const contentType2 = normalize(encoding.contentType);
|
|
1095
|
+
if (entry.stream.contentTypes.some((declared) => normalize(declared) === contentType2)) {
|
|
850
1096
|
throw new Error(`Cannot combine buffered and streaming success responses for status ${status2} and content-type: ${encoding.contentType}`);
|
|
851
1097
|
}
|
|
852
1098
|
}
|
|
@@ -875,7 +1121,7 @@ function validateResponseExclusivity(schemas, getStatus) {
|
|
|
875
1121
|
const status2 = getStatus(schema);
|
|
876
1122
|
const withHeadersAnnotation = getWithHeadersAnnotation(schema.ast);
|
|
877
1123
|
const body = isWithHeaders(schema) ? schema.schema : withHeadersAnnotation?.body ?? schema;
|
|
878
|
-
const
|
|
1124
|
+
const contentType2 = isNoContent(body.ast) ? "" : normalize(isStreamSchema(body) ? body.contentType : getResponseEncodingSchema(schema).contentType);
|
|
879
1125
|
let entry = statuses.get(status2);
|
|
880
1126
|
if (entry === void 0) {
|
|
881
1127
|
entry = {
|
|
@@ -884,16 +1130,16 @@ function validateResponseExclusivity(schemas, getStatus) {
|
|
|
884
1130
|
};
|
|
885
1131
|
statuses.set(status2, entry);
|
|
886
1132
|
}
|
|
887
|
-
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>"}`);
|
|
888
1134
|
if (isWithHeaders(schema) || withHeadersAnnotation !== void 0) {
|
|
889
1135
|
if (entry.headerContentType !== void 0) {
|
|
890
1136
|
throw new Error(`Cannot declare multiple responses with headers for status ${status2}`);
|
|
891
1137
|
}
|
|
892
|
-
if (entry.plainContentTypes.has(
|
|
893
|
-
entry.headerContentType =
|
|
1138
|
+
if (entry.plainContentTypes.has(contentType2)) throw combineError();
|
|
1139
|
+
entry.headerContentType = contentType2;
|
|
894
1140
|
} else {
|
|
895
|
-
if (entry.headerContentType ===
|
|
896
|
-
entry.plainContentTypes.add(
|
|
1141
|
+
if (entry.headerContentType === contentType2) throw combineError();
|
|
1142
|
+
entry.plainContentTypes.add(contentType2);
|
|
897
1143
|
}
|
|
898
1144
|
}
|
|
899
1145
|
}
|
|
@@ -945,14 +1191,11 @@ function transformResponse(schema) {
|
|
|
945
1191
|
if (withHeaders2 === void 0) {
|
|
946
1192
|
return applyResponseEncoding(schema, encoding);
|
|
947
1193
|
}
|
|
948
|
-
|
|
949
|
-
return Struct({
|
|
950
|
-
body: applyResponseEncoding(toEncoded2(withHeaders2.body), encoding),
|
|
951
|
-
headers
|
|
952
|
-
}).pipe(decodeTo(schema)).annotate({
|
|
1194
|
+
return schema.annotate({
|
|
953
1195
|
"~httpApiWithHeaders": {
|
|
954
1196
|
...withHeaders2,
|
|
955
|
-
|
|
1197
|
+
bodyCodec: applyResponseEncoding(withHeaders2.body, encoding),
|
|
1198
|
+
headersCodec: toCodecHttpProperties(withHeaders2.headers)
|
|
956
1199
|
}
|
|
957
1200
|
});
|
|
958
1201
|
}
|
|
@@ -968,6 +1211,7 @@ function applyResponseEncoding(schema, encoding) {
|
|
|
968
1211
|
}
|
|
969
1212
|
}
|
|
970
1213
|
function transformPayload(schema, method) {
|
|
1214
|
+
if (!hasBody(method)) return toCodecHttpProperties(schema);
|
|
971
1215
|
const encoding = getPayloadEncoding(schema.ast, method);
|
|
972
1216
|
switch (encoding._tag) {
|
|
973
1217
|
case "Json":
|
|
@@ -989,8 +1233,25 @@ var del = /* @__PURE__ */ make3("DELETE");
|
|
|
989
1233
|
var head = /* @__PURE__ */ make3("HEAD");
|
|
990
1234
|
var options = /* @__PURE__ */ make3("OPTIONS");
|
|
991
1235
|
|
|
992
|
-
// ../../node_modules/.bun/effect@
|
|
993
|
-
var
|
|
1236
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/HttpApi.js
|
|
1237
|
+
var HttpApi_exports = {};
|
|
1238
|
+
__export(HttpApi_exports, {
|
|
1239
|
+
AdditionalSchemas: () => AdditionalSchemas,
|
|
1240
|
+
ErrorParseOptions: () => ErrorParseOptions,
|
|
1241
|
+
HeadersParseOptions: () => HeadersParseOptions,
|
|
1242
|
+
ParamsParseOptions: () => ParamsParseOptions,
|
|
1243
|
+
ParseOptions: () => ParseOptions,
|
|
1244
|
+
PayloadParseOptions: () => PayloadParseOptions,
|
|
1245
|
+
QueryParseOptions: () => QueryParseOptions,
|
|
1246
|
+
RedactedNames: () => RedactedNames,
|
|
1247
|
+
SuccessParseOptions: () => SuccessParseOptions,
|
|
1248
|
+
getEndpointRedactedNames: () => getEndpointRedactedNames,
|
|
1249
|
+
getSlotParseOptions: () => getSlotParseOptions,
|
|
1250
|
+
isHttpApi: () => isHttpApi,
|
|
1251
|
+
make: () => make4,
|
|
1252
|
+
reflect: () => reflect
|
|
1253
|
+
});
|
|
1254
|
+
var TypeId2 = "~effect/http-api/HttpApi";
|
|
994
1255
|
var isHttpApi = (u) => hasProperty(u, TypeId2);
|
|
995
1256
|
var Proto2 = {
|
|
996
1257
|
[TypeId2]: TypeId2,
|
|
@@ -1094,7 +1355,7 @@ var extractResponseContent = (schemas, getStatus) => {
|
|
|
1094
1355
|
return map7;
|
|
1095
1356
|
function add2(schema) {
|
|
1096
1357
|
const body = isWithHeaders(schema) ? schema.schema : schema;
|
|
1097
|
-
if (isStreamSchema(body)) return;
|
|
1358
|
+
if (isStreamSchema(body) || isUpgrade(body)) return;
|
|
1098
1359
|
const status2 = getStatus(schema);
|
|
1099
1360
|
const schemas2 = map7.get(status2);
|
|
1100
1361
|
if (schemas2 === void 0) {
|
|
@@ -1104,29 +1365,340 @@ var extractResponseContent = (schemas, getStatus) => {
|
|
|
1104
1365
|
}
|
|
1105
1366
|
}
|
|
1106
1367
|
};
|
|
1107
|
-
var AdditionalSchemas = class extends (/* @__PURE__ */ Service()("effect/
|
|
1368
|
+
var AdditionalSchemas = class extends (/* @__PURE__ */ Service()("effect/http-api/HttpApi/AdditionalSchemas")) {
|
|
1369
|
+
};
|
|
1370
|
+
var ParseOptions = class extends (/* @__PURE__ */ Service()("effect/http-api/HttpApi/ParseOptions")) {
|
|
1371
|
+
};
|
|
1372
|
+
var ParamsParseOptions = class extends (/* @__PURE__ */ Service()("effect/http-api/HttpApi/ParamsParseOptions")) {
|
|
1373
|
+
};
|
|
1374
|
+
var QueryParseOptions = class extends (/* @__PURE__ */ Service()("effect/http-api/HttpApi/QueryParseOptions")) {
|
|
1375
|
+
};
|
|
1376
|
+
var HeadersParseOptions = class extends (/* @__PURE__ */ Service()("effect/http-api/HttpApi/HeadersParseOptions")) {
|
|
1377
|
+
};
|
|
1378
|
+
var PayloadParseOptions = class extends (/* @__PURE__ */ Service()("effect/http-api/HttpApi/PayloadParseOptions")) {
|
|
1379
|
+
};
|
|
1380
|
+
var SuccessParseOptions = class extends (/* @__PURE__ */ Service()("effect/http-api/HttpApi/SuccessParseOptions")) {
|
|
1381
|
+
};
|
|
1382
|
+
var ErrorParseOptions = class extends (/* @__PURE__ */ Service()("effect/http-api/HttpApi/ErrorParseOptions")) {
|
|
1383
|
+
};
|
|
1384
|
+
var RedactedNames = class extends (/* @__PURE__ */ Service()("effect/http-api/HttpApi/RedactedNames")) {
|
|
1385
|
+
};
|
|
1386
|
+
var getSlotParseOptions = (annotations) => {
|
|
1387
|
+
const fallback = getOrUndefined(annotations, ParseOptions);
|
|
1388
|
+
return {
|
|
1389
|
+
params: getOrUndefined(annotations, ParamsParseOptions) ?? fallback,
|
|
1390
|
+
query: getOrUndefined(annotations, QueryParseOptions) ?? fallback,
|
|
1391
|
+
headers: getOrUndefined(annotations, HeadersParseOptions) ?? fallback,
|
|
1392
|
+
payload: getOrUndefined(annotations, PayloadParseOptions) ?? fallback,
|
|
1393
|
+
success: getOrUndefined(annotations, SuccessParseOptions) ?? fallback,
|
|
1394
|
+
error: getOrUndefined(annotations, ErrorParseOptions) ?? fallback
|
|
1395
|
+
};
|
|
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
|
+
};
|
|
1414
|
+
|
|
1415
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/HttpApiGroup.js
|
|
1416
|
+
var HttpApiGroup_exports = {};
|
|
1417
|
+
__export(HttpApiGroup_exports, {
|
|
1418
|
+
isHttpApiGroup: () => isHttpApiGroup,
|
|
1419
|
+
make: () => make5
|
|
1420
|
+
});
|
|
1421
|
+
var TypeId3 = "~effect/http-api/HttpApiGroup";
|
|
1422
|
+
var isHttpApiGroup = (u) => hasProperty(u, TypeId3);
|
|
1423
|
+
var Proto3 = {
|
|
1424
|
+
[TypeId3]: TypeId3,
|
|
1425
|
+
add(...toAdd) {
|
|
1426
|
+
const endpoints = {
|
|
1427
|
+
...this.endpoints
|
|
1428
|
+
};
|
|
1429
|
+
for (const endpoint2 of toAdd) {
|
|
1430
|
+
assignProperty(endpoints, endpoint2.identifier, endpoint2);
|
|
1431
|
+
}
|
|
1432
|
+
return makeProto3({
|
|
1433
|
+
...optionsFromGroup(this),
|
|
1434
|
+
endpoints
|
|
1435
|
+
});
|
|
1436
|
+
},
|
|
1437
|
+
prefix(prefix) {
|
|
1438
|
+
return makeProto3({
|
|
1439
|
+
...optionsFromGroup(this),
|
|
1440
|
+
endpoints: map(this.endpoints, (endpoint2) => endpoint2.prefix(prefix))
|
|
1441
|
+
});
|
|
1442
|
+
},
|
|
1443
|
+
middleware(middleware) {
|
|
1444
|
+
return makeProto3({
|
|
1445
|
+
...optionsFromGroup(this),
|
|
1446
|
+
endpoints: map(this.endpoints, (endpoint2) => endpoint2.middleware(middleware))
|
|
1447
|
+
});
|
|
1448
|
+
},
|
|
1449
|
+
annotateMerge(annotations) {
|
|
1450
|
+
return makeProto3({
|
|
1451
|
+
...optionsFromGroup(this),
|
|
1452
|
+
annotations: merge(this.annotations, annotations)
|
|
1453
|
+
});
|
|
1454
|
+
},
|
|
1455
|
+
annotate(annotation, value) {
|
|
1456
|
+
return makeProto3({
|
|
1457
|
+
...optionsFromGroup(this),
|
|
1458
|
+
annotations: add(this.annotations, annotation, value)
|
|
1459
|
+
});
|
|
1460
|
+
},
|
|
1461
|
+
annotateEndpointsMerge(annotations) {
|
|
1462
|
+
return makeProto3({
|
|
1463
|
+
...optionsFromGroup(this),
|
|
1464
|
+
endpoints: map(this.endpoints, (endpoint2) => endpoint2.annotateMerge(annotations))
|
|
1465
|
+
});
|
|
1466
|
+
},
|
|
1467
|
+
annotateEndpoints(annotation, value) {
|
|
1468
|
+
return makeProto3({
|
|
1469
|
+
...optionsFromGroup(this),
|
|
1470
|
+
endpoints: map(this.endpoints, (endpoint2) => endpoint2.annotate(annotation, value))
|
|
1471
|
+
});
|
|
1472
|
+
},
|
|
1473
|
+
pipe() {
|
|
1474
|
+
return pipeArguments(this, arguments);
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1477
|
+
var optionsFromGroup = (group2) => ({
|
|
1478
|
+
identifier: group2.identifier,
|
|
1479
|
+
topLevel: group2.topLevel,
|
|
1480
|
+
endpoints: group2.endpoints,
|
|
1481
|
+
annotations: group2.annotations
|
|
1482
|
+
});
|
|
1483
|
+
var makeProto3 = (options2) => {
|
|
1484
|
+
function HttpApiGroup() {
|
|
1485
|
+
}
|
|
1486
|
+
Object.setPrototypeOf(HttpApiGroup, Proto3);
|
|
1487
|
+
HttpApiGroup.key = `effect/http-api/HttpApiGroup/${options2.identifier}`;
|
|
1488
|
+
return Object.assign(HttpApiGroup, options2);
|
|
1489
|
+
};
|
|
1490
|
+
var make5 = (identifier, options2) => makeProto3({
|
|
1491
|
+
identifier,
|
|
1492
|
+
topLevel: options2?.topLevel ?? false,
|
|
1493
|
+
endpoints: {},
|
|
1494
|
+
annotations: empty()
|
|
1495
|
+
});
|
|
1496
|
+
|
|
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;
|
|
1108
1567
|
};
|
|
1109
|
-
var
|
|
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
|
+
}
|
|
1110
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
|
+
}));
|
|
1111
1658
|
|
|
1112
|
-
// ../../node_modules/.bun/effect@
|
|
1659
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/internal/path.js
|
|
1113
1660
|
var emptyParamNames = /* @__PURE__ */ new Set();
|
|
1114
1661
|
function getParamNames(schema) {
|
|
1115
1662
|
if (schema === void 0) return emptyParamNames;
|
|
1116
1663
|
const ast = getLastEncoding(schema.ast);
|
|
1117
1664
|
return isObjects(ast) && ast.indexSignatures.length === 0 ? new Set(ast.propertySignatures.map((ps) => String(ps.name))) : void 0;
|
|
1118
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
|
+
}
|
|
1119
1686
|
|
|
1120
|
-
// ../../node_modules/.bun/effect@
|
|
1687
|
+
// ../../node_modules/.bun/effect@4.1.4/node_modules/effect/dist/http-api/HttpApiClient.js
|
|
1121
1688
|
var HttpApiClient_exports = {};
|
|
1122
1689
|
__export(HttpApiClient_exports, {
|
|
1690
|
+
UpgradedTypeId: () => UpgradedTypeId,
|
|
1691
|
+
decodeResponse: () => decodeResponse,
|
|
1123
1692
|
endpoint: () => endpoint,
|
|
1124
1693
|
group: () => group,
|
|
1125
|
-
|
|
1694
|
+
isUpgraded: () => isUpgraded,
|
|
1695
|
+
make: () => make6,
|
|
1126
1696
|
makeClient: () => makeClient,
|
|
1127
1697
|
makeWith: () => makeWith,
|
|
1128
1698
|
urlBuilder: () => urlBuilder
|
|
1129
1699
|
});
|
|
1700
|
+
var UpgradedTypeId = "~effect/http-api/HttpApiClient/Upgraded";
|
|
1701
|
+
var isUpgraded = (u) => hasProperty(u, UpgradedTypeId);
|
|
1130
1702
|
var makeClient = (api, options2) => gen(function* () {
|
|
1131
1703
|
const services = yield* context();
|
|
1132
1704
|
const httpClient = options2.httpClient.pipe(options2?.baseUrl === void 0 ? identity : mapRequest(prependUrl(options2.baseUrl.toString())));
|
|
@@ -1156,52 +1728,31 @@ var makeClient = (api, options2) => gen(function* () {
|
|
|
1156
1728
|
const {
|
|
1157
1729
|
group: group2,
|
|
1158
1730
|
endpoint: endpoint2,
|
|
1159
|
-
errors: errors2,
|
|
1160
|
-
successes,
|
|
1161
1731
|
mergedAnnotations
|
|
1162
1732
|
} = onEndpointOptions;
|
|
1163
|
-
const parseOptions =
|
|
1733
|
+
const parseOptions = getSlotParseOptions(mergedAnnotations);
|
|
1164
1734
|
const makeUrl = compilePath(endpoint2.path, endpoint2.params);
|
|
1165
|
-
const
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
const
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
for (const [status2, alternatives] of errorAlternatives.entries()) {
|
|
1176
|
-
const decode3 = makeResponseDecoder(alternatives);
|
|
1177
|
-
decodeMap[status2] = (response) => flatMap(catchCause(decode3(response), (cause) => failCause(combine(fail2(new HttpClientError({
|
|
1178
|
-
reason: new StatusCodeError({
|
|
1179
|
-
request: response.request,
|
|
1180
|
-
response
|
|
1181
|
-
})
|
|
1182
|
-
})), cause))), fail3);
|
|
1183
|
-
}
|
|
1184
|
-
const successAlternatives = /* @__PURE__ */ new Map();
|
|
1185
|
-
for (const [status2, schemas] of successes.entries()) {
|
|
1186
|
-
const grouped = groupSchemasByContentType(schemas);
|
|
1187
|
-
for (const [contentType, schemas2] of grouped.entries()) {
|
|
1188
|
-
addResponseAlternative(successAlternatives, status2, contentType, schemasToResponse(schemas2, parseOptions));
|
|
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);
|
|
1189
1745
|
}
|
|
1190
1746
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
const encodeUnknownEffect2 = (schema) => encodeUnknownEffect(schema, parseOptions);
|
|
1199
|
-
const encodeParams = map4(endpoint2.params, encodeUnknownEffect2);
|
|
1200
|
-
const payloadSchemas = getPayloadSchemas(endpoint2);
|
|
1201
|
-
const encodePayload = isArrayNonEmpty(payloadSchemas) ? hasBody(endpoint2.method) ? encodeUnknownEffect2(getEncodePayloadSchema(payloadSchemas, endpoint2.method)) : encodeUnknownEffect2(Union(payloadSchemas)) : void 0;
|
|
1202
|
-
const encodeHeaders = map4(endpoint2.headers, encodeUnknownEffect2);
|
|
1203
|
-
const encodeQuery = map4(endpoint2.query, encodeUnknownEffect2);
|
|
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));
|
|
1204
1754
|
const middlewareKeys = Array.from(onEndpointOptions.middleware, (tag2) => `${tag2.key}/Client`);
|
|
1755
|
+
const redactedNames = getEndpointRedactedNames(api, group2, endpoint2);
|
|
1205
1756
|
const endpointFn = fnUntraced(function* (request) {
|
|
1206
1757
|
let httpRequest = make2(endpoint2.method)(endpoint2.path);
|
|
1207
1758
|
if (request !== void 0) {
|
|
@@ -1209,7 +1760,10 @@ var makeClient = (api, options2) => gen(function* () {
|
|
|
1209
1760
|
const params = yield* encodeParams(request.params);
|
|
1210
1761
|
httpRequest = setUrl(httpRequest, makeUrl(params));
|
|
1211
1762
|
}
|
|
1212
|
-
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) {
|
|
1213
1767
|
if (hasBody(endpoint2.method)) {
|
|
1214
1768
|
if (request.payload instanceof FormData) {
|
|
1215
1769
|
httpRequest = bodyFormData(httpRequest, request.payload);
|
|
@@ -1221,6 +1775,10 @@ var makeClient = (api, options2) => gen(function* () {
|
|
|
1221
1775
|
const urlParams2 = yield* encodePayload(request.payload);
|
|
1222
1776
|
httpRequest = appendUrlParams(httpRequest, urlParams2);
|
|
1223
1777
|
}
|
|
1778
|
+
} else if (streamPayloadEncoder !== void 0) {
|
|
1779
|
+
return yield* new SchemaError(new InvalidValue({
|
|
1780
|
+
message: "Expected a Stream payload"
|
|
1781
|
+
}, request.payload));
|
|
1224
1782
|
}
|
|
1225
1783
|
if (encodeHeaders !== void 0) {
|
|
1226
1784
|
const headers = yield* encodeHeaders(request.headers);
|
|
@@ -1231,11 +1789,15 @@ var makeClient = (api, options2) => gen(function* () {
|
|
|
1231
1789
|
httpRequest = appendUrlParams(httpRequest, query2);
|
|
1232
1790
|
}
|
|
1233
1791
|
}
|
|
1234
|
-
|
|
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);
|
|
1235
1797
|
if (request?.responseMode === "response-only") {
|
|
1236
1798
|
return response;
|
|
1237
1799
|
}
|
|
1238
|
-
const decoded = (
|
|
1800
|
+
const decoded = decodeEndpointResponse(response, request?.sseOptions);
|
|
1239
1801
|
const value = yield* options2.transformResponse === void 0 ? decoded : options2.transformResponse(decoded);
|
|
1240
1802
|
return request?.responseMode === "decoded-and-response" ? [value, response] : value;
|
|
1241
1803
|
});
|
|
@@ -1246,7 +1808,8 @@ var makeClient = (api, options2) => gen(function* () {
|
|
|
1246
1808
|
}
|
|
1247
1809
|
});
|
|
1248
1810
|
});
|
|
1249
|
-
var
|
|
1811
|
+
var withRedactedNames = (effect, redactedNames) => effect.pipe(updateService(CurrentRedactedNames2, (names) => [...names, ...redactedNames.query]), updateService(CurrentRedactedNames, (names) => [...names, ...redactedNames.headers]));
|
|
1812
|
+
var make6 = (api, options2) => flatMap(HttpClient, (httpClient) => makeWith(api, {
|
|
1250
1813
|
...options2,
|
|
1251
1814
|
httpClient: options2?.transformClient ? options2.transformClient(httpClient) : httpClient
|
|
1252
1815
|
}));
|
|
@@ -1282,7 +1845,7 @@ var group = (api, options2) => {
|
|
|
1282
1845
|
}) {
|
|
1283
1846
|
assignProperty(client, endpoint2.identifier, endpointFn);
|
|
1284
1847
|
}
|
|
1285
|
-
}).pipe(
|
|
1848
|
+
}).pipe(map3(() => client));
|
|
1286
1849
|
};
|
|
1287
1850
|
var endpoint = (api, options2) => {
|
|
1288
1851
|
let client = void 0;
|
|
@@ -1298,7 +1861,22 @@ var endpoint = (api, options2) => {
|
|
|
1298
1861
|
}) {
|
|
1299
1862
|
client = endpointFn;
|
|
1300
1863
|
}
|
|
1301
|
-
}).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);
|
|
1302
1880
|
};
|
|
1303
1881
|
var urlBuilder = (api, options2) => {
|
|
1304
1882
|
const builder = {};
|
|
@@ -1314,10 +1892,10 @@ var urlBuilder = (api, options2) => {
|
|
|
1314
1892
|
endpoint: endpoint2,
|
|
1315
1893
|
mergedAnnotations
|
|
1316
1894
|
}) {
|
|
1317
|
-
const parseOptions =
|
|
1895
|
+
const parseOptions = getSlotParseOptions(mergedAnnotations);
|
|
1318
1896
|
const makeUrl = compilePath(endpoint2.path, endpoint2.params);
|
|
1319
|
-
const encodeParams = endpoint2.params === void 0 ? void 0 : encodeSync(endpoint2.params, parseOptions);
|
|
1320
|
-
const encodeQuery = endpoint2.query === void 0 ? void 0 : encodeSync(endpoint2.query, parseOptions);
|
|
1897
|
+
const encodeParams = endpoint2.params === void 0 ? void 0 : encodeSync(endpoint2.params, parseOptions.params);
|
|
1898
|
+
const encodeQuery = endpoint2.query === void 0 ? void 0 : encodeSync(endpoint2.query, parseOptions.query);
|
|
1321
1899
|
const endpointBuilder = (request) => {
|
|
1322
1900
|
const params = request?.params;
|
|
1323
1901
|
const path = params === void 0 ? endpoint2.path : makeUrl(encodeParams === void 0 ? params : encodeParams(params));
|
|
@@ -1330,7 +1908,7 @@ var urlBuilder = (api, options2) => {
|
|
|
1330
1908
|
const url = new URL(prependUrl(get(path), options2.baseUrl.toString()).url);
|
|
1331
1909
|
for (const [key, value] of urlParams2.params) {
|
|
1332
1910
|
if (value !== void 0) {
|
|
1333
|
-
url.searchParams.append(key, value);
|
|
1911
|
+
url.searchParams.append(key, unwrap(value));
|
|
1334
1912
|
}
|
|
1335
1913
|
}
|
|
1336
1914
|
return url.toString();
|
|
@@ -1340,110 +1918,182 @@ var urlBuilder = (api, options2) => {
|
|
|
1340
1918
|
});
|
|
1341
1919
|
return builder;
|
|
1342
1920
|
};
|
|
1343
|
-
var paramsRegExp = /(\/?):(\w+)(\?)?/g;
|
|
1344
1921
|
var compilePath = (path, schema) => {
|
|
1345
1922
|
if (schema === void 0 || !path.includes(":")) {
|
|
1346
1923
|
return (_) => path;
|
|
1347
1924
|
}
|
|
1348
1925
|
const paramNames = getParamNames(schema);
|
|
1349
|
-
return (params) => {
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
}
|
|
1359
|
-
throw new Error(`Missing path parameter: ${key}`);
|
|
1360
|
-
}
|
|
1361
|
-
return `${slash}${encodeURIComponent(value)}`;
|
|
1362
|
-
});
|
|
1363
|
-
};
|
|
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
|
+
});
|
|
1364
1935
|
};
|
|
1365
|
-
function schemasToResponse(schemas, options2) {
|
|
1936
|
+
function schemasToResponse(schemas, options2, headersOptions) {
|
|
1366
1937
|
const hasWithHeaders = schemas.some((schema) => isWithHeaders(schema) || getWithHeadersAnnotation(schema.ast) !== void 0);
|
|
1367
|
-
const codec = hasWithHeaders ?
|
|
1368
|
-
const
|
|
1369
|
-
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({
|
|
1370
1941
|
body,
|
|
1371
1942
|
headers: response.headers
|
|
1372
|
-
}) :
|
|
1943
|
+
}) : decode4);
|
|
1373
1944
|
}
|
|
1374
|
-
|
|
1375
|
-
|
|
1945
|
+
var ResponsePair = /* @__PURE__ */ Struct({
|
|
1946
|
+
body: Unknown,
|
|
1947
|
+
headers: Unknown
|
|
1948
|
+
});
|
|
1949
|
+
function toCodecArrayBufferWithHeaders(schema, options2, headersOptions) {
|
|
1376
1950
|
const annotation = getWithHeadersAnnotation(schema.ast);
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1951
|
+
const parts = annotation !== void 0 ? {
|
|
1952
|
+
body: annotation.bodyCodec,
|
|
1953
|
+
headers: annotation.headersCodec,
|
|
1954
|
+
toValue: annotation.transformation.decode
|
|
1955
|
+
} : isWithHeaders(schema) ? {
|
|
1956
|
+
body: schema.schema,
|
|
1957
|
+
headers: schema.headers,
|
|
1958
|
+
toValue: withHeaders
|
|
1959
|
+
} : {
|
|
1960
|
+
body: schema,
|
|
1961
|
+
headers: Unknown,
|
|
1962
|
+
toValue: (pair) => pair.body
|
|
1963
|
+
};
|
|
1964
|
+
const decodeBody = decodeUnknownEffect(fromArrayBuffer(parts.body).pipe(decodeTo2(parts.body)), options2);
|
|
1965
|
+
const decodeHeaders = decodeUnknownEffect(parts.headers, headersOptions);
|
|
1966
|
+
return ResponsePair.pipe(decodeTo2(isWithHeaders(schema) ? schema : toType(schema), transformEffect({
|
|
1967
|
+
decode: (pair) => all({
|
|
1968
|
+
body: decodeBody(pair.body),
|
|
1969
|
+
headers: decodeHeaders(pair.headers)
|
|
1970
|
+
}).pipe(map3(parts.toValue), mapError((error) => error.issue)),
|
|
1971
|
+
encode: (input, options3) => fail3(new Forbidden({
|
|
1972
|
+
message: "Decode only schema"
|
|
1973
|
+
}, input, options3))
|
|
1393
1974
|
})));
|
|
1394
1975
|
}
|
|
1395
|
-
|
|
1396
|
-
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);
|
|
1397
2042
|
const alternatives = map7.get(status2);
|
|
1398
2043
|
if (alternatives === void 0) {
|
|
1399
2044
|
map7.set(status2, [{
|
|
1400
2045
|
contentType: normalizedContentType,
|
|
1401
|
-
decode:
|
|
2046
|
+
decode: decode4
|
|
1402
2047
|
}]);
|
|
1403
2048
|
} else {
|
|
1404
2049
|
alternatives.push({
|
|
1405
2050
|
contentType: normalizedContentType,
|
|
1406
|
-
decode:
|
|
2051
|
+
decode: decode4
|
|
1407
2052
|
});
|
|
1408
2053
|
}
|
|
1409
2054
|
}
|
|
1410
2055
|
function makeResponseDecoder(alternatives) {
|
|
1411
2056
|
const first = alternatives[0];
|
|
1412
|
-
if (
|
|
2057
|
+
if (first !== void 0 && alternatives.every((alternative) => alternative.decode === first.decode)) {
|
|
1413
2058
|
return first.decode;
|
|
1414
2059
|
}
|
|
1415
2060
|
return (response, sseOptions) => {
|
|
1416
|
-
const
|
|
1417
|
-
const alternative = alternatives.find((alternative2) => alternative2.contentType ===
|
|
1418
|
-
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);
|
|
1419
2064
|
};
|
|
1420
2065
|
}
|
|
1421
2066
|
function groupSchemasByContentType(schemas) {
|
|
1422
2067
|
const grouped = /* @__PURE__ */ new Map();
|
|
1423
2068
|
for (const schema of schemas) {
|
|
1424
2069
|
const body = isWithHeaders(schema) ? schema.schema : schema;
|
|
1425
|
-
const
|
|
1426
|
-
const existing = grouped.get(
|
|
2070
|
+
const contentType2 = isNoContent(body.ast) ? "" : normalize(getResponseEncodingSchema(schema).contentType);
|
|
2071
|
+
const existing = grouped.get(contentType2);
|
|
1427
2072
|
if (existing === void 0) {
|
|
1428
|
-
grouped.set(
|
|
2073
|
+
grouped.set(contentType2, [schema]);
|
|
1429
2074
|
} else {
|
|
1430
2075
|
existing.push(schema);
|
|
1431
2076
|
}
|
|
1432
2077
|
}
|
|
1433
2078
|
return grouped;
|
|
1434
2079
|
}
|
|
1435
|
-
function failUnsupportedContentType(response,
|
|
2080
|
+
function failUnsupportedContentType(response, contentType2, alternatives) {
|
|
1436
2081
|
const expected = Array.from(new Set(alternatives.map((alternative) => alternative.contentType))).join(", ");
|
|
1437
2082
|
return fail3(new HttpClientError({
|
|
1438
2083
|
reason: new DecodeError({
|
|
1439
2084
|
request: response.request,
|
|
1440
2085
|
response,
|
|
1441
|
-
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}`
|
|
1442
2087
|
})
|
|
1443
2088
|
}));
|
|
1444
2089
|
}
|
|
1445
|
-
var reservedStreamFailureEvent2 = "effect/
|
|
2090
|
+
var reservedStreamFailureEvent2 = "effect/http-api/stream/failure";
|
|
1446
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
|
+
}
|
|
1447
2097
|
function getStreamSuccessSchemas(endpoint2) {
|
|
1448
2098
|
const schemas = [];
|
|
1449
2099
|
for (const schema of endpoint2.success) {
|
|
@@ -1454,23 +2104,49 @@ function getStreamSuccessSchemas(endpoint2) {
|
|
|
1454
2104
|
}
|
|
1455
2105
|
return schemas;
|
|
1456
2106
|
}
|
|
1457
|
-
function streamToResponse(successSchema, options2) {
|
|
2107
|
+
function streamToResponse(successSchema, options2, headersOptions) {
|
|
1458
2108
|
const isWithHeaders2 = isWithHeadersStreamSuccess(successSchema);
|
|
1459
2109
|
const streamSchema2 = isWithHeaders2 ? successSchema.schema : successSchema;
|
|
1460
|
-
const
|
|
1461
|
-
|
|
1462
|
-
decoder: makeSseDecoder(streamSchema2, options2)
|
|
1463
|
-
};
|
|
1464
|
-
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));
|
|
1465
2112
|
if (!isWithHeaders2) return toStream;
|
|
1466
|
-
const decodeHeaders = decodeUnknownEffect(successSchema.headers,
|
|
1467
|
-
return (response, sseOptions) => flatMap(decodeHeaders(response.headers), (headers) =>
|
|
2113
|
+
const decodeHeaders = decodeUnknownEffect(successSchema.headers, headersOptions);
|
|
2114
|
+
return (response, sseOptions) => flatMap(decodeHeaders(response.headers), (headers) => map3(toStream(response, sseOptions), (body) => withHeaders({
|
|
1468
2115
|
body,
|
|
1469
2116
|
headers
|
|
1470
2117
|
})));
|
|
1471
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
|
+
}));
|
|
1472
2148
|
function makeSseDecoder(declaration, parseOptions) {
|
|
1473
|
-
const Event2 =
|
|
2149
|
+
const Event2 = Union2([Struct({
|
|
1474
2150
|
id: optional(String2),
|
|
1475
2151
|
event: Literal(reservedStreamFailureEvent2),
|
|
1476
2152
|
data: fromJsonString(toCodecJson(Cause(declaration.error, Defect())))
|
|
@@ -1478,8 +2154,8 @@ function makeSseDecoder(declaration, parseOptions) {
|
|
|
1478
2154
|
const defaultDecoder = decodeSchema(Event2, void 0, parseOptions);
|
|
1479
2155
|
return (options2) => options2 === void 0 ? defaultDecoder : decodeSchema(Event2, options2, parseOptions);
|
|
1480
2156
|
}
|
|
1481
|
-
function decodeSseStream(
|
|
1482
|
-
const events = transformPull(
|
|
2157
|
+
function decodeSseStream(stream2, declaration, decoder) {
|
|
2158
|
+
const events = transformPull(stream2.pipe(decodeText, pipeThroughChannel(decoder)), (pull) => sync(() => {
|
|
1483
2159
|
let pendingFailureCause = void 0;
|
|
1484
2160
|
return suspend(() => {
|
|
1485
2161
|
if (pendingFailureCause !== void 0) {
|
|
@@ -1502,14 +2178,14 @@ function decodeSseStream(stream, declaration, decoder) {
|
|
|
1502
2178
|
});
|
|
1503
2179
|
}));
|
|
1504
2180
|
if (declaration.sseMode === "data") {
|
|
1505
|
-
return
|
|
2181
|
+
return map5(events, (event) => event.data);
|
|
1506
2182
|
}
|
|
1507
2183
|
return events;
|
|
1508
2184
|
}
|
|
1509
2185
|
var ArrayBuffer = /* @__PURE__ */ instanceOf(globalThis.ArrayBuffer, {
|
|
1510
2186
|
expected: "ArrayBuffer"
|
|
1511
2187
|
});
|
|
1512
|
-
var Uint8ArrayFromArrayBuffer = /* @__PURE__ */ ArrayBuffer.pipe(/* @__PURE__ */
|
|
2188
|
+
var Uint8ArrayFromArrayBuffer = /* @__PURE__ */ ArrayBuffer.pipe(/* @__PURE__ */ decodeTo2(Uint8Array2, /* @__PURE__ */ transform({
|
|
1513
2189
|
decode(fromA) {
|
|
1514
2190
|
return new Uint8Array(fromA);
|
|
1515
2191
|
},
|
|
@@ -1517,7 +2193,7 @@ var Uint8ArrayFromArrayBuffer = /* @__PURE__ */ ArrayBuffer.pipe(/* @__PURE__ */
|
|
|
1517
2193
|
return arr.byteLength === arr.buffer.byteLength ? arr.buffer : arr.buffer.slice(arr.byteOffset, arr.byteOffset + arr.byteLength);
|
|
1518
2194
|
}
|
|
1519
2195
|
})));
|
|
1520
|
-
var StringFromArrayBuffer = /* @__PURE__ */ ArrayBuffer.pipe(/* @__PURE__ */
|
|
2196
|
+
var StringFromArrayBuffer = /* @__PURE__ */ ArrayBuffer.pipe(/* @__PURE__ */ decodeTo2(String2, /* @__PURE__ */ transform({
|
|
1521
2197
|
decode(fromA) {
|
|
1522
2198
|
return new TextDecoder().decode(fromA);
|
|
1523
2199
|
},
|
|
@@ -1526,18 +2202,18 @@ var StringFromArrayBuffer = /* @__PURE__ */ ArrayBuffer.pipe(/* @__PURE__ */ dec
|
|
|
1526
2202
|
return arr.byteLength === arr.buffer.byteLength ? arr.buffer : arr.buffer.slice(arr.byteOffset, arr.byteOffset + arr.byteLength);
|
|
1527
2203
|
}
|
|
1528
2204
|
})));
|
|
1529
|
-
var UnknownFromArrayBuffer = /* @__PURE__ */ StringFromArrayBuffer.pipe(/* @__PURE__ */
|
|
2205
|
+
var UnknownFromArrayBuffer = /* @__PURE__ */ StringFromArrayBuffer.pipe(/* @__PURE__ */ decodeTo2(/* @__PURE__ */ Union2([
|
|
1530
2206
|
// Handle No Content
|
|
1531
|
-
/* @__PURE__ */ Literal("").pipe(/* @__PURE__ */
|
|
2207
|
+
/* @__PURE__ */ Literal("").pipe(/* @__PURE__ */ decodeTo2(Undefined, /* @__PURE__ */ transform({
|
|
1532
2208
|
decode: () => void 0,
|
|
1533
2209
|
encode: () => ""
|
|
1534
2210
|
}))),
|
|
1535
2211
|
UnknownFromJsonString
|
|
1536
2212
|
])));
|
|
1537
2213
|
function toCodecArrayBuffer(schemas) {
|
|
1538
|
-
return
|
|
2214
|
+
return Union2(schemas.map(onSchema));
|
|
1539
2215
|
function onSchema(schema) {
|
|
1540
|
-
return fromArrayBuffer(schema).pipe(
|
|
2216
|
+
return fromArrayBuffer(schema).pipe(decodeTo2(schema));
|
|
1541
2217
|
}
|
|
1542
2218
|
}
|
|
1543
2219
|
function fromArrayBuffer(schema) {
|
|
@@ -1545,13 +2221,13 @@ function fromArrayBuffer(schema) {
|
|
|
1545
2221
|
switch (encoding._tag) {
|
|
1546
2222
|
case "Json": {
|
|
1547
2223
|
const encodedIsNull = isNull(toEncoded(schema.ast));
|
|
1548
|
-
return encodedIsNull ? UnknownFromArrayBuffer.pipe(
|
|
2224
|
+
return encodedIsNull ? UnknownFromArrayBuffer.pipe(decodeTo2(Unknown, transform({
|
|
1549
2225
|
decode: (a) => a === void 0 ? null : a,
|
|
1550
2226
|
encode: (a) => a === null ? void 0 : a
|
|
1551
2227
|
}))) : UnknownFromArrayBuffer;
|
|
1552
2228
|
}
|
|
1553
2229
|
case "FormUrlEncoded":
|
|
1554
|
-
return StringFromArrayBuffer.pipe(
|
|
2230
|
+
return StringFromArrayBuffer.pipe(decodeTo2(RecordFromUrlParams, transform({
|
|
1555
2231
|
decode: (text2) => fromInput(new URLSearchParams(text2)),
|
|
1556
2232
|
encode: toString
|
|
1557
2233
|
})));
|
|
@@ -1564,12 +2240,20 @@ function fromArrayBuffer(schema) {
|
|
|
1564
2240
|
var statusOrElse = (response) => fail3(new HttpClientError({
|
|
1565
2241
|
reason: new DecodeError({
|
|
1566
2242
|
request: response.request,
|
|
1567
|
-
response
|
|
2243
|
+
response,
|
|
2244
|
+
description: "undeclared status code"
|
|
1568
2245
|
})
|
|
1569
2246
|
}));
|
|
1570
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
|
+
}
|
|
1571
2255
|
function getEncodePayloadSchema(schemas, method) {
|
|
1572
|
-
return
|
|
2256
|
+
return Union2(schemas.map((s) => getEncodePayloadSchemaFromBody(s, method)));
|
|
1573
2257
|
}
|
|
1574
2258
|
var bodyFromPayloadCache = /* @__PURE__ */ new WeakMap();
|
|
1575
2259
|
function getEncodePayloadSchemaFromBody(schema, method) {
|
|
@@ -1579,7 +2263,7 @@ function getEncodePayloadSchemaFromBody(schema, method) {
|
|
|
1579
2263
|
return cached;
|
|
1580
2264
|
}
|
|
1581
2265
|
const encoding = getPayloadEncoding(ast, method);
|
|
1582
|
-
const out = $HttpBody.pipe(
|
|
2266
|
+
const out = $HttpBody.pipe(decodeTo2(schema, transformEffect({
|
|
1583
2267
|
decode(input, options2) {
|
|
1584
2268
|
return fail3(new Forbidden({
|
|
1585
2269
|
message: "Encode only schema"
|
|
@@ -1632,165 +2316,10 @@ function getEncodePayloadSchemaFromBody(schema, method) {
|
|
|
1632
2316
|
return out;
|
|
1633
2317
|
}
|
|
1634
2318
|
|
|
1635
|
-
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/httpapi/HttpApiGroup.js
|
|
1636
|
-
var HttpApiGroup_exports = {};
|
|
1637
|
-
__export(HttpApiGroup_exports, {
|
|
1638
|
-
isHttpApiGroup: () => isHttpApiGroup,
|
|
1639
|
-
make: () => make6
|
|
1640
|
-
});
|
|
1641
|
-
var TypeId3 = "~effect/httpapi/HttpApiGroup";
|
|
1642
|
-
var isHttpApiGroup = (u) => hasProperty(u, TypeId3);
|
|
1643
|
-
var Proto3 = {
|
|
1644
|
-
[TypeId3]: TypeId3,
|
|
1645
|
-
add(...toAdd) {
|
|
1646
|
-
const endpoints = {
|
|
1647
|
-
...this.endpoints
|
|
1648
|
-
};
|
|
1649
|
-
for (const endpoint2 of toAdd) {
|
|
1650
|
-
assignProperty(endpoints, endpoint2.identifier, endpoint2);
|
|
1651
|
-
}
|
|
1652
|
-
return makeProto3({
|
|
1653
|
-
...optionsFromGroup(this),
|
|
1654
|
-
endpoints
|
|
1655
|
-
});
|
|
1656
|
-
},
|
|
1657
|
-
prefix(prefix) {
|
|
1658
|
-
return makeProto3({
|
|
1659
|
-
...optionsFromGroup(this),
|
|
1660
|
-
endpoints: map(this.endpoints, (endpoint2) => endpoint2.prefix(prefix))
|
|
1661
|
-
});
|
|
1662
|
-
},
|
|
1663
|
-
middleware(middleware) {
|
|
1664
|
-
return makeProto3({
|
|
1665
|
-
...optionsFromGroup(this),
|
|
1666
|
-
endpoints: map(this.endpoints, (endpoint2) => endpoint2.middleware(middleware))
|
|
1667
|
-
});
|
|
1668
|
-
},
|
|
1669
|
-
annotateMerge(annotations) {
|
|
1670
|
-
return makeProto3({
|
|
1671
|
-
...optionsFromGroup(this),
|
|
1672
|
-
annotations: merge(this.annotations, annotations)
|
|
1673
|
-
});
|
|
1674
|
-
},
|
|
1675
|
-
annotate(annotation, value) {
|
|
1676
|
-
return makeProto3({
|
|
1677
|
-
...optionsFromGroup(this),
|
|
1678
|
-
annotations: add(this.annotations, annotation, value)
|
|
1679
|
-
});
|
|
1680
|
-
},
|
|
1681
|
-
annotateEndpointsMerge(annotations) {
|
|
1682
|
-
return makeProto3({
|
|
1683
|
-
...optionsFromGroup(this),
|
|
1684
|
-
endpoints: map(this.endpoints, (endpoint2) => endpoint2.annotateMerge(annotations))
|
|
1685
|
-
});
|
|
1686
|
-
},
|
|
1687
|
-
annotateEndpoints(annotation, value) {
|
|
1688
|
-
return makeProto3({
|
|
1689
|
-
...optionsFromGroup(this),
|
|
1690
|
-
endpoints: map(this.endpoints, (endpoint2) => endpoint2.annotate(annotation, value))
|
|
1691
|
-
});
|
|
1692
|
-
},
|
|
1693
|
-
pipe() {
|
|
1694
|
-
return pipeArguments(this, arguments);
|
|
1695
|
-
}
|
|
1696
|
-
};
|
|
1697
|
-
var optionsFromGroup = (group2) => ({
|
|
1698
|
-
identifier: group2.identifier,
|
|
1699
|
-
topLevel: group2.topLevel,
|
|
1700
|
-
endpoints: group2.endpoints,
|
|
1701
|
-
annotations: group2.annotations
|
|
1702
|
-
});
|
|
1703
|
-
var makeProto3 = (options2) => {
|
|
1704
|
-
function HttpApiGroup() {
|
|
1705
|
-
}
|
|
1706
|
-
Object.setPrototypeOf(HttpApiGroup, Proto3);
|
|
1707
|
-
HttpApiGroup.key = `effect/httpapi/HttpApiGroup/${options2.identifier}`;
|
|
1708
|
-
return Object.assign(HttpApiGroup, options2);
|
|
1709
|
-
};
|
|
1710
|
-
var make6 = (identifier, options2) => makeProto3({
|
|
1711
|
-
identifier,
|
|
1712
|
-
topLevel: options2?.topLevel ?? false,
|
|
1713
|
-
endpoints: {},
|
|
1714
|
-
annotations: empty()
|
|
1715
|
-
});
|
|
1716
|
-
|
|
1717
|
-
// src/contracts/ui.ts
|
|
1718
|
-
var UiContext = Schema_exports.Struct({
|
|
1719
|
-
deployment: Schema_exports.NonEmptyString,
|
|
1720
|
-
profile: Schema_exports.optional(Schema_exports.NonEmptyString),
|
|
1721
|
-
expectedProfileRevision: Schema_exports.optional(Schema_exports.Int)
|
|
1722
|
-
});
|
|
1723
|
-
var UiOperation = Schema_exports.Struct({
|
|
1724
|
-
...UiContext.fields,
|
|
1725
|
-
name: Schema_exports.NonEmptyString,
|
|
1726
|
-
input: JsonValue
|
|
1727
|
-
});
|
|
1728
|
-
var UiUnauthorized = class extends Schema_exports.TaggedError()(
|
|
1729
|
-
"UiUnauthorized",
|
|
1730
|
-
{},
|
|
1731
|
-
{ httpApiStatus: 401 }
|
|
1732
|
-
) {
|
|
1733
|
-
};
|
|
1734
|
-
var UiForbidden = class extends Schema_exports.TaggedError()(
|
|
1735
|
-
"UiForbidden",
|
|
1736
|
-
{},
|
|
1737
|
-
{ httpApiStatus: 403 }
|
|
1738
|
-
) {
|
|
1739
|
-
};
|
|
1740
|
-
var UiDeploymentChanged = class extends Schema_exports.TaggedError()(
|
|
1741
|
-
"UiDeploymentChanged",
|
|
1742
|
-
{},
|
|
1743
|
-
{ httpApiStatus: 409 }
|
|
1744
|
-
) {
|
|
1745
|
-
};
|
|
1746
|
-
var UiFailed = class extends Schema_exports.TaggedError()(
|
|
1747
|
-
"UiFailed",
|
|
1748
|
-
{
|
|
1749
|
-
reason: Schema_exports.Literals(["unavailable", "operation_failed", "account_required"])
|
|
1750
|
-
},
|
|
1751
|
-
{ httpApiStatus: 422 }
|
|
1752
|
-
) {
|
|
1753
|
-
};
|
|
1754
|
-
var UiSnapshot = Schema_exports.Union([
|
|
1755
|
-
Schema_exports.Struct({
|
|
1756
|
-
type: Schema_exports.Literal("snapshot"),
|
|
1757
|
-
value: JsonValue,
|
|
1758
|
-
trace: Schema_exports.optional(Schema_exports.Unknown)
|
|
1759
|
-
}),
|
|
1760
|
-
Schema_exports.Struct({ type: Schema_exports.Literal("failure"), error: UiFailed }),
|
|
1761
|
-
Schema_exports.Struct({ type: Schema_exports.Literal("heartbeat") })
|
|
1762
|
-
]);
|
|
1763
|
-
var errors = [UiUnauthorized, UiForbidden, UiDeploymentChanged, UiFailed];
|
|
1764
|
-
var AppUiApi = HttpApi_exports.make("app-ui").add(
|
|
1765
|
-
HttpApiGroup_exports.make("ui").add(
|
|
1766
|
-
HttpApiEndpoint_exports.post("query", "/_executor/api/query", {
|
|
1767
|
-
payload: UiOperation,
|
|
1768
|
-
success: JsonValue,
|
|
1769
|
-
error: errors
|
|
1770
|
-
})
|
|
1771
|
-
).add(
|
|
1772
|
-
HttpApiEndpoint_exports.post("mutate", "/_executor/api/mutate", {
|
|
1773
|
-
payload: UiOperation,
|
|
1774
|
-
success: JsonValue,
|
|
1775
|
-
error: errors
|
|
1776
|
-
})
|
|
1777
|
-
).add(
|
|
1778
|
-
HttpApiEndpoint_exports.post("subscribe", "/_executor/api/subscribe", {
|
|
1779
|
-
payload: UiOperation,
|
|
1780
|
-
success: HttpApiSchema_exports.StreamSse({ data: UiSnapshot, error: Schema_exports.Union(errors) }),
|
|
1781
|
-
error: errors
|
|
1782
|
-
})
|
|
1783
|
-
)
|
|
1784
|
-
);
|
|
1785
|
-
|
|
1786
2319
|
export {
|
|
2320
|
+
HttpApiSchema_exports,
|
|
2321
|
+
HttpApiEndpoint_exports,
|
|
2322
|
+
HttpApi_exports,
|
|
1787
2323
|
HttpApiClient_exports,
|
|
1788
|
-
|
|
1789
|
-
UiOperation,
|
|
1790
|
-
UiUnauthorized,
|
|
1791
|
-
UiForbidden,
|
|
1792
|
-
UiDeploymentChanged,
|
|
1793
|
-
UiFailed,
|
|
1794
|
-
UiSnapshot,
|
|
1795
|
-
AppUiApi
|
|
2324
|
+
HttpApiGroup_exports
|
|
1796
2325
|
};
|