apps 0.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +191 -0
  2. package/check-publish.mjs +10 -0
  3. package/framework-reference.json +1 -0
  4. package/js/chunk-22WRQZT7.js +389 -0
  5. package/js/chunk-2OTCEKL2.js +29480 -0
  6. package/js/chunk-36DNRFZQ.js +34 -0
  7. package/js/chunk-3ANFZFCV.js +1799 -0
  8. package/js/chunk-7JXHF5IF.js +138 -0
  9. package/js/chunk-BCSNKUAC.js +0 -0
  10. package/js/chunk-BKVL7XAJ.js +47 -0
  11. package/js/chunk-BPEFS4YF.js +1323 -0
  12. package/js/chunk-C24KEZXR.js +59 -0
  13. package/js/chunk-D6BKYP2L.js +877 -0
  14. package/js/chunk-EP6AEUZO.js +19 -0
  15. package/js/chunk-HP7E42X6.js +1719 -0
  16. package/js/chunk-KWTCHVLT.js +284 -0
  17. package/js/chunk-LOKGDT6B.js +28 -0
  18. package/js/chunk-MLKGABMK.js +9 -0
  19. package/js/chunk-OWD2YICM.js +2486 -0
  20. package/js/chunk-Q2FD5IBM.js +899 -0
  21. package/js/chunk-R6JMJSVT.js +590 -0
  22. package/js/chunk-SBKHUC5L.js +56 -0
  23. package/js/chunk-VFUZI3NY.js +75 -0
  24. package/js/chunk-W7Q5EOTS.js +4375 -0
  25. package/js/chunk-WIDTG42X.js +171 -0
  26. package/js/chunk-X3YBZCJW.js +246 -0
  27. package/js/chunk-YDR4CPJA.js +2357 -0
  28. package/js/client.js +1023 -0
  29. package/js/contracts.js +163 -0
  30. package/js/effect.js +44 -0
  31. package/js/graphql.js +392 -0
  32. package/js/host.js +193 -0
  33. package/js/index.js +284 -0
  34. package/js/mcp/effect.js +23 -0
  35. package/js/mcp/stdio.js +123 -0
  36. package/js/mcp.js +37 -0
  37. package/js/openapi.js +246 -0
  38. package/js/operations/approval.js +9 -0
  39. package/js/react.js +37 -0
  40. package/js/storage/facet.js +546 -0
  41. package/js/ui/auth/contracts.js +19 -0
  42. package/js/ui/auth.js +28 -0
  43. package/js/ui/contracts.js +24 -0
  44. package/js/ui/serving.js +286 -0
  45. package/package.json +116 -0
  46. package/runtime.json +1 -0
  47. package/types/app-data/src/contracts/database.d.ts +193 -0
  48. package/types/app-data/src/implementation/cursor.d.ts +10 -0
  49. package/types/app-data/src/implementation/index-key.d.ts +7 -0
  50. package/types/app-data/src/implementation/promise.d.ts +68 -0
  51. package/types/app-data/src/implementation/range.d.ts +8 -0
  52. package/types/app-data/src/implementation/schema.d.ts +33 -0
  53. package/types/app-data/src/implementation/sqlite.d.ts +11 -0
  54. package/types/app-data/src/index.d.ts +4 -0
  55. package/types/apps/src/approval.d.ts +10 -0
  56. package/types/apps/src/client.d.ts +5 -0
  57. package/types/apps/src/contracts/app.d.ts +58 -0
  58. package/types/apps/src/contracts/approval.d.ts +14 -0
  59. package/types/apps/src/contracts/context.d.ts +25 -0
  60. package/types/apps/src/contracts/elicitation.d.ts +86 -0
  61. package/types/apps/src/contracts/graphql.d.ts +102 -0
  62. package/types/apps/src/contracts/host.d.ts +568 -0
  63. package/types/apps/src/contracts/http.d.ts +20 -0
  64. package/types/apps/src/contracts/live.d.ts +26 -0
  65. package/types/apps/src/contracts/mcp.d.ts +93 -0
  66. package/types/apps/src/contracts/openapi.d.ts +105 -0
  67. package/types/apps/src/contracts/operations.d.ts +30 -0
  68. package/types/apps/src/contracts/optimistic.d.ts +22 -0
  69. package/types/apps/src/contracts/provider.d.ts +96 -0
  70. package/types/apps/src/contracts/schedules.d.ts +51 -0
  71. package/types/apps/src/contracts/schema.d.ts +20 -0
  72. package/types/apps/src/contracts/storage.d.ts +68 -0
  73. package/types/apps/src/contracts/tools.d.ts +11 -0
  74. package/types/apps/src/contracts/ui-auth.d.ts +28 -0
  75. package/types/apps/src/contracts/ui.d.ts +90 -0
  76. package/types/apps/src/contracts/webhook-protocol.d.ts +102 -0
  77. package/types/apps/src/contracts/webhooks.d.ts +53 -0
  78. package/types/apps/src/contracts/workflows.d.ts +277 -0
  79. package/types/apps/src/effect.d.ts +10 -0
  80. package/types/apps/src/facet.d.ts +5 -0
  81. package/types/apps/src/graphql.d.ts +10 -0
  82. package/types/apps/src/host.d.ts +16 -0
  83. package/types/apps/src/implementation/account-operations.d.ts +32 -0
  84. package/types/apps/src/implementation/app.d.ts +40 -0
  85. package/types/apps/src/implementation/authoring.d.ts +12 -0
  86. package/types/apps/src/implementation/elicitation.d.ts +103 -0
  87. package/types/apps/src/implementation/graphql.d.ts +5 -0
  88. package/types/apps/src/implementation/host.d.ts +3 -0
  89. package/types/apps/src/implementation/http.d.ts +5 -0
  90. package/types/apps/src/implementation/live.d.ts +18 -0
  91. package/types/apps/src/implementation/mcp-call.d.ts +19 -0
  92. package/types/apps/src/implementation/mcp-client.d.ts +50 -0
  93. package/types/apps/src/implementation/mcp-stdio.d.ts +4 -0
  94. package/types/apps/src/implementation/mcp-tools.d.ts +6 -0
  95. package/types/apps/src/implementation/mcp.d.ts +4 -0
  96. package/types/apps/src/implementation/openapi-request.d.ts +11 -0
  97. package/types/apps/src/implementation/openapi.d.ts +5 -0
  98. package/types/apps/src/implementation/operations.d.ts +65 -0
  99. package/types/apps/src/implementation/optimistic.d.ts +30 -0
  100. package/types/apps/src/implementation/protocol-operations.d.ts +24 -0
  101. package/types/apps/src/implementation/provider.d.ts +16 -0
  102. package/types/apps/src/implementation/query-commit.d.ts +10 -0
  103. package/types/apps/src/implementation/schedules.d.ts +16 -0
  104. package/types/apps/src/implementation/schema.d.ts +93 -0
  105. package/types/apps/src/implementation/storage.d.ts +13 -0
  106. package/types/apps/src/implementation/ui-auth.d.ts +13 -0
  107. package/types/apps/src/implementation/ui-client.d.ts +16 -0
  108. package/types/apps/src/implementation/ui-errors.d.ts +2 -0
  109. package/types/apps/src/implementation/ui-serving.d.ts +16 -0
  110. package/types/apps/src/implementation/ui-watch.d.ts +2 -0
  111. package/types/apps/src/implementation/webhooks.d.ts +29 -0
  112. package/types/apps/src/implementation/workflow-context.d.ts +8 -0
  113. package/types/apps/src/implementation/workflow-rpc.d.ts +5 -0
  114. package/types/apps/src/implementation/workflows.d.ts +27 -0
  115. package/types/apps/src/index.d.ts +58 -0
  116. package/types/apps/src/mcp-stdio.d.ts +8 -0
  117. package/types/apps/src/mcp.d.ts +10 -0
  118. package/types/apps/src/openapi.d.ts +10 -0
  119. package/types/apps/src/react.d.ts +7 -0
  120. package/types/apps/src/ui-auth.d.ts +3 -0
  121. package/types/apps/src/ui-serving.d.ts +3 -0
  122. package/types/telemetry/src/browser-operations.d.ts +16 -0
  123. package/types/telemetry/src/browser-performance.d.ts +11 -0
  124. package/types/telemetry/src/browser-request-timing.d.ts +2 -0
  125. package/types/telemetry/src/browser.d.ts +27 -0
  126. package/types/telemetry/src/config.d.ts +83 -0
  127. package/types/telemetry/src/context.d.ts +14 -0
  128. package/types/telemetry/src/index.d.ts +9 -0
  129. package/types/telemetry/src/layer.d.ts +7 -0
  130. package/types/telemetry/src/measurements.d.ts +8 -0
  131. package/types/telemetry/src/pending-span.d.ts +7 -0
  132. package/types/telemetry/src/relay.d.ts +28 -0
  133. package/types/telemetry/src/span-attributes.d.ts +29 -0
  134. package/types/telemetry/src/trace-context.d.ts +20 -0
  135. package/types/telemetry/src/transport.d.ts +6 -0
@@ -0,0 +1,1799 @@
1
+ import {
2
+ DecodeError,
3
+ HttpClient,
4
+ HttpClientError,
5
+ StatusCodeError,
6
+ appendUrlParams,
7
+ bodyFormData,
8
+ fromLiteral,
9
+ get,
10
+ hasBody,
11
+ isHttpBody,
12
+ make as make2,
13
+ mapRequest,
14
+ prefixPath,
15
+ prependUrl,
16
+ setBody,
17
+ setHeaders,
18
+ setUrl,
19
+ text,
20
+ uint8Array,
21
+ urlParams
22
+ } from "./chunk-W7Q5EOTS.js";
23
+ import {
24
+ JsonValue
25
+ } from "./chunk-36DNRFZQ.js";
26
+ import {
27
+ Cause,
28
+ Defect,
29
+ Forbidden,
30
+ InvalidValue,
31
+ Literal,
32
+ Never,
33
+ RecordFromUrlParams,
34
+ Schema_exports,
35
+ Service,
36
+ String as String2,
37
+ Struct,
38
+ TaggedClass,
39
+ TaggedError,
40
+ Uint8Array as Uint8Array2,
41
+ Undefined,
42
+ UndefinedOr,
43
+ Union,
44
+ Unknown,
45
+ UnknownFromJsonString,
46
+ Void,
47
+ add,
48
+ as,
49
+ assignProperty,
50
+ brand,
51
+ catchCause,
52
+ combine2 as combine,
53
+ constVoid,
54
+ context,
55
+ declare,
56
+ decode2 as decode,
57
+ decodeEffect,
58
+ decodeText,
59
+ decodeTo,
60
+ decodeUnknownEffect2 as decodeUnknownEffect,
61
+ empty2 as empty,
62
+ empty6 as empty2,
63
+ encodeSync,
64
+ encodeUnknownEffect2 as encodeUnknownEffect,
65
+ ensure,
66
+ fail,
67
+ fail2,
68
+ fail4 as fail3,
69
+ failCause2 as failCause,
70
+ flatMap2 as flatMap,
71
+ fnUntraced,
72
+ fromInput3 as fromInput,
73
+ fromJsonString,
74
+ fromTransform,
75
+ gen,
76
+ getLastEncoding,
77
+ getOrUndefined2 as getOrUndefined,
78
+ hasProperty,
79
+ identity,
80
+ instanceOf,
81
+ isArrayNonEmpty,
82
+ isCause,
83
+ isLiteral,
84
+ isNull,
85
+ isObject,
86
+ isObjects,
87
+ isSchema,
88
+ isStream,
89
+ isSuspend,
90
+ isUnion,
91
+ isVoid,
92
+ make6 as make,
93
+ map2 as map,
94
+ map3 as map2,
95
+ map4 as map3,
96
+ map6 as map4,
97
+ memoize,
98
+ merge,
99
+ millis,
100
+ optional,
101
+ pipeArguments,
102
+ pipeThroughChannel,
103
+ pipeTo,
104
+ provideContext2 as provideContext,
105
+ resolveAt,
106
+ succeed,
107
+ succeed4 as succeed2,
108
+ suspend,
109
+ sync2 as sync,
110
+ tag,
111
+ toCodecJson,
112
+ toCodecStringTree,
113
+ toEncoded,
114
+ toEncoded2,
115
+ toString,
116
+ toType,
117
+ transform,
118
+ transformEffect,
119
+ transformPull,
120
+ void_2 as void_
121
+ } from "./chunk-2OTCEKL2.js";
122
+ import {
123
+ __export
124
+ } from "./chunk-MLKGABMK.js";
125
+
126
+ // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/httpapi/HttpApi.js
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@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/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@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/httpapi/HttpApiSchema.js
155
+ var HttpApiSchema_exports = {};
156
+ __export(HttpApiSchema_exports, {
157
+ Accepted: () => Accepted,
158
+ Created: () => Created,
159
+ Empty: () => Empty,
160
+ MultipartStreamTypeId: () => MultipartStreamTypeId,
161
+ MultipartTypeId: () => MultipartTypeId,
162
+ NoContent: () => NoContent,
163
+ StreamSse: () => StreamSse,
164
+ StreamUint8Array: () => StreamUint8Array,
165
+ WithHeaders: () => WithHeaders,
166
+ WithHeadersTypeId: () => WithHeadersTypeId,
167
+ WithHeadersValueTypeId: () => WithHeadersValueTypeId,
168
+ asFormUrlEncoded: () => asFormUrlEncoded,
169
+ asJson: () => asJson,
170
+ asMultipart: () => asMultipart,
171
+ asMultipartStream: () => asMultipartStream,
172
+ asNoContent: () => asNoContent,
173
+ asText: () => asText,
174
+ asUint8Array: () => asUint8Array,
175
+ encodeToWithHeaders: () => encodeToWithHeaders,
176
+ getPayloadEncoding: () => getPayloadEncoding,
177
+ getResponseEncoding: () => getResponseEncoding,
178
+ getResponseEncodingSchema: () => getResponseEncodingSchema,
179
+ getStatusError: () => getStatusError,
180
+ getStatusErrorSchema: () => getStatusErrorSchema,
181
+ getStatusSuccess: () => getStatusSuccess,
182
+ getStatusSuccessSchema: () => getStatusSuccessSchema,
183
+ getWithHeadersAnnotation: () => getWithHeadersAnnotation,
184
+ isNoContent: () => isNoContent,
185
+ isStreamSchema: () => isStreamSchema,
186
+ isStreamSse: () => isStreamSse,
187
+ isStreamUint8Array: () => isStreamUint8Array,
188
+ isWithHeaders: () => isWithHeaders,
189
+ isWithHeadersValue: () => isWithHeadersValue,
190
+ rebuildWithHeaders: () => rebuildWithHeaders,
191
+ status: () => status,
192
+ withHeaders: () => withHeaders
193
+ });
194
+
195
+ // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/encoding/Sse.js
196
+ var SseErrorTypeId = "~effect/encoding/Sse/SseError";
197
+ var EventTooLarge = class extends (/* @__PURE__ */ TaggedError("EventTooLarge")) {
198
+ get message() {
199
+ return `Pending SSE event exceeded the maximum size of ${this.maxEventSize}`;
200
+ }
201
+ };
202
+ var SseError = class extends (/* @__PURE__ */ TaggedError("SseError")) {
203
+ /**
204
+ * Marks this value as an SSE decoding error.
205
+ *
206
+ * @since 4.0.0
207
+ */
208
+ [SseErrorTypeId] = SseErrorTypeId;
209
+ /**
210
+ * Delegates the public message to the underlying SSE error reason.
211
+ *
212
+ * @since 4.0.0
213
+ */
214
+ get message() {
215
+ return this.reason.message;
216
+ }
217
+ };
218
+ var defaultMaxEventSize = 10 * 1024 * 1024;
219
+ var decode2 = (options2) => fromTransform((upstream, _scope) => sync(() => {
220
+ let buffer = [];
221
+ let retry;
222
+ const parser = makeParser((event) => {
223
+ if (event._tag === "Retry") {
224
+ retry = event;
225
+ } else {
226
+ buffer.push(event);
227
+ }
228
+ }, options2);
229
+ const pump = flatMap(upstream, (arr) => {
230
+ for (let i = 0; i < arr.length; i++) {
231
+ const error = parser.feed(arr[i]);
232
+ if (error !== void 0) {
233
+ return fail3(error);
234
+ }
235
+ }
236
+ return void_;
237
+ });
238
+ return suspend(function loop() {
239
+ if (isArrayNonEmpty(buffer)) {
240
+ const out = buffer;
241
+ buffer = [];
242
+ return succeed2(out);
243
+ } else if (retry) {
244
+ return fail3(retry);
245
+ }
246
+ return flatMap(pump, loop);
247
+ });
248
+ }));
249
+ var decodeSchema = (schema, options2, parseOptions) => pipeTo(decode2(options2), decode(Event.pipe(decodeTo(schema, transformEvent)), parseOptions)());
250
+ function makeParser(onParse, options2) {
251
+ const maxEventSize = options2?.maxEventSize ?? defaultMaxEventSize;
252
+ let isFirstChunk;
253
+ let buffer;
254
+ let startingPosition;
255
+ let startingFieldLength;
256
+ let discardTrailingNewline;
257
+ let lastEventId;
258
+ let eventName;
259
+ let data;
260
+ reset();
261
+ return {
262
+ feed,
263
+ reset
264
+ };
265
+ function reset() {
266
+ isFirstChunk = true;
267
+ buffer = "";
268
+ startingPosition = 0;
269
+ startingFieldLength = -1;
270
+ discardTrailingNewline = false;
271
+ lastEventId = void 0;
272
+ eventName = void 0;
273
+ data = "";
274
+ }
275
+ function feed(chunk) {
276
+ buffer = buffer ? buffer + chunk : chunk;
277
+ if (isFirstChunk && buffer.startsWith(BOM)) {
278
+ buffer = buffer.slice(BOM.length);
279
+ }
280
+ isFirstChunk = false;
281
+ const length = buffer.length;
282
+ let position = 0;
283
+ while (position < length) {
284
+ if (discardTrailingNewline) {
285
+ if (buffer[position] === "\n") {
286
+ ++position;
287
+ }
288
+ discardTrailingNewline = false;
289
+ }
290
+ let lineLength = -1;
291
+ let fieldLength = startingFieldLength;
292
+ let character;
293
+ for (let index = position + startingPosition; lineLength < 0 && index < length; ++index) {
294
+ character = buffer[index];
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
+ }
303
+ }
304
+ if (lineLength < 0) {
305
+ startingPosition = length - position;
306
+ startingFieldLength = fieldLength;
307
+ break;
308
+ } else {
309
+ startingPosition = 0;
310
+ startingFieldLength = -1;
311
+ }
312
+ parseEventStreamLine(buffer, position, fieldLength, lineLength);
313
+ position += lineLength + 1;
314
+ }
315
+ if (position === length) {
316
+ buffer = "";
317
+ } else if (position > 0) {
318
+ buffer = buffer.slice(position);
319
+ }
320
+ if (buffer.length + data.length > maxEventSize) {
321
+ const error = new SseError({
322
+ reason: new EventTooLarge({
323
+ maxEventSize
324
+ })
325
+ });
326
+ reset();
327
+ return error;
328
+ }
329
+ }
330
+ function parseEventStreamLine(lineBuffer, index, fieldLength, lineLength) {
331
+ if (lineLength === 0) {
332
+ if (data.length > 0) {
333
+ onParse({
334
+ _tag: "Event",
335
+ id: lastEventId,
336
+ event: eventName || "message",
337
+ data: data.slice(0, -1)
338
+ // remove trailing newline
339
+ });
340
+ data = "";
341
+ }
342
+ eventName = void 0;
343
+ return;
344
+ }
345
+ const noValue = fieldLength < 0;
346
+ const field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength));
347
+ let step = 0;
348
+ if (noValue) {
349
+ step = lineLength;
350
+ } else if (lineBuffer[index + fieldLength + 1] === " ") {
351
+ step = fieldLength + 2;
352
+ } else {
353
+ step = fieldLength + 1;
354
+ }
355
+ const position = index + step;
356
+ const valueLength = lineLength - step;
357
+ const value = lineBuffer.slice(position, position + valueLength).toString();
358
+ if (field === "data") {
359
+ data += value ? `${value}
360
+ ` : "\n";
361
+ } else if (field === "event") {
362
+ eventName = value;
363
+ } else if (field === "id" && !value.includes("\0")) {
364
+ lastEventId = value;
365
+ } else if (field === "retry" && /^\d+$/.test(value)) {
366
+ const retry = parseInt(value, 10);
367
+ onParse(new Retry({
368
+ duration: millis(retry),
369
+ lastEventId
370
+ }));
371
+ }
372
+ }
373
+ }
374
+ var BOM = "\uFEFF";
375
+ var EventEncoded = /* @__PURE__ */ Struct({
376
+ id: /* @__PURE__ */ optional(String2),
377
+ event: String2,
378
+ data: String2
379
+ });
380
+ var Event = /* @__PURE__ */ Struct({
381
+ _tag: /* @__PURE__ */ tag("Event"),
382
+ id: /* @__PURE__ */ UndefinedOr(String2),
383
+ event: String2,
384
+ data: String2
385
+ });
386
+ var transformEvent = /* @__PURE__ */ transform({
387
+ decode: (event) => event.id === void 0 ? {
388
+ event: event.event,
389
+ data: event.data
390
+ } : {
391
+ id: event.id,
392
+ event: event.event,
393
+ data: event.data
394
+ },
395
+ encode: (event) => ({
396
+ _tag: "Event",
397
+ id: event.id,
398
+ event: event.event ?? "message",
399
+ data: event.data
400
+ })
401
+ });
402
+ var RetryTypeId = "~effect/encoding/Sse/Retry";
403
+ var Retry = class _Retry extends (/* @__PURE__ */ TaggedClass("Retry")) {
404
+ /**
405
+ * Marks this value as an SSE retry directive for runtime guards.
406
+ *
407
+ * @since 4.0.0
408
+ */
409
+ [RetryTypeId] = RetryTypeId;
410
+ /**
411
+ * Returns `true` when the value is an SSE retry directive.
412
+ *
413
+ * @since 4.0.0
414
+ */
415
+ static is(u) {
416
+ return hasProperty(u, RetryTypeId);
417
+ }
418
+ /**
419
+ * Separates SSE retry directives from regular event values.
420
+ *
421
+ * @since 4.0.0
422
+ */
423
+ static filter(u) {
424
+ return _Retry.is(u) ? succeed(u) : fail(u);
425
+ }
426
+ };
427
+
428
+ // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/httpapi/HttpApiSchema.js
429
+ var StreamSchemaTypeId = "~effect/httpapi/HttpApiSchema/Stream";
430
+ function status(code) {
431
+ const statusCode = typeof code === "string" ? fromLiteral(code) : code;
432
+ return (self) => self.annotate({
433
+ httpApiStatus: statusCode
434
+ });
435
+ }
436
+ var Empty = (code) => Void.pipe(status(code));
437
+ var NoContent = /* @__PURE__ */ Empty(204);
438
+ var Created = /* @__PURE__ */ Empty(201);
439
+ var Accepted = /* @__PURE__ */ Empty(202);
440
+ function asNoContent(options2) {
441
+ return (self) => {
442
+ return Void.pipe(decodeTo(toType(self), transform({
443
+ decode: options2.decode,
444
+ encode: constVoid
445
+ })));
446
+ };
447
+ }
448
+ var streamSchema = /* @__PURE__ */ declare(isStream);
449
+ var StreamSse = (options2) => {
450
+ const events = options2.events ?? (options2.data === void 0 ? void 0 : Struct({
451
+ ...EventEncoded.fields,
452
+ data: fromJsonString(options2.data)
453
+ }));
454
+ if (events === void 0) {
455
+ throw new Error("StreamSse requires either an events schema or a data schema");
456
+ }
457
+ return make(streamSchema.ast, {
458
+ [StreamSchemaTypeId]: StreamSchemaTypeId,
459
+ _tag: "StreamSse",
460
+ mode: "sse",
461
+ sseMode: options2.events === void 0 ? "data" : "events",
462
+ contentType: options2.contentType ?? defaultStreamContentType("sse"),
463
+ events,
464
+ error: options2.error ?? Never
465
+ });
466
+ };
467
+ var StreamUint8Array = (options2) => make(streamSchema.ast, {
468
+ [StreamSchemaTypeId]: StreamSchemaTypeId,
469
+ _tag: "StreamUint8Array",
470
+ mode: "uint8array",
471
+ contentType: options2?.contentType ?? defaultStreamContentType("uint8array")
472
+ });
473
+ var isStreamSchema = (u) => isSchema(u) && hasProperty(u, StreamSchemaTypeId);
474
+ var isStreamSse = (u) => isStreamSchema(u) && u._tag === "StreamSse";
475
+ var isStreamUint8Array = (u) => isStreamSchema(u) && u._tag === "StreamUint8Array";
476
+ function defaultStreamContentType(mode) {
477
+ switch (mode) {
478
+ case "sse":
479
+ return "text/event-stream";
480
+ case "uint8array":
481
+ return "application/octet-stream";
482
+ }
483
+ }
484
+ var WithHeadersTypeId = "~effect/httpapi/HttpApiSchema/WithHeaders";
485
+ var WithHeadersValueTypeId = "~effect/httpapi/HttpApiSchema/WithHeadersValue";
486
+ var isWithHeadersValue = (u) => hasProperty(u, WithHeadersValueTypeId);
487
+ var withHeadersValueSchema = /* @__PURE__ */ declare(isWithHeadersValue);
488
+ function WithHeaders(schema, headers) {
489
+ if (isWithHeaders(schema)) {
490
+ throw new Error("WithHeaders schemas cannot be nested");
491
+ }
492
+ return make(withHeadersValueSchema.ast, {
493
+ [WithHeadersTypeId]: WithHeadersTypeId,
494
+ schema,
495
+ headers: isSchema(headers) ? headers : Struct(headers)
496
+ });
497
+ }
498
+ var withHeaders = (options2) => ({
499
+ [WithHeadersValueTypeId]: WithHeadersValueTypeId,
500
+ body: options2.body,
501
+ headers: options2.headers
502
+ });
503
+ var isWithHeaders = (u) => isSchema(u) && hasProperty(u, WithHeadersTypeId);
504
+ function rebuildWithHeaders(self, schema, headers) {
505
+ return make(self.ast, {
506
+ [WithHeadersTypeId]: WithHeadersTypeId,
507
+ schema,
508
+ headers
509
+ });
510
+ }
511
+ function encodeToWithHeaders(options2, transformation) {
512
+ return (self) => {
513
+ const body = options2.body;
514
+ const headers = Struct(options2.headers);
515
+ const status2 = resolveHttpApiStatus(body.ast);
516
+ const encoding = resolveHttpApiEncoding(body.ast);
517
+ return Struct({
518
+ body,
519
+ headers
520
+ }).pipe(decodeTo(toType(self), transform(transformation))).annotate({
521
+ "~httpApiWithHeaders": {
522
+ body,
523
+ headers,
524
+ headersCodec: toEncoded2(headers)
525
+ },
526
+ httpApiStatus: status2,
527
+ "~httpApiEncoding": encoding
528
+ });
529
+ };
530
+ }
531
+ var MultipartTypeId = "~effect/httpapi/HttpApiSchema/Multipart";
532
+ function asMultipart(options2) {
533
+ return (self) => self.pipe(brand(MultipartTypeId)).annotate({
534
+ "~httpApiEncoding": {
535
+ _tag: "Multipart",
536
+ mode: "buffered",
537
+ contentType: defaultContentType("Multipart"),
538
+ limits: options2
539
+ }
540
+ });
541
+ }
542
+ var MultipartStreamTypeId = "~effect/httpapi/HttpApiSchema/MultipartStream";
543
+ function asMultipartStream(options2) {
544
+ return (self) => self.pipe(brand(MultipartStreamTypeId)).annotate({
545
+ "~httpApiEncoding": {
546
+ _tag: "Multipart",
547
+ mode: "stream",
548
+ contentType: defaultContentType("Multipart"),
549
+ limits: options2
550
+ }
551
+ });
552
+ }
553
+ function asNonMultipartEncoding(self, options2) {
554
+ return self.annotate({
555
+ "~httpApiEncoding": {
556
+ _tag: options2._tag,
557
+ contentType: options2.contentType ?? defaultContentType(options2._tag)
558
+ }
559
+ });
560
+ }
561
+ function defaultContentType(_tag) {
562
+ switch (_tag) {
563
+ case "Multipart":
564
+ return "multipart/form-data";
565
+ case "Json":
566
+ return "application/json";
567
+ case "FormUrlEncoded":
568
+ return "application/x-www-form-urlencoded";
569
+ case "Uint8Array":
570
+ return "application/octet-stream";
571
+ case "Text":
572
+ return "text/plain";
573
+ }
574
+ }
575
+ function asJson(options2) {
576
+ return (self) => asNonMultipartEncoding(self, {
577
+ _tag: "Json",
578
+ ...options2
579
+ });
580
+ }
581
+ function asFormUrlEncoded(options2) {
582
+ return (self) => asNonMultipartEncoding(self, {
583
+ _tag: "FormUrlEncoded",
584
+ ...options2
585
+ });
586
+ }
587
+ function asText(options2) {
588
+ return (self) => asNonMultipartEncoding(self, {
589
+ _tag: "Text",
590
+ ...options2
591
+ });
592
+ }
593
+ function asUint8Array(options2) {
594
+ return (self) => asNonMultipartEncoding(self, {
595
+ _tag: "Uint8Array",
596
+ ...options2
597
+ });
598
+ }
599
+ var isNoContent = (ast) => {
600
+ if (isVoid(ast)) return true;
601
+ const encoded = toEncoded(ast);
602
+ if (isVoid(encoded)) return true;
603
+ const target = ast.encoding?.[0].to;
604
+ if (target === void 0) return false;
605
+ return isVoid(target);
606
+ };
607
+ var resolveHttpApiEncoding = /* @__PURE__ */ resolveAt("~httpApiEncoding");
608
+ var getWithHeadersAnnotation = /* @__PURE__ */ resolveAt("~httpApiWithHeaders");
609
+ var resolveHttpApiStatus = /* @__PURE__ */ resolveAt("httpApiStatus");
610
+ var defaultJsonEncoding = {
611
+ _tag: "Json",
612
+ contentType: "application/json"
613
+ };
614
+ var defaultUrlEncodedEncoding = {
615
+ _tag: "FormUrlEncoded",
616
+ contentType: "application/x-www-form-urlencoded"
617
+ };
618
+ function getEncoding(ast) {
619
+ return resolveHttpApiEncoding(ast) ?? defaultJsonEncoding;
620
+ }
621
+ function getPayloadEncoding(ast, method) {
622
+ const encoding = resolveHttpApiEncoding(ast);
623
+ if (encoding) return encoding;
624
+ return hasBody(method) ? defaultJsonEncoding : defaultUrlEncodedEncoding;
625
+ }
626
+ function getResponseEncoding(ast) {
627
+ const out = getEncoding(ast);
628
+ if (out._tag === "Multipart") {
629
+ throw new Error("Multipart is not supported in response");
630
+ }
631
+ return out;
632
+ }
633
+ function getStatusSuccess(self) {
634
+ return resolveHttpApiStatus(self) ?? 200;
635
+ }
636
+ function getStatusSuccessSchema(schema) {
637
+ if (isWithHeaders(schema)) {
638
+ return resolveHttpApiStatus(schema.ast) ?? getStatusSuccess(schema.schema.ast);
639
+ }
640
+ return getStatusSuccess(schema.ast);
641
+ }
642
+ function getResponseEncodingSchema(schema) {
643
+ if (isWithHeaders(schema) && resolveHttpApiEncoding(schema.ast) === void 0) {
644
+ return getResponseEncoding(schema.schema.ast);
645
+ }
646
+ return getResponseEncoding(schema.ast);
647
+ }
648
+ function getStatusError(self) {
649
+ return resolveHttpApiStatus(self) ?? 500;
650
+ }
651
+ function getStatusErrorSchema(schema) {
652
+ if (isWithHeaders(schema)) {
653
+ return resolveHttpApiStatus(schema.ast) ?? getStatusError(schema.schema.ast);
654
+ }
655
+ return getStatusError(schema.ast);
656
+ }
657
+
658
+ // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/httpapi/internal/mediaType.js
659
+ function normalize(contentType) {
660
+ const normalized = contentType.toLowerCase().trim();
661
+ const index = normalized.indexOf(";");
662
+ return index === -1 ? normalized : normalized.slice(0, index).trim();
663
+ }
664
+
665
+ // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/httpapi/HttpApiEndpoint.js
666
+ var TypeId = "~effect/httpapi/HttpApiEndpoint";
667
+ var isHttpApiEndpoint = (u) => hasProperty(u, TypeId);
668
+ function getPayloadSchemas(endpoint2) {
669
+ const result = [];
670
+ for (const {
671
+ schemas
672
+ } of endpoint2.payload.values()) {
673
+ result.push(...schemas);
674
+ }
675
+ return result;
676
+ }
677
+ function getSuccessSchemas(endpoint2) {
678
+ const schemas = Array.from(endpoint2.success);
679
+ return isArrayNonEmpty(schemas) ? schemas : [NoContent];
680
+ }
681
+ function getErrorSchemas(endpoint2) {
682
+ const schemas = new Set(endpoint2.error);
683
+ const transform2 = endpoint2.disableCodecs ? identity : transformResponseSchema;
684
+ for (const middleware of endpoint2.middlewares) {
685
+ const key = middleware;
686
+ for (const schema of key.error) {
687
+ schemas.add(transform2(schema));
688
+ }
689
+ }
690
+ return Array.from(schemas);
691
+ }
692
+ var Proto = {
693
+ [TypeId]: TypeId,
694
+ pipe() {
695
+ return pipeArguments(this, arguments);
696
+ },
697
+ prefix(prefix) {
698
+ return makeProto({
699
+ ...optionsFromEndpoint(this),
700
+ path: prefixPath(this.path, prefix)
701
+ });
702
+ },
703
+ middleware(middleware) {
704
+ return makeProto({
705
+ ...optionsFromEndpoint(this),
706
+ middlewares: /* @__PURE__ */ new Set([...this.middlewares, middleware])
707
+ });
708
+ },
709
+ annotate(key, value) {
710
+ return makeProto({
711
+ ...optionsFromEndpoint(this),
712
+ annotations: add(this.annotations, key, value)
713
+ });
714
+ },
715
+ annotateMerge(annotations) {
716
+ return makeProto({
717
+ ...optionsFromEndpoint(this),
718
+ annotations: merge(this.annotations, annotations)
719
+ });
720
+ }
721
+ };
722
+ var optionsFromEndpoint = (endpoint2) => ({
723
+ identifier: endpoint2.identifier,
724
+ path: endpoint2.path,
725
+ method: endpoint2.method,
726
+ params: endpoint2.params,
727
+ query: endpoint2.query,
728
+ headers: endpoint2.headers,
729
+ payload: endpoint2.payload,
730
+ success: endpoint2.success,
731
+ error: endpoint2.error,
732
+ annotations: endpoint2.annotations,
733
+ middlewares: endpoint2.middlewares,
734
+ disableCodecs: endpoint2.disableCodecs
735
+ });
736
+ function makeProto(options2) {
737
+ function HttpApiEndpoint() {
738
+ }
739
+ Object.setPrototypeOf(HttpApiEndpoint, Proto);
740
+ return Object.assign(HttpApiEndpoint, options2);
741
+ }
742
+ var make3 = (method) => (identifier, path, options2) => {
743
+ const disableCodecs = options2?.disableCodecs ?? false;
744
+ const transformStringTree = disableCodecs ? identity : toCodecStringTree;
745
+ return makeProto({
746
+ identifier,
747
+ path,
748
+ method,
749
+ params: ensureStruct(options2?.params, transformStringTree),
750
+ query: ensureStruct(options2?.query, transformStringTree),
751
+ headers: ensureStruct(options2?.headers, transformStringTree),
752
+ payload: getPayload(options2?.payload, method, disableCodecs),
753
+ success: getSuccessResponse(options2?.success, method, disableCodecs),
754
+ error: getErrorResponse(options2?.error, disableCodecs),
755
+ annotations: empty(),
756
+ middlewares: /* @__PURE__ */ new Set(),
757
+ disableCodecs
758
+ });
759
+ };
760
+ function ensureStruct(params, transform2) {
761
+ if (params === void 0) return void 0;
762
+ if (isSchema(params)) return transform2(params);
763
+ return transform2(Struct(params));
764
+ }
765
+ function getPayload(payload, method, disableCodecs) {
766
+ const result = /* @__PURE__ */ new Map();
767
+ if (payload === void 0) return result;
768
+ const schemas = Array.isArray(payload) ? payload : isSchema(payload) ? [payload] : [Struct(payload).pipe(asFormUrlEncoded())];
769
+ const transform2 = disableCodecs ? identity : transformPayload;
770
+ for (const schema of schemas) {
771
+ const encoding = getPayloadEncoding(schema.ast, method);
772
+ const contentType = normalize(encoding.contentType);
773
+ const existing = result.get(contentType);
774
+ if (existing) {
775
+ if (existing.encoding._tag !== encoding._tag) {
776
+ throw new Error(`Multiple payload encodings for content-type: ${encoding.contentType}`);
777
+ }
778
+ if (existing.encoding._tag === "Multipart") {
779
+ throw new Error(`Multiple multipart payloads for content-type: ${encoding.contentType}`);
780
+ }
781
+ existing.schemas.push(transform2(schema, method));
782
+ } else {
783
+ result.set(contentType, {
784
+ encoding,
785
+ schemas: [transform2(schema, method)]
786
+ });
787
+ }
788
+ }
789
+ return result;
790
+ }
791
+ var reservedStreamFailureEvent = "effect/httpapi/stream/failure";
792
+ function getSuccessResponse(success, method, disableCodecs) {
793
+ if (success === void 0) return /* @__PURE__ */ new Set();
794
+ const schemas = ensure(success);
795
+ validateSuccessResponse(schemas, method);
796
+ return new Set(disableCodecs ? schemas : schemas.map(transformResponseSchema));
797
+ }
798
+ var transformResponseSchema = /* @__PURE__ */ memoize((schema) => {
799
+ if (isStreamSchema(schema)) return schema;
800
+ if (isWithHeaders(schema)) {
801
+ const inner = isStreamSchema(schema.schema) ? schema.schema : applyResponseEncoding(schema.schema, getResponseEncodingSchema(schema));
802
+ return rebuildWithHeaders(schema, inner, toCodecStringTree(schema.headers));
803
+ }
804
+ return transformResponse(schema);
805
+ });
806
+ function getErrorResponse(error, disableCodecs) {
807
+ if (error === void 0) return /* @__PURE__ */ new Set();
808
+ const schemas = ensure(error);
809
+ for (const schema of schemas) {
810
+ const body = isWithHeaders(schema) ? schema.schema : schema;
811
+ if (isStreamSchema(body)) {
812
+ throw new Error("Streaming schemas are not supported in error responses");
813
+ }
814
+ }
815
+ validateResponseExclusivity(schemas, getStatusErrorSchema);
816
+ return new Set(disableCodecs ? schemas : schemas.map(transformResponseSchema));
817
+ }
818
+ function validateSuccessResponse(schemas, method) {
819
+ let hasStream = false;
820
+ const statuses = /* @__PURE__ */ new Map();
821
+ for (const schema of schemas) {
822
+ const inner = isWithHeaders(schema) ? schema.schema : schema;
823
+ const status2 = getStatusSuccessSchema(schema);
824
+ if (isStreamSchema(inner)) {
825
+ validateStreamSuccess(inner, method);
826
+ if (hasStream) {
827
+ throw new Error("Multiple streaming success responses are not supported");
828
+ }
829
+ hasStream = true;
830
+ const entry = getStatusEntry(statuses, status2);
831
+ if (entry.noContent) {
832
+ throw new Error(`Cannot combine no-content and streaming success responses for status: ${status2}`);
833
+ }
834
+ if (entry.bufferedContentTypes.has(normalize(inner.contentType))) {
835
+ throw new Error(`Cannot combine buffered and streaming success responses for status ${status2} and content-type: ${inner.contentType}`);
836
+ }
837
+ statuses.set(status2, {
838
+ ...entry,
839
+ stream: inner
840
+ });
841
+ } else {
842
+ const entry = getStatusEntry(statuses, status2);
843
+ const noContent = isNoContent(inner.ast);
844
+ if (entry.stream !== void 0) {
845
+ if (noContent) {
846
+ throw new Error(`Cannot combine no-content and streaming success responses for status: ${status2}`);
847
+ }
848
+ const encoding = getResponseEncodingSchema(schema);
849
+ if (normalize(encoding.contentType) === normalize(entry.stream.contentType)) {
850
+ throw new Error(`Cannot combine buffered and streaming success responses for status ${status2} and content-type: ${encoding.contentType}`);
851
+ }
852
+ }
853
+ if (!noContent) {
854
+ entry.bufferedContentTypes.add(normalize(getResponseEncodingSchema(schema).contentType));
855
+ }
856
+ entry.noContent = entry.noContent || noContent;
857
+ }
858
+ }
859
+ validateResponseExclusivity(schemas, getStatusSuccessSchema);
860
+ }
861
+ function getStatusEntry(statuses, status2) {
862
+ let entry = statuses.get(status2);
863
+ if (entry === void 0) {
864
+ entry = {
865
+ bufferedContentTypes: /* @__PURE__ */ new Set(),
866
+ noContent: false
867
+ };
868
+ statuses.set(status2, entry);
869
+ }
870
+ return entry;
871
+ }
872
+ function validateResponseExclusivity(schemas, getStatus) {
873
+ const statuses = /* @__PURE__ */ new Map();
874
+ for (const schema of schemas) {
875
+ const status2 = getStatus(schema);
876
+ const withHeadersAnnotation = getWithHeadersAnnotation(schema.ast);
877
+ const body = isWithHeaders(schema) ? schema.schema : withHeadersAnnotation?.body ?? schema;
878
+ const contentType = isNoContent(body.ast) ? "" : normalize(isStreamSchema(body) ? body.contentType : getResponseEncodingSchema(schema).contentType);
879
+ let entry = statuses.get(status2);
880
+ if (entry === void 0) {
881
+ entry = {
882
+ headerContentType: void 0,
883
+ plainContentTypes: /* @__PURE__ */ new Set()
884
+ };
885
+ statuses.set(status2, entry);
886
+ }
887
+ const combineError = () => new Error(`Cannot combine a response with headers with another response for status ${status2} and content-type: ${contentType || "<no content>"}`);
888
+ if (isWithHeaders(schema) || withHeadersAnnotation !== void 0) {
889
+ if (entry.headerContentType !== void 0) {
890
+ throw new Error(`Cannot declare multiple responses with headers for status ${status2}`);
891
+ }
892
+ if (entry.plainContentTypes.has(contentType)) throw combineError();
893
+ entry.headerContentType = contentType;
894
+ } else {
895
+ if (entry.headerContentType === contentType) throw combineError();
896
+ entry.plainContentTypes.add(contentType);
897
+ }
898
+ }
899
+ }
900
+ function validateStreamSuccess(schema, method) {
901
+ if (method === "HEAD") {
902
+ throw new Error("HEAD endpoints cannot declare streaming success responses");
903
+ }
904
+ if (isStreamSse(schema) && hasReservedSseEventName(schema.events.ast)) {
905
+ throw new Error(`SSE event name is reserved: ${reservedStreamFailureEvent}`);
906
+ }
907
+ }
908
+ function hasReservedSseEventName(ast) {
909
+ return hasReservedEventName(toEncoded(ast), /* @__PURE__ */ new Set());
910
+ }
911
+ function hasReservedEventName(ast, seen) {
912
+ if (seen.has(ast)) return false;
913
+ seen.add(ast);
914
+ if (isUnion(ast)) {
915
+ return ast.types.some((type) => hasReservedEventName(type, seen));
916
+ }
917
+ if (isSuspend(ast)) {
918
+ return hasReservedEventName(ast.thunk(), seen);
919
+ }
920
+ if (!isObjects(ast)) return false;
921
+ const event = ast.propertySignatures.find((ps) => ps.name === "event");
922
+ return event !== void 0 && hasReservedEventLiteral(event.type, seen);
923
+ }
924
+ function hasReservedEventLiteral(ast, seen) {
925
+ if (seen.has(ast)) return false;
926
+ seen.add(ast);
927
+ const encoded = toEncoded(ast);
928
+ if (encoded !== ast) {
929
+ return hasReservedEventLiteral(encoded, seen);
930
+ }
931
+ if (isLiteral(ast)) {
932
+ return ast.literal === reservedStreamFailureEvent;
933
+ }
934
+ if (isUnion(ast)) {
935
+ return ast.types.some((type) => hasReservedEventLiteral(type, seen));
936
+ }
937
+ if (isSuspend(ast)) {
938
+ return hasReservedEventLiteral(ast.thunk(), seen);
939
+ }
940
+ return false;
941
+ }
942
+ function transformResponse(schema) {
943
+ const encoding = getResponseEncoding(schema.ast);
944
+ const withHeaders2 = getWithHeadersAnnotation(schema.ast);
945
+ if (withHeaders2 === void 0) {
946
+ return applyResponseEncoding(schema, encoding);
947
+ }
948
+ const headers = toEncoded2(withHeaders2.headers);
949
+ return Struct({
950
+ body: applyResponseEncoding(toEncoded2(withHeaders2.body), encoding),
951
+ headers
952
+ }).pipe(decodeTo(schema)).annotate({
953
+ "~httpApiWithHeaders": {
954
+ ...withHeaders2,
955
+ headersCodec: toCodecStringTree(headers)
956
+ }
957
+ });
958
+ }
959
+ function applyResponseEncoding(schema, encoding) {
960
+ switch (encoding._tag) {
961
+ case "Json":
962
+ return toCodecJson(schema);
963
+ case "FormUrlEncoded":
964
+ return toCodecStringTree(schema);
965
+ case "Text":
966
+ case "Uint8Array":
967
+ return schema;
968
+ }
969
+ }
970
+ function transformPayload(schema, method) {
971
+ const encoding = getPayloadEncoding(schema.ast, method);
972
+ switch (encoding._tag) {
973
+ case "Json":
974
+ return toCodecJson(schema);
975
+ case "FormUrlEncoded":
976
+ return toCodecStringTree(schema);
977
+ case "Text":
978
+ case "Uint8Array":
979
+ case "Multipart":
980
+ return schema;
981
+ }
982
+ }
983
+ var get2 = /* @__PURE__ */ make3("GET");
984
+ var query = /* @__PURE__ */ make3("QUERY");
985
+ var post = /* @__PURE__ */ make3("POST");
986
+ var put = /* @__PURE__ */ make3("PUT");
987
+ var patch = /* @__PURE__ */ make3("PATCH");
988
+ var del = /* @__PURE__ */ make3("DELETE");
989
+ var head = /* @__PURE__ */ make3("HEAD");
990
+ var options = /* @__PURE__ */ make3("OPTIONS");
991
+
992
+ // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/httpapi/HttpApi.js
993
+ var TypeId2 = "~effect/httpapi/HttpApi";
994
+ var isHttpApi = (u) => hasProperty(u, TypeId2);
995
+ var Proto2 = {
996
+ [TypeId2]: TypeId2,
997
+ pipe() {
998
+ return pipeArguments(this, arguments);
999
+ },
1000
+ add(...toAdd) {
1001
+ const groups = {
1002
+ ...this.groups
1003
+ };
1004
+ for (const group2 of toAdd) {
1005
+ assignProperty(groups, group2.identifier, group2);
1006
+ }
1007
+ return makeProto2({
1008
+ ...optionsFromApi(this),
1009
+ groups
1010
+ });
1011
+ },
1012
+ addHttpApi(api) {
1013
+ const newGroups = {
1014
+ ...this.groups
1015
+ };
1016
+ for (const key of Object.keys(api.groups)) {
1017
+ const group2 = api.groups[key];
1018
+ assignProperty(newGroups, key, group2.annotateMerge(merge(api.annotations, group2.annotations)));
1019
+ }
1020
+ return makeProto2({
1021
+ ...optionsFromApi(this),
1022
+ groups: newGroups
1023
+ });
1024
+ },
1025
+ prefix(prefix) {
1026
+ return makeProto2({
1027
+ ...optionsFromApi(this),
1028
+ groups: map(this.groups, (group2) => group2.prefix(prefix))
1029
+ });
1030
+ },
1031
+ middleware(tag2) {
1032
+ return makeProto2({
1033
+ ...optionsFromApi(this),
1034
+ groups: map(this.groups, (group2) => group2.middleware(tag2))
1035
+ });
1036
+ },
1037
+ annotate(key, value) {
1038
+ return makeProto2({
1039
+ ...optionsFromApi(this),
1040
+ annotations: add(this.annotations, key, value)
1041
+ });
1042
+ },
1043
+ annotateMerge(annotations) {
1044
+ return makeProto2({
1045
+ ...optionsFromApi(this),
1046
+ annotations: merge(this.annotations, annotations)
1047
+ });
1048
+ }
1049
+ };
1050
+ var optionsFromApi = (api) => ({
1051
+ identifier: api.identifier,
1052
+ groups: api.groups,
1053
+ annotations: api.annotations
1054
+ });
1055
+ var makeProto2 = (options2) => {
1056
+ function HttpApi() {
1057
+ }
1058
+ Object.setPrototypeOf(HttpApi, Proto2);
1059
+ return Object.assign(HttpApi, options2);
1060
+ };
1061
+ var make4 = (identifier) => makeProto2({
1062
+ identifier,
1063
+ groups: {},
1064
+ annotations: empty()
1065
+ });
1066
+ var reflect = (self, options2) => {
1067
+ const groups = Object.values(self.groups);
1068
+ for (const group2 of groups) {
1069
+ const groupAnnotations = merge(self.annotations, group2.annotations);
1070
+ options2.onGroup({
1071
+ group: group2,
1072
+ mergedAnnotations: groupAnnotations
1073
+ });
1074
+ const endpoints = Object.values(group2.endpoints);
1075
+ for (const endpoint2 of endpoints) {
1076
+ if (options2.predicate && !options2.predicate({
1077
+ endpoint: endpoint2,
1078
+ group: group2
1079
+ })) continue;
1080
+ options2.onEndpoint({
1081
+ group: group2,
1082
+ endpoint: endpoint2,
1083
+ middleware: endpoint2.middlewares,
1084
+ mergedAnnotations: merge(groupAnnotations, endpoint2.annotations),
1085
+ successes: extractResponseContent(getSuccessSchemas(endpoint2), getStatusSuccessSchema),
1086
+ errors: extractResponseContent(getErrorSchemas(endpoint2), getStatusErrorSchema)
1087
+ });
1088
+ }
1089
+ }
1090
+ };
1091
+ var extractResponseContent = (schemas, getStatus) => {
1092
+ const map7 = /* @__PURE__ */ new Map();
1093
+ schemas.forEach(add2);
1094
+ return map7;
1095
+ function add2(schema) {
1096
+ const body = isWithHeaders(schema) ? schema.schema : schema;
1097
+ if (isStreamSchema(body)) return;
1098
+ const status2 = getStatus(schema);
1099
+ const schemas2 = map7.get(status2);
1100
+ if (schemas2 === void 0) {
1101
+ map7.set(status2, [schema]);
1102
+ } else {
1103
+ schemas2.push(schema);
1104
+ }
1105
+ }
1106
+ };
1107
+ var AdditionalSchemas = class extends (/* @__PURE__ */ Service()("effect/httpapi/HttpApi/AdditionalSchemas")) {
1108
+ };
1109
+ var ParseOptions = class extends (/* @__PURE__ */ Service()("effect/httpapi/HttpApi/ParseOptions")) {
1110
+ };
1111
+
1112
+ // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/httpapi/internal/path.js
1113
+ var emptyParamNames = /* @__PURE__ */ new Set();
1114
+ function getParamNames(schema) {
1115
+ if (schema === void 0) return emptyParamNames;
1116
+ const ast = getLastEncoding(schema.ast);
1117
+ return isObjects(ast) && ast.indexSignatures.length === 0 ? new Set(ast.propertySignatures.map((ps) => String(ps.name))) : void 0;
1118
+ }
1119
+
1120
+ // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/httpapi/HttpApiClient.js
1121
+ var HttpApiClient_exports = {};
1122
+ __export(HttpApiClient_exports, {
1123
+ endpoint: () => endpoint,
1124
+ group: () => group,
1125
+ make: () => make5,
1126
+ makeClient: () => makeClient,
1127
+ makeWith: () => makeWith,
1128
+ urlBuilder: () => urlBuilder
1129
+ });
1130
+ var makeClient = (api, options2) => gen(function* () {
1131
+ const services = yield* context();
1132
+ const httpClient = options2.httpClient.pipe(options2?.baseUrl === void 0 ? identity : mapRequest(prependUrl(options2.baseUrl.toString())));
1133
+ function executeMiddleware(group2, endpoint2, request, middlewareKeys, index) {
1134
+ if (index === -1) {
1135
+ return httpClient.execute(request);
1136
+ }
1137
+ const middleware = services.mapUnsafe.get(middlewareKeys[index]);
1138
+ if (middleware === void 0) {
1139
+ return executeMiddleware(group2, endpoint2, request, middlewareKeys, index - 1);
1140
+ }
1141
+ return middleware({
1142
+ endpoint: endpoint2,
1143
+ group: group2,
1144
+ request,
1145
+ next(request2) {
1146
+ return executeMiddleware(group2, endpoint2, request2, middlewareKeys, index - 1);
1147
+ }
1148
+ });
1149
+ }
1150
+ reflect(api, {
1151
+ predicate: options2?.predicate,
1152
+ onGroup(onGroupOptions) {
1153
+ options2.onGroup?.(onGroupOptions);
1154
+ },
1155
+ onEndpoint(onEndpointOptions) {
1156
+ const {
1157
+ group: group2,
1158
+ endpoint: endpoint2,
1159
+ errors: errors2,
1160
+ successes,
1161
+ mergedAnnotations
1162
+ } = onEndpointOptions;
1163
+ const parseOptions = getOrUndefined(mergedAnnotations, ParseOptions);
1164
+ const makeUrl = compilePath(endpoint2.path, endpoint2.params);
1165
+ const decodeMap = {
1166
+ orElse: statusOrElse
1167
+ };
1168
+ const errorAlternatives = /* @__PURE__ */ new Map();
1169
+ for (const [status2, schemas] of errors2.entries()) {
1170
+ const grouped = groupSchemasByContentType(schemas);
1171
+ for (const [contentType, schemas2] of grouped.entries()) {
1172
+ addResponseAlternative(errorAlternatives, status2, contentType, schemasToResponse(schemas2, parseOptions));
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));
1189
+ }
1190
+ }
1191
+ for (const streamSuccess of getStreamSuccessSchemas(endpoint2)) {
1192
+ const streamSchema2 = isWithHeadersStreamSuccess(streamSuccess) ? streamSuccess.schema : streamSuccess;
1193
+ addResponseAlternative(successAlternatives, getStatusSuccessSchema(streamSuccess), streamSchema2.contentType, streamToResponse(streamSuccess, parseOptions));
1194
+ }
1195
+ for (const [status2, alternatives] of successAlternatives.entries()) {
1196
+ decodeMap[status2] = makeResponseDecoder(alternatives);
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);
1204
+ const middlewareKeys = Array.from(onEndpointOptions.middleware, (tag2) => `${tag2.key}/Client`);
1205
+ const endpointFn = fnUntraced(function* (request) {
1206
+ let httpRequest = make2(endpoint2.method)(endpoint2.path);
1207
+ if (request !== void 0) {
1208
+ if (encodeParams !== void 0) {
1209
+ const params = yield* encodeParams(request.params);
1210
+ httpRequest = setUrl(httpRequest, makeUrl(params));
1211
+ }
1212
+ if (encodePayload !== void 0) {
1213
+ if (hasBody(endpoint2.method)) {
1214
+ if (request.payload instanceof FormData) {
1215
+ httpRequest = bodyFormData(httpRequest, request.payload);
1216
+ } else {
1217
+ const body = yield* encodePayload(request.payload);
1218
+ httpRequest = setBody(httpRequest, body);
1219
+ }
1220
+ } else {
1221
+ const urlParams2 = yield* encodePayload(request.payload);
1222
+ httpRequest = appendUrlParams(httpRequest, urlParams2);
1223
+ }
1224
+ }
1225
+ if (encodeHeaders !== void 0) {
1226
+ const headers = yield* encodeHeaders(request.headers);
1227
+ httpRequest = setHeaders(httpRequest, headers);
1228
+ }
1229
+ if (encodeQuery !== void 0) {
1230
+ const query2 = yield* encodeQuery(request.query);
1231
+ httpRequest = appendUrlParams(httpRequest, query2);
1232
+ }
1233
+ }
1234
+ const response = yield* executeMiddleware(group2, endpoint2, httpRequest, middlewareKeys, middlewareKeys.length - 1);
1235
+ if (request?.responseMode === "response-only") {
1236
+ return response;
1237
+ }
1238
+ const decoded = (decodeMap[response.status] ?? decodeMap.orElse)(response, request?.sseOptions);
1239
+ const value = yield* options2.transformResponse === void 0 ? decoded : options2.transformResponse(decoded);
1240
+ return request?.responseMode === "decoded-and-response" ? [value, response] : value;
1241
+ });
1242
+ options2.onEndpoint({
1243
+ ...onEndpointOptions,
1244
+ endpointFn
1245
+ });
1246
+ }
1247
+ });
1248
+ });
1249
+ var make5 = (api, options2) => flatMap(HttpClient, (httpClient) => makeWith(api, {
1250
+ ...options2,
1251
+ httpClient: options2?.transformClient ? options2.transformClient(httpClient) : httpClient
1252
+ }));
1253
+ var makeWith = (api, options2) => {
1254
+ const client = {};
1255
+ return makeClient(api, {
1256
+ ...options2,
1257
+ onGroup({
1258
+ group: group2
1259
+ }) {
1260
+ if (group2.topLevel) return;
1261
+ assignProperty(client, group2.identifier, {});
1262
+ },
1263
+ onEndpoint({
1264
+ endpoint: endpoint2,
1265
+ endpointFn,
1266
+ group: group2
1267
+ }) {
1268
+ assignProperty(group2.topLevel ? client : client[group2.identifier], endpoint2.identifier, endpointFn);
1269
+ }
1270
+ }).pipe(as(client));
1271
+ };
1272
+ var group = (api, options2) => {
1273
+ const client = {};
1274
+ return makeClient(api, {
1275
+ ...options2,
1276
+ predicate: ({
1277
+ group: group2
1278
+ }) => group2.identifier === options2.group,
1279
+ onEndpoint({
1280
+ endpoint: endpoint2,
1281
+ endpointFn
1282
+ }) {
1283
+ assignProperty(client, endpoint2.identifier, endpointFn);
1284
+ }
1285
+ }).pipe(map2(() => client));
1286
+ };
1287
+ var endpoint = (api, options2) => {
1288
+ let client = void 0;
1289
+ return makeClient(api, {
1290
+ ...options2,
1291
+ httpClient: options2.transformClient ? options2.transformClient(options2.httpClient) : options2.httpClient,
1292
+ predicate: ({
1293
+ endpoint: endpoint2,
1294
+ group: group2
1295
+ }) => group2.identifier === options2.group && endpoint2.identifier === options2.endpoint,
1296
+ onEndpoint({
1297
+ endpointFn
1298
+ }) {
1299
+ client = endpointFn;
1300
+ }
1301
+ }).pipe(map2(() => client));
1302
+ };
1303
+ var urlBuilder = (api, options2) => {
1304
+ const builder = {};
1305
+ reflect(api, {
1306
+ onGroup({
1307
+ group: group2
1308
+ }) {
1309
+ if (group2.topLevel) return;
1310
+ assignProperty(builder, group2.identifier, {});
1311
+ },
1312
+ onEndpoint({
1313
+ group: group2,
1314
+ endpoint: endpoint2,
1315
+ mergedAnnotations
1316
+ }) {
1317
+ const parseOptions = getOrUndefined(mergedAnnotations, ParseOptions);
1318
+ 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);
1321
+ const endpointBuilder = (request) => {
1322
+ const params = request?.params;
1323
+ const path = params === void 0 ? endpoint2.path : makeUrl(encodeParams === void 0 ? params : encodeParams(params));
1324
+ const queryInput = request?.query === void 0 ? void 0 : encodeQuery === void 0 ? request.query : encodeQuery(request.query);
1325
+ const urlParams2 = queryInput === void 0 ? empty2 : fromInput(queryInput);
1326
+ if (options2?.baseUrl === void 0) {
1327
+ const query2 = toString(urlParams2);
1328
+ return query2 === "" ? path : `${path}?${query2}`;
1329
+ }
1330
+ const url = new URL(prependUrl(get(path), options2.baseUrl.toString()).url);
1331
+ for (const [key, value] of urlParams2.params) {
1332
+ if (value !== void 0) {
1333
+ url.searchParams.append(key, value);
1334
+ }
1335
+ }
1336
+ return url.toString();
1337
+ };
1338
+ assignProperty(group2.topLevel ? builder : builder[group2.identifier], endpoint2.identifier, endpointBuilder);
1339
+ }
1340
+ });
1341
+ return builder;
1342
+ };
1343
+ var paramsRegExp = /(\/?):(\w+)(\?)?/g;
1344
+ var compilePath = (path, schema) => {
1345
+ if (schema === void 0 || !path.includes(":")) {
1346
+ return (_) => path;
1347
+ }
1348
+ const paramNames = getParamNames(schema);
1349
+ return (params) => {
1350
+ return path.replace(paramsRegExp, (match, slash, key, optional2) => {
1351
+ if (paramNames !== void 0 && !paramNames.has(key)) {
1352
+ return match;
1353
+ }
1354
+ const value = params[key];
1355
+ if (value === void 0) {
1356
+ if (optional2 !== void 0) {
1357
+ return "";
1358
+ }
1359
+ throw new Error(`Missing path parameter: ${key}`);
1360
+ }
1361
+ return `${slash}${encodeURIComponent(value)}`;
1362
+ });
1363
+ };
1364
+ };
1365
+ function schemasToResponse(schemas, options2) {
1366
+ const hasWithHeaders = schemas.some((schema) => isWithHeaders(schema) || getWithHeadersAnnotation(schema.ast) !== void 0);
1367
+ const codec = hasWithHeaders ? Union(schemas.map(toCodecArrayBufferWithHeaders)) : toCodecArrayBuffer(schemas);
1368
+ const decode3 = decodeEffect(codec, options2);
1369
+ return (response) => flatMap(response.arrayBuffer, hasWithHeaders ? (body) => decode3({
1370
+ body,
1371
+ headers: response.headers
1372
+ }) : decode3);
1373
+ }
1374
+ function toCodecArrayBufferWithHeaders(schema) {
1375
+ const isWithHeaders2 = isWithHeaders(schema);
1376
+ const annotation = getWithHeadersAnnotation(schema.ast);
1377
+ if (annotation !== void 0) {
1378
+ return Struct({
1379
+ body: fromArrayBuffer(annotation.body),
1380
+ headers: annotation.headersCodec
1381
+ }).pipe(decodeTo(schema));
1382
+ }
1383
+ const body = isWithHeaders2 ? schema.schema : schema;
1384
+ return Struct({
1385
+ body: fromArrayBuffer(body).pipe(decodeTo(body)),
1386
+ headers: isWithHeaders2 ? schema.headers : Unknown
1387
+ }).pipe(decodeTo(isWithHeaders2 ? schema : toType(schema), transform({
1388
+ decode: (value) => isWithHeaders2 ? withHeaders(value) : value.body,
1389
+ encode: (value) => isWithHeaders2 ? value : {
1390
+ body: value,
1391
+ headers: void 0
1392
+ }
1393
+ })));
1394
+ }
1395
+ function addResponseAlternative(map7, status2, contentType, decode3) {
1396
+ const normalizedContentType = normalize(contentType);
1397
+ const alternatives = map7.get(status2);
1398
+ if (alternatives === void 0) {
1399
+ map7.set(status2, [{
1400
+ contentType: normalizedContentType,
1401
+ decode: decode3
1402
+ }]);
1403
+ } else {
1404
+ alternatives.push({
1405
+ contentType: normalizedContentType,
1406
+ decode: decode3
1407
+ });
1408
+ }
1409
+ }
1410
+ function makeResponseDecoder(alternatives) {
1411
+ const first = alternatives[0];
1412
+ if (alternatives.length === 1 && first !== void 0) {
1413
+ return first.decode;
1414
+ }
1415
+ return (response, sseOptions) => {
1416
+ const contentType = normalize(response.headers["content-type"] ?? "");
1417
+ const alternative = alternatives.find((alternative2) => alternative2.contentType === contentType);
1418
+ return alternative === void 0 ? failUnsupportedContentType(response, contentType, alternatives) : alternative.decode(response, sseOptions);
1419
+ };
1420
+ }
1421
+ function groupSchemasByContentType(schemas) {
1422
+ const grouped = /* @__PURE__ */ new Map();
1423
+ for (const schema of schemas) {
1424
+ const body = isWithHeaders(schema) ? schema.schema : schema;
1425
+ const contentType = isNoContent(body.ast) ? "" : normalize(getResponseEncodingSchema(schema).contentType);
1426
+ const existing = grouped.get(contentType);
1427
+ if (existing === void 0) {
1428
+ grouped.set(contentType, [schema]);
1429
+ } else {
1430
+ existing.push(schema);
1431
+ }
1432
+ }
1433
+ return grouped;
1434
+ }
1435
+ function failUnsupportedContentType(response, contentType, alternatives) {
1436
+ const expected = Array.from(new Set(alternatives.map((alternative) => alternative.contentType))).join(", ");
1437
+ return fail3(new HttpClientError({
1438
+ reason: new DecodeError({
1439
+ request: response.request,
1440
+ response,
1441
+ description: `Unsupported response content-type for status ${response.status}: ${contentType || "<missing>"}. Expected one of: ${expected}`
1442
+ })
1443
+ }));
1444
+ }
1445
+ var reservedStreamFailureEvent2 = "effect/httpapi/stream/failure";
1446
+ var isWithHeadersStreamSuccess = (schema) => isWithHeaders(schema);
1447
+ function getStreamSuccessSchemas(endpoint2) {
1448
+ const schemas = [];
1449
+ for (const schema of endpoint2.success) {
1450
+ const body = isWithHeaders(schema) ? schema.schema : schema;
1451
+ if (isStreamSchema(body)) {
1452
+ schemas.push(schema);
1453
+ }
1454
+ }
1455
+ return schemas;
1456
+ }
1457
+ function streamToResponse(successSchema, options2) {
1458
+ const isWithHeaders2 = isWithHeadersStreamSuccess(successSchema);
1459
+ const streamSchema2 = isWithHeaders2 ? successSchema.schema : successSchema;
1460
+ const sse = isStreamUint8Array(streamSchema2) ? void 0 : {
1461
+ declaration: streamSchema2,
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));
1465
+ if (!isWithHeaders2) return toStream;
1466
+ const decodeHeaders = decodeUnknownEffect(successSchema.headers, options2);
1467
+ return (response, sseOptions) => flatMap(decodeHeaders(response.headers), (headers) => map2(toStream(response, sseOptions), (body) => withHeaders({
1468
+ body,
1469
+ headers
1470
+ })));
1471
+ }
1472
+ function makeSseDecoder(declaration, parseOptions) {
1473
+ const Event2 = Union([Struct({
1474
+ id: optional(String2),
1475
+ event: Literal(reservedStreamFailureEvent2),
1476
+ data: fromJsonString(toCodecJson(Cause(declaration.error, Defect())))
1477
+ }), declaration.events]);
1478
+ const defaultDecoder = decodeSchema(Event2, void 0, parseOptions);
1479
+ return (options2) => options2 === void 0 ? defaultDecoder : decodeSchema(Event2, options2, parseOptions);
1480
+ }
1481
+ function decodeSseStream(stream, declaration, decoder) {
1482
+ const events = transformPull(stream.pipe(decodeText, pipeThroughChannel(decoder)), (pull) => sync(() => {
1483
+ let pendingFailureCause = void 0;
1484
+ return suspend(() => {
1485
+ if (pendingFailureCause !== void 0) {
1486
+ return failCause(pendingFailureCause);
1487
+ }
1488
+ return flatMap(pull, (events2) => {
1489
+ for (let i = 0; i < events2.length; i++) {
1490
+ const event = events2[i];
1491
+ if (event.event === reservedStreamFailureEvent2 && isCause(event.data)) {
1492
+ if (i === 0) {
1493
+ return failCause(event.data);
1494
+ }
1495
+ pendingFailureCause = event.data;
1496
+ events2 = events2.slice(0, i);
1497
+ break;
1498
+ }
1499
+ }
1500
+ return succeed2(events2);
1501
+ });
1502
+ });
1503
+ }));
1504
+ if (declaration.sseMode === "data") {
1505
+ return map3(events, (event) => event.data);
1506
+ }
1507
+ return events;
1508
+ }
1509
+ var ArrayBuffer = /* @__PURE__ */ instanceOf(globalThis.ArrayBuffer, {
1510
+ expected: "ArrayBuffer"
1511
+ });
1512
+ var Uint8ArrayFromArrayBuffer = /* @__PURE__ */ ArrayBuffer.pipe(/* @__PURE__ */ decodeTo(Uint8Array2, /* @__PURE__ */ transform({
1513
+ decode(fromA) {
1514
+ return new Uint8Array(fromA);
1515
+ },
1516
+ encode(arr) {
1517
+ return arr.byteLength === arr.buffer.byteLength ? arr.buffer : arr.buffer.slice(arr.byteOffset, arr.byteOffset + arr.byteLength);
1518
+ }
1519
+ })));
1520
+ var StringFromArrayBuffer = /* @__PURE__ */ ArrayBuffer.pipe(/* @__PURE__ */ decodeTo(String2, /* @__PURE__ */ transform({
1521
+ decode(fromA) {
1522
+ return new TextDecoder().decode(fromA);
1523
+ },
1524
+ encode(toI) {
1525
+ const arr = new TextEncoder().encode(toI);
1526
+ return arr.byteLength === arr.buffer.byteLength ? arr.buffer : arr.buffer.slice(arr.byteOffset, arr.byteOffset + arr.byteLength);
1527
+ }
1528
+ })));
1529
+ var UnknownFromArrayBuffer = /* @__PURE__ */ StringFromArrayBuffer.pipe(/* @__PURE__ */ decodeTo(/* @__PURE__ */ Union([
1530
+ // Handle No Content
1531
+ /* @__PURE__ */ Literal("").pipe(/* @__PURE__ */ decodeTo(Undefined, /* @__PURE__ */ transform({
1532
+ decode: () => void 0,
1533
+ encode: () => ""
1534
+ }))),
1535
+ UnknownFromJsonString
1536
+ ])));
1537
+ function toCodecArrayBuffer(schemas) {
1538
+ return Union(schemas.map(onSchema));
1539
+ function onSchema(schema) {
1540
+ return fromArrayBuffer(schema).pipe(decodeTo(schema));
1541
+ }
1542
+ }
1543
+ function fromArrayBuffer(schema) {
1544
+ const encoding = getResponseEncoding(schema.ast);
1545
+ switch (encoding._tag) {
1546
+ case "Json": {
1547
+ const encodedIsNull = isNull(toEncoded(schema.ast));
1548
+ return encodedIsNull ? UnknownFromArrayBuffer.pipe(decodeTo(Unknown, transform({
1549
+ decode: (a) => a === void 0 ? null : a,
1550
+ encode: (a) => a === null ? void 0 : a
1551
+ }))) : UnknownFromArrayBuffer;
1552
+ }
1553
+ case "FormUrlEncoded":
1554
+ return StringFromArrayBuffer.pipe(decodeTo(RecordFromUrlParams, transform({
1555
+ decode: (text2) => fromInput(new URLSearchParams(text2)),
1556
+ encode: toString
1557
+ })));
1558
+ case "Uint8Array":
1559
+ return Uint8ArrayFromArrayBuffer;
1560
+ case "Text":
1561
+ return StringFromArrayBuffer;
1562
+ }
1563
+ }
1564
+ var statusOrElse = (response) => fail3(new HttpClientError({
1565
+ reason: new DecodeError({
1566
+ request: response.request,
1567
+ response
1568
+ })
1569
+ }));
1570
+ var $HttpBody = /* @__PURE__ */ declare(isHttpBody);
1571
+ function getEncodePayloadSchema(schemas, method) {
1572
+ return Union(schemas.map((s) => getEncodePayloadSchemaFromBody(s, method)));
1573
+ }
1574
+ var bodyFromPayloadCache = /* @__PURE__ */ new WeakMap();
1575
+ function getEncodePayloadSchemaFromBody(schema, method) {
1576
+ const ast = schema.ast;
1577
+ const cached = bodyFromPayloadCache.get(ast);
1578
+ if (cached !== void 0) {
1579
+ return cached;
1580
+ }
1581
+ const encoding = getPayloadEncoding(ast, method);
1582
+ const out = $HttpBody.pipe(decodeTo(schema, transformEffect({
1583
+ decode(input, options2) {
1584
+ return fail3(new Forbidden({
1585
+ message: "Encode only schema"
1586
+ }, input, options2));
1587
+ },
1588
+ encode(t, options2) {
1589
+ switch (encoding._tag) {
1590
+ case "Multipart":
1591
+ return fail3(new Forbidden({
1592
+ message: "Payload must be a FormData"
1593
+ }, t, options2));
1594
+ case "Json": {
1595
+ try {
1596
+ const body = JSON.stringify(t);
1597
+ return succeed2(text(body, encoding.contentType));
1598
+ } catch {
1599
+ return fail3(new InvalidValue({
1600
+ expected: "a JSON-serializable request body"
1601
+ }, t, options2));
1602
+ }
1603
+ }
1604
+ case "Text": {
1605
+ if (typeof t !== "string") {
1606
+ return fail3(new InvalidValue({
1607
+ message: "Expected a string"
1608
+ }, t, options2));
1609
+ }
1610
+ return succeed2(text(t, encoding.contentType));
1611
+ }
1612
+ case "FormUrlEncoded": {
1613
+ if (!isObject(t)) {
1614
+ return fail3(new InvalidValue({
1615
+ message: "Expected a record"
1616
+ }, t, options2));
1617
+ }
1618
+ return succeed2(urlParams(fromInput(t), encoding.contentType));
1619
+ }
1620
+ case "Uint8Array": {
1621
+ if (!(t instanceof Uint8Array)) {
1622
+ return fail3(new InvalidValue({
1623
+ message: "Expected a Uint8Array"
1624
+ }, t, options2));
1625
+ }
1626
+ return succeed2(uint8Array(t, encoding.contentType));
1627
+ }
1628
+ }
1629
+ }
1630
+ })));
1631
+ bodyFromPayloadCache.set(ast, out);
1632
+ return out;
1633
+ }
1634
+
1635
+ // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/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
+ export {
1787
+ HttpApiEndpoint_exports,
1788
+ HttpApi_exports,
1789
+ HttpApiClient_exports,
1790
+ HttpApiGroup_exports,
1791
+ UiContext,
1792
+ UiOperation,
1793
+ UiUnauthorized,
1794
+ UiForbidden,
1795
+ UiDeploymentChanged,
1796
+ UiFailed,
1797
+ UiSnapshot,
1798
+ AppUiApi
1799
+ };