getborg 0.0.118 → 0.0.124
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/dist/{FetchHttpClient-C-jciW95.mjs → FetchHttpClient-DkBX_tvM.mjs} +814 -814
- package/dist/{FileSystem-NX0EtGtm.mjs → FileSystem-B8SvsKCB.mjs} +87 -18
- package/dist/{Mime-C6O17O_3.mjs → Mime-mwjBDTG5.mjs} +945 -945
- package/dist/{NodeHttpIncomingMessage-CylGKvlB.mjs → NodeHttpIncomingMessage-Caou0eJc.mjs} +3 -3
- package/dist/{NodeHttpServer-EarHJJzn.mjs → NodeHttpServer-CiwRW4qX.mjs} +7 -7
- package/dist/{NodePtyAdapter-C6ioPYk6.mjs → NodePtyAdapter-DCy0YCxP.mjs} +2 -2
- package/dist/{NodeServices-C18DO3cx.mjs → NodeServices-KA4IGVlf.mjs} +4 -4
- package/dist/{NodeSqliteClient-CWkKfsSo.mjs → NodeSqliteClient-y7W-gFvl.mjs} +3 -3
- package/dist/{NodeStream-1N7oXzTp.mjs → NodeStream-Cwt3mZYs.mjs} +2 -2
- package/dist/{SqlClient-Cusaqpaw.mjs → SqlClient-D-oF89aw.mjs} +2 -2
- package/dist/bin.mjs +27760 -18891
- package/dist/{borgTelemetryNode-CHLcRFOW.mjs → borgTelemetryNode-BTLPaUwA.mjs} +5 -5
- package/dist/client/.vite/manifest.json +396 -320
- package/dist/client/assets/{ArrowRight-CgvCTAzu.js → ArrowRight-D8u8fAtz.js} +2 -2
- package/dist/client/assets/{ArrowSquareOut-C1CwJQ7R.js → ArrowSquareOut-B_f6YUhV.js} +2 -2
- package/dist/client/assets/{ArrowsClockwise-CBwAQTtQ.js → ArrowsClockwise-DQYZ1Xbo.js} +2 -2
- package/dist/client/assets/{CaretLeft-Bk0n02vc.js → CaretLeft-CfrkuxuJ.js} +2 -2
- package/dist/client/assets/ChatMarkdown-Ch9PipMk.js +249 -0
- package/dist/client/assets/CircleNotch-BcVOnWaH.js +2 -0
- package/dist/client/assets/DesignWorkspace-CrijZIpE.js +3 -0
- package/dist/client/assets/DiffPanel-Bbs-arXF.js +2 -0
- package/dist/client/assets/DiffWorkerPoolProvider-B-AH2sbL.js +10 -0
- package/dist/client/assets/{DocxPreview-DHnzhQMX.js → DocxPreview-HXde7oD1.js} +4 -4
- package/dist/client/assets/FilePreviewPanel-DkspqFyX.js +2237 -0
- package/dist/client/assets/HtmlPreview-pfh_hRgS.js +2 -0
- package/dist/client/assets/{PdfPreview-CjWrZkCM.js → PdfPreview-VSGe6F9I.js} +3 -3
- package/dist/client/assets/PptxPreview-CZZ5e7rI.js +3 -0
- package/dist/client/assets/PreviewPanel-C_WqPJu_.js +2 -0
- package/dist/client/assets/PullRequestCodeTab-DLajHhi9.js +6 -0
- package/dist/client/assets/PullRequestReactions-BJ4eU_08.js +12 -0
- package/dist/client/assets/{RightPanelResizeHandle-DBci-Ee2.js → RightPanelResizeHandle-XlC9gY5e.js} +2 -2
- package/dist/client/assets/VirtualizedFile-qiRlyNDc.js +2 -0
- package/dist/client/assets/XlsxPreview-BPtt3tW-.js +3 -0
- package/dist/client/assets/accountData-BKyjOPQm.js +16 -0
- package/dist/client/assets/assetUrls-33nMWFnF.js +2 -0
- package/dist/client/assets/assets-1BW7ZJgz.js +2 -0
- package/dist/client/assets/{browserHistoryStore-CIr_OQCq.js → browserHistoryStore-CEVJXGfr.js} +3 -3
- package/dist/client/assets/browserRecording-BavNt16V.js +2 -0
- package/dist/client/assets/clientAnalytics-ChPHl8_D.js +1 -0
- package/dist/client/assets/clientPersistenceStorage-CeJLSpQl.js +2 -0
- package/dist/client/assets/combobox-CQHB5X6j.js +2 -0
- package/dist/client/assets/composerMentionDrag-CdTT1rUK.js +2 -0
- package/dist/client/assets/designCanvas.logic-DduGt5E7.js +8 -0
- package/dist/client/assets/{designOpenFileContext-DCJpUleA.js → designOpenFileContext-CMKir5dG.js} +2 -2
- package/dist/client/assets/{diffFileContents-CFjzWK4l.js → diffFileContents-CHRsIT6_.js} +3 -3
- package/dist/client/assets/{empty-tcpR9LH8.js → empty-DUUjhkFh.js} +2 -2
- package/dist/client/assets/entities-BtD3_L53.js +2 -0
- package/dist/client/assets/followUpQueuePersistence-C_pFQCnT.js +1 -0
- package/dist/client/assets/{index-DraeEDbf.js → index-DrITfTBh.js} +3 -3
- package/dist/client/assets/{input-BRLXkmUH.js → input-CyCAHFxI.js} +2 -2
- package/dist/client/assets/{lib-ay4Y8Jpt.js → lib-BRpsbmNP.js} +2 -2
- package/dist/client/assets/main-Bi6AoLeM.js +167 -0
- package/dist/client/assets/main-C0iNAqq8.css +2 -0
- package/dist/client/assets/{pdf-BH4RlEy2.js → pdf-C3xMIdpt.js} +2 -2
- package/dist/client/assets/popover-BXSj56CI.js +2 -0
- package/dist/client/assets/pptxDocument-BnTLF4HV.js +3 -0
- package/dist/client/assets/projectFilesQueryState-Cs5skZOc.js +2 -0
- package/dist/client/assets/queries-BevoHPqY.js +2 -0
- package/dist/client/assets/{scroll-area-j6QV0udq.js → scroll-area-DAaT-DGF.js} +36 -36
- package/dist/client/assets/session-Dmu9Hk5C.js +68 -0
- package/dist/client/assets/spinner-K3N_kbJr.js +2 -0
- package/dist/client/assets/textarea-BT0tVWKM.js +2 -0
- package/dist/client/assets/{toggle-DwBa6pBo.js → toggle-Sui8J_p3.js} +2 -2
- package/dist/client/assets/toggle-group-BDgfPfOF.js +2 -0
- package/dist/client/assets/useSettings-GEQSU1F5.js +5 -0
- package/dist/client/assets/{useWorkspaceMutationRefresh-DLI4brDf.js → useWorkspaceMutationRefresh-ApasU6PB.js} +2 -2
- package/dist/client/assets/utils-ClZ5OxbV.js +30 -0
- package/dist/client/assets/xlsxDocument-SRKfhPKH.js +2 -0
- package/dist/client/index.html +1 -1
- package/dist/service-launcher.mjs +1 -1
- package/package.json +2 -2
- package/dist/client/assets/ChatMarkdown-BhfpBJaq.js +0 -249
- package/dist/client/assets/DesignWorkspace-okkekyBu.js +0 -3
- package/dist/client/assets/DiffPanel-Dn_Or9fx.js +0 -2
- package/dist/client/assets/DiffWorkerPoolProvider-Hp3trMBG.js +0 -10
- package/dist/client/assets/FilePreviewPanel-KOVwBhPe.js +0 -2231
- package/dist/client/assets/HtmlPreview-I3xV5YgS.js +0 -2
- package/dist/client/assets/PptxPreview-D4YsFq_s.js +0 -3
- package/dist/client/assets/PreviewPanel-CKieJ-9L.js +0 -2
- package/dist/client/assets/PullRequestCodeTab-DbUx3FWB.js +0 -6
- package/dist/client/assets/PullRequestReactions-BSI_Qt4L.js +0 -12
- package/dist/client/assets/VirtualizedFile-VSzhLWFM.js +0 -2
- package/dist/client/assets/XlsxPreview-BnnrdNes.js +0 -3
- package/dist/client/assets/accountData-C4ZvicpJ.js +0 -16
- package/dist/client/assets/assetUrls-C2vkiSgX.js +0 -2
- package/dist/client/assets/browserRecording-BmG6q-H4.js +0 -2
- package/dist/client/assets/clientPersistenceStorage-BlYjZvCd.js +0 -2
- package/dist/client/assets/combobox-uXzVxkLc.js +0 -2
- package/dist/client/assets/composerMentionDrag-DTGN7WcV.js +0 -2
- package/dist/client/assets/designCanvas.logic-DtK3Ht6X.js +0 -8
- package/dist/client/assets/entities-Da-AvwsX.js +0 -2
- package/dist/client/assets/main-Bn8Ylf8R.js +0 -161
- package/dist/client/assets/main-YscGsfgO.css +0 -2
- package/dist/client/assets/popover-DTprsoPQ.js +0 -2
- package/dist/client/assets/pptxDocument-ifTk53yH.js +0 -3
- package/dist/client/assets/projectFilesQueryState-CD_JXBj5.js +0 -2
- package/dist/client/assets/queries-D1AwaR_5.js +0 -2
- package/dist/client/assets/session-BaysTZDD.js +0 -67
- package/dist/client/assets/spinner-DHhZaoFg.js +0 -2
- package/dist/client/assets/textarea-BB3euU4O.js +0 -5
- package/dist/client/assets/toggle-group-BU7-0DcW.js +0 -2
- package/dist/client/assets/utils-DgzD4MA_.js +0 -30
- package/dist/client/assets/xlsxDocument-DwhEMpfP.js +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { $ as decodeEffect, $u as some, A as Record, Al as toSeconds, An as transform$2, Bi as matchCauseEffect, Bu as fromNullishOr, Dl as seconds, Dr as andThen, Ed as symbolRedactable, Fi as map$2, Fr as cached, Ft as optional, Gd as constFalse, Gu as getOrUndefined, Ha as uninterruptibleMask, Hd as or, Hl as fromIterable$1, Io as TaggedError, Jl as makeEquivalence, Jr as contextWith, Jt as make$7, Kd as constTrue, La as tryPromise, Li as mapError, M as String$1, Md as symbol$1, Mu as merge$2, Nl as appendAll$1, Oa as suspend, Od as symbol, Pd as hasProperty, Po as Error, Qd as identity, R as Tuple, Ra as try_, Rt as tag, S as NonEmptyArray, Sd as NodeInspectSymbol, Su as Service, Ta as succeed$1, Td as redact$1, Tr as addFinalizer, Tu as get$2, Ua as updateContext, Vo as effect, W as Union, Wa as useSpan, Xd as dual, Xt as stringOrRedacted, Xu as match, Ya as withFiber, Z as declare, Za as withParentSpan, Zd as flow, Zu as none, _l as fromInputUnsafe, au as set$3, bd as BaseProto, bl as isFinite, bu as try_$1, c as Defect, d as ErrorClass, dc as isTimeoutError, ef as pipeArguments, fd as PipeInspectableProto, ha as runSync, hu as isFailure, ia as repeat, il as DisablePropagation, iu as map, jd as structure, jt as link, ka as sync, kd as array, ll as externalSpan, lu as makeEquivalence$1, n as ArraySchema, ni as failCause, nt as decodeTo, nu as isEmptyRecord, oa as retry, od as make$6, po as isSchedule, qi as onInterrupt, qu as isSome, ru as makeEquivalence$2, sd as strictEqual, si as flatMap, sn as encodeUnknownEffect, tc as hasInterrupts, ti as fail$1, uu as fail, v as Literals, vo as passthrough, vu as map$1, wd as format, xd as Class, xu as Reference, yd as assignProperty, yu as succeed, zt as toCodecJson } from "./Schema-CA_wFfhH.mjs";
|
|
4
|
-
import { A as fromReadableStream, _ as fail$2,
|
|
4
|
+
import { A as fromReadableStream, _ as fail$2, _n as set$4, ct as suspend$1, g as ensuring, gn as make$8, pt as toReadableStreamEffect } from "./FileSystem-B8SvsKCB.mjs";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
//#region \0rolldown/runtime.js
|
|
7
7
|
var __create = Object.create;
|
|
@@ -37,742 +37,1037 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
37
37
|
}) : target, mod));
|
|
38
38
|
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
39
39
|
//#endregion
|
|
40
|
-
//#region ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/
|
|
41
|
-
/**
|
|
42
|
-
* Defines supported HTTP method names for the unstable HTTP modules.
|
|
43
|
-
*
|
|
44
|
-
* Values are uppercase string literals such as `"GET"` and `"POST"`, matching
|
|
45
|
-
* the method tokens used by HTTP requests and routes. This module also includes
|
|
46
|
-
* helpers for checking whether a method can carry a request body and whether an
|
|
47
|
-
* unknown value is one of the supported methods.
|
|
48
|
-
*
|
|
49
|
-
* @since 4.0.0
|
|
50
|
-
*/
|
|
51
|
-
/**
|
|
52
|
-
* Returns `true` when a method can carry a request body and narrows it to `HttpMethod.WithBody`.
|
|
53
|
-
*
|
|
54
|
-
* @category guards
|
|
55
|
-
* @since 4.0.0
|
|
56
|
-
*/
|
|
57
|
-
const hasBody = (method) => method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE";
|
|
58
|
-
/**
|
|
59
|
-
* Provides tuples mapping each supported HTTP method to its short
|
|
60
|
-
* request-constructor name.
|
|
61
|
-
*
|
|
62
|
-
* **When to use**
|
|
63
|
-
*
|
|
64
|
-
* Use when you need the mapping from supported HTTP method literals to their
|
|
65
|
-
* short request-constructor names.
|
|
66
|
-
*
|
|
67
|
-
* @category constants
|
|
68
|
-
* @since 4.0.0
|
|
69
|
-
*/
|
|
70
|
-
const allShort = [
|
|
71
|
-
["GET", "get"],
|
|
72
|
-
["POST", "post"],
|
|
73
|
-
["PUT", "put"],
|
|
74
|
-
["DELETE", "del"],
|
|
75
|
-
["PATCH", "patch"],
|
|
76
|
-
["HEAD", "head"],
|
|
77
|
-
["OPTIONS", "options"],
|
|
78
|
-
["TRACE", "trace"]
|
|
79
|
-
];
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/http/UrlParams.js
|
|
40
|
+
//#region ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/Ref.js
|
|
82
41
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* `UrlParams` is used for HTTP client query strings, URL-encoded form bodies,
|
|
86
|
-
* and server-side decoding. Values can be built from records, iterables, or
|
|
87
|
-
* native `URLSearchParams`, then updated, serialized, converted to a `URL`, or
|
|
88
|
-
* decoded with schemas.
|
|
42
|
+
* Stores fiber-safe mutable state inside Effect programs.
|
|
89
43
|
*
|
|
90
|
-
*
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*
|
|
44
|
+
* A `Ref<A>` holds one value and exposes reads, writes, and atomic
|
|
45
|
+
* transformations as effects, so state changes compose with Effect's
|
|
46
|
+
* concurrency model. This module includes constructors, safe and unsafe reads,
|
|
47
|
+
* set and get-and-set helpers, update and modify helpers, and conditional
|
|
48
|
+
* update variants that leave the value unchanged when an `Option.none` result
|
|
49
|
+
* is returned.
|
|
95
50
|
*
|
|
96
|
-
* @
|
|
97
|
-
* @since 4.0.0
|
|
51
|
+
* @since 2.0.0
|
|
98
52
|
*/
|
|
99
|
-
const
|
|
100
|
-
|
|
53
|
+
const RefProto = {
|
|
54
|
+
["~effect/Ref"]: { _A: identity },
|
|
101
55
|
...PipeInspectableProto,
|
|
102
|
-
[TypeId$8]: TypeId$8,
|
|
103
|
-
[Symbol.iterator]() {
|
|
104
|
-
return this.params[Symbol.iterator]();
|
|
105
|
-
},
|
|
106
56
|
toJSON() {
|
|
107
57
|
return {
|
|
108
|
-
_id: "
|
|
109
|
-
|
|
58
|
+
_id: "Ref",
|
|
59
|
+
ref: this.ref
|
|
110
60
|
};
|
|
111
|
-
},
|
|
112
|
-
[symbol](that) {
|
|
113
|
-
return Equivalence$1(this, that);
|
|
114
|
-
},
|
|
115
|
-
[symbol$1]() {
|
|
116
|
-
return array(this.params.flat());
|
|
117
61
|
}
|
|
118
62
|
};
|
|
119
63
|
/**
|
|
120
|
-
* Creates
|
|
64
|
+
* Creates a new Ref with the specified initial value (unsafe version).
|
|
121
65
|
*
|
|
122
|
-
* **
|
|
66
|
+
* **When to use**
|
|
123
67
|
*
|
|
124
|
-
*
|
|
68
|
+
* Use when you need immediate synchronous construction and can guarantee
|
|
69
|
+
* that creating the `Ref` outside of `Effect` is safe.
|
|
125
70
|
*
|
|
126
|
-
*
|
|
127
|
-
* @since 4.0.0
|
|
128
|
-
*/
|
|
129
|
-
const make$5 = (params) => {
|
|
130
|
-
const self = Object.create(Proto$5);
|
|
131
|
-
self.params = params;
|
|
132
|
-
return self;
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Creates `UrlParams` from a supported input shape.
|
|
71
|
+
* **Gotchas**
|
|
136
72
|
*
|
|
137
|
-
*
|
|
73
|
+
* Prefer `Ref.make` for Effect-wrapped creation in Effect programs.
|
|
138
74
|
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
75
|
+
* **Example** (Creating a ref unsafely)
|
|
76
|
+
*
|
|
77
|
+
* ```ts import.meta.vitest
|
|
78
|
+
* import { Ref } from "effect"
|
|
79
|
+
*
|
|
80
|
+
* const counter = Ref.makeUnsafe(0)
|
|
81
|
+
* Ref.getUnsafe(counter) // => 0
|
|
82
|
+
* ```
|
|
141
83
|
*
|
|
142
84
|
* @category constructors
|
|
143
85
|
* @since 4.0.0
|
|
144
86
|
*/
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
for (let i = 0; i < parsed.length; i++) if (Array.isArray(parsed[i][0])) {
|
|
150
|
-
const [keys, value] = parsed[i];
|
|
151
|
-
out.push([`${keys[0]}[${keys.slice(1).join("][")}]`, value]);
|
|
152
|
-
} else out.push(parsed[i]);
|
|
153
|
-
return make$5(out);
|
|
154
|
-
};
|
|
155
|
-
const fromInputNested = (input) => {
|
|
156
|
-
const entries = typeof input[Symbol.iterator] === "function" ? fromIterable$1(input) : Object.entries(input);
|
|
157
|
-
const out = [];
|
|
158
|
-
for (const [key, value] of entries) if (Array.isArray(value)) {
|
|
159
|
-
for (let i = 0; i < value.length; i++) if (value[i] !== void 0) out.push([key, String(value[i])]);
|
|
160
|
-
} else if (typeof value === "object") {
|
|
161
|
-
const nested = fromInputNested(value);
|
|
162
|
-
for (const [k, v] of nested) out.push([[key, ...typeof k === "string" ? [k] : k], v]);
|
|
163
|
-
} else if (value !== void 0) out.push([key, String(value)]);
|
|
164
|
-
return out;
|
|
87
|
+
const makeUnsafe = (value) => {
|
|
88
|
+
const self = Object.create(RefProto);
|
|
89
|
+
self.ref = make$8(value);
|
|
90
|
+
return self;
|
|
165
91
|
};
|
|
166
92
|
/**
|
|
167
|
-
*
|
|
93
|
+
* Creates a new Ref with the specified initial value.
|
|
168
94
|
*
|
|
169
|
-
* **
|
|
95
|
+
* **When to use**
|
|
170
96
|
*
|
|
171
|
-
*
|
|
172
|
-
* order.
|
|
97
|
+
* Use to create a `Ref` for shared mutable state inside an Effect program.
|
|
173
98
|
*
|
|
174
|
-
*
|
|
175
|
-
* @since 4.0.0
|
|
176
|
-
*/
|
|
177
|
-
const Equivalence$1 = /*#__PURE__*/ make$6((a, b) => arrayEquivalence(a.params, b.params));
|
|
178
|
-
const arrayEquivalence = /*#__PURE__*/ makeEquivalence(/*#__PURE__*/ makeEquivalence$1([/*#__PURE__*/ strictEqual(), /*#__PURE__*/ strictEqual()]));
|
|
179
|
-
/**
|
|
180
|
-
* Schema for `UrlParams`.
|
|
99
|
+
* **Example** (Creating a ref)
|
|
181
100
|
*
|
|
182
|
-
*
|
|
101
|
+
* ```ts import.meta.vitest
|
|
102
|
+
* import { Effect, Ref } from "effect"
|
|
183
103
|
*
|
|
184
|
-
*
|
|
104
|
+
* const program = Effect.gen(function*() {
|
|
105
|
+
* const ref = yield* Ref.make(42)
|
|
106
|
+
* return yield* Ref.get(ref)
|
|
107
|
+
* })
|
|
185
108
|
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
representation: {
|
|
191
|
-
id: "effect/http/UrlParams",
|
|
192
|
-
payload: null
|
|
193
|
-
},
|
|
194
|
-
toCode: () => ({
|
|
195
|
-
runtime: "UrlParams.UrlParamsSchema",
|
|
196
|
-
Type: "UrlParams.UrlParams",
|
|
197
|
-
importDeclarations: [`import * as UrlParams from "effect/unstable/http/UrlParams"`]
|
|
198
|
-
}),
|
|
199
|
-
expected: "UrlParams",
|
|
200
|
-
toEquivalence: () => Equivalence$1,
|
|
201
|
-
toCodec: () => link()(ArraySchema(Tuple([String$1, String$1])), transform$2({
|
|
202
|
-
decode: make$5,
|
|
203
|
-
encode: (self) => self.params
|
|
204
|
-
}))
|
|
205
|
-
});
|
|
206
|
-
/**
|
|
207
|
-
* An empty `UrlParams` value.
|
|
109
|
+
* await Effect.runPromise(program) // => 42
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @see {@link makeUnsafe} for synchronous construction outside Effect code
|
|
208
113
|
*
|
|
209
114
|
* @category constructors
|
|
210
|
-
* @since
|
|
115
|
+
* @since 2.0.0
|
|
211
116
|
*/
|
|
212
|
-
const
|
|
117
|
+
const make$5 = (value) => sync(() => makeUnsafe(value));
|
|
213
118
|
/**
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
* **Details**
|
|
119
|
+
* Gets the current value of the Ref.
|
|
217
120
|
*
|
|
218
|
-
*
|
|
121
|
+
* **When to use**
|
|
219
122
|
*
|
|
220
|
-
*
|
|
221
|
-
* @since 4.0.0
|
|
222
|
-
*/
|
|
223
|
-
const transform$1 = /*#__PURE__*/ dual(2, (self, f) => make$5(f(self.params)));
|
|
224
|
-
/**
|
|
225
|
-
* Sets multiple query parameters from input.
|
|
123
|
+
* Use to read the current `Ref` value without changing it.
|
|
226
124
|
*
|
|
227
|
-
* **
|
|
125
|
+
* **Example** (Getting the current value)
|
|
228
126
|
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
127
|
+
* ```ts import.meta.vitest
|
|
128
|
+
* import { Effect, Ref } from "effect"
|
|
231
129
|
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const out = fromInput$1(input);
|
|
237
|
-
const params = out.params;
|
|
238
|
-
const keys = /* @__PURE__ */ new Set();
|
|
239
|
-
for (let i = 0; i < params.length; i++) keys.add(params[i][0]);
|
|
240
|
-
for (let i = 0; i < self.params.length; i++) {
|
|
241
|
-
if (keys.has(self.params[i][0])) continue;
|
|
242
|
-
params.push(self.params[i]);
|
|
243
|
-
}
|
|
244
|
-
return out;
|
|
245
|
-
});
|
|
246
|
-
/**
|
|
247
|
-
* Appends all query parameters produced from the supplied input.
|
|
130
|
+
* const program = Effect.gen(function*() {
|
|
131
|
+
* const ref = yield* Ref.make(42)
|
|
132
|
+
* return yield* Ref.get(ref)
|
|
133
|
+
* })
|
|
248
134
|
*
|
|
249
|
-
*
|
|
135
|
+
* await Effect.runPromise(program) // => 42
|
|
136
|
+
* ```
|
|
250
137
|
*
|
|
251
|
-
*
|
|
138
|
+
* @see {@link set} for replacing the current value
|
|
252
139
|
*
|
|
253
|
-
* @category
|
|
254
|
-
* @since
|
|
140
|
+
* @category getters
|
|
141
|
+
* @since 2.0.0
|
|
255
142
|
*/
|
|
256
|
-
const
|
|
143
|
+
const get$1 = (self) => sync(() => self.ref.current);
|
|
257
144
|
/**
|
|
258
|
-
*
|
|
145
|
+
* Sets the value of the Ref to the specified value.
|
|
259
146
|
*
|
|
260
|
-
*
|
|
261
|
-
* @since 4.0.0
|
|
262
|
-
*/
|
|
263
|
-
const toString = (input) => new URLSearchParams(fromInput$1(input).params).toString();
|
|
264
|
-
/**
|
|
265
|
-
* Builds a `Record` containing all the key-value pairs in the given `UrlParams`
|
|
266
|
-
* as `string` (if only one value for a key) or a `NonEmptyArray<string>`
|
|
267
|
-
* (when more than one value for a key)
|
|
147
|
+
* **When to use**
|
|
268
148
|
*
|
|
269
|
-
*
|
|
149
|
+
* Use to replace the current `Ref` value with a known value.
|
|
150
|
+
*
|
|
151
|
+
* **Example** (Setting a value)
|
|
270
152
|
*
|
|
271
153
|
* ```ts import.meta.vitest
|
|
272
|
-
* import {
|
|
154
|
+
* import { Effect, Ref } from "effect"
|
|
273
155
|
*
|
|
274
|
-
* const
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
156
|
+
* const program = Effect.gen(function*() {
|
|
157
|
+
* const ref = yield* Ref.make(0)
|
|
158
|
+
* yield* Ref.set(ref, 42)
|
|
159
|
+
* return yield* Ref.get(ref)
|
|
160
|
+
* })
|
|
161
|
+
*
|
|
162
|
+
* const program2 = Effect.gen(function*() {
|
|
163
|
+
* const ref = yield* Ref.make(0)
|
|
164
|
+
* yield* Ref.set(ref, 100)
|
|
165
|
+
* return yield* Ref.get(ref)
|
|
166
|
+
* })
|
|
167
|
+
*
|
|
168
|
+
* await Effect.runPromise(program) // => 42
|
|
169
|
+
* await Effect.runPromise(program2) // => 100
|
|
281
170
|
* ```
|
|
282
171
|
*
|
|
283
|
-
* @
|
|
284
|
-
* @
|
|
172
|
+
* @see {@link getAndSet} for setting while returning the previous value
|
|
173
|
+
* @see {@link setAndGet} for setting while returning the new value
|
|
174
|
+
*
|
|
175
|
+
* @category mutations
|
|
176
|
+
* @since 2.0.0
|
|
285
177
|
*/
|
|
286
|
-
const
|
|
287
|
-
const out = {};
|
|
288
|
-
for (const [k, value] of self.params) if (!Object.hasOwn(out, k)) assignProperty(out, k, value);
|
|
289
|
-
else {
|
|
290
|
-
const current = out[k];
|
|
291
|
-
if (typeof current === "string") assignProperty(out, k, [current, value]);
|
|
292
|
-
else current.push(value);
|
|
293
|
-
}
|
|
294
|
-
return out;
|
|
295
|
-
};
|
|
178
|
+
const set$2 = /*#__PURE__*/ dual(2, (self, value) => sync(() => set$4(self.ref, value)));
|
|
296
179
|
/**
|
|
297
|
-
*
|
|
180
|
+
* Gets the current value of the Ref, sets it to the specified value, and returns the previous value atomically.
|
|
298
181
|
*
|
|
299
|
-
* **
|
|
182
|
+
* **When to use**
|
|
300
183
|
*
|
|
301
|
-
*
|
|
302
|
-
* non-empty readonly array of strings.
|
|
184
|
+
* Use to replace a plain `Ref` value while returning the previous value.
|
|
303
185
|
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
186
|
+
* **Example** (Replacing a value atomically)
|
|
187
|
+
*
|
|
188
|
+
* ```ts import.meta.vitest
|
|
189
|
+
* import { Effect, Ref } from "effect"
|
|
190
|
+
*
|
|
191
|
+
* const program = Effect.gen(function*() {
|
|
192
|
+
* const ref = yield* Ref.make("initial")
|
|
193
|
+
*
|
|
194
|
+
* const previous = yield* Ref.getAndSet(ref, "updated")
|
|
195
|
+
* const current = yield* Ref.get(ref)
|
|
196
|
+
* return [previous, current]
|
|
197
|
+
* })
|
|
198
|
+
*
|
|
199
|
+
* await Effect.runPromise(program) // => ["initial", "updated"]
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* @see {@link set} for setting without returning the previous value
|
|
203
|
+
* @see {@link getAndUpdate} for deriving the new value from the previous value
|
|
204
|
+
*
|
|
205
|
+
* @category mutations
|
|
206
|
+
* @since 2.0.0
|
|
306
207
|
*/
|
|
307
|
-
const
|
|
208
|
+
const getAndSet = /*#__PURE__*/ dual(2, (self, value) => sync(() => {
|
|
209
|
+
const current = self.ref.current;
|
|
210
|
+
self.ref.current = value;
|
|
211
|
+
return current;
|
|
212
|
+
}));
|
|
308
213
|
/**
|
|
309
|
-
*
|
|
214
|
+
* Modifies the value of the Ref atomically using the given function.
|
|
215
|
+
*
|
|
216
|
+
* **When to use**
|
|
217
|
+
*
|
|
218
|
+
* Use to compute both a separate return value and the next stored `Ref` value
|
|
219
|
+
* in one atomic update.
|
|
310
220
|
*
|
|
311
221
|
* **Details**
|
|
312
222
|
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
223
|
+
* The function receives the current value and returns a tuple of
|
|
224
|
+
* `[result, newValue]`. The Ref is updated with `newValue`, and `result` is
|
|
225
|
+
* returned by the effect.
|
|
315
226
|
*
|
|
316
|
-
* **Example** (
|
|
227
|
+
* **Example** (Modifying a value atomically)
|
|
317
228
|
*
|
|
318
229
|
* ```ts import.meta.vitest
|
|
319
|
-
* import {
|
|
320
|
-
* import { UrlParams } from "effect/unstable/http"
|
|
230
|
+
* import { Effect, Ref } from "effect"
|
|
321
231
|
*
|
|
322
|
-
* const
|
|
323
|
-
*
|
|
324
|
-
* some: Schema.String,
|
|
325
|
-
* number: Schema.FiniteFromString
|
|
326
|
-
* }))
|
|
327
|
-
* )
|
|
232
|
+
* const program = Effect.gen(function*() {
|
|
233
|
+
* const counter = yield* Ref.make(10)
|
|
328
234
|
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
235
|
+
* const result = yield* Ref.modify(counter, (n) => [
|
|
236
|
+
* `Previous value was ${n}`,
|
|
237
|
+
* n * 2
|
|
238
|
+
* ])
|
|
239
|
+
* const current = yield* Ref.get(counter)
|
|
240
|
+
* return [result, current]
|
|
241
|
+
* })
|
|
242
|
+
*
|
|
243
|
+
* const program2 = Effect.gen(function*() {
|
|
244
|
+
* const state = yield* Ref.make({ count: 0, total: 0 })
|
|
245
|
+
* return yield* Ref.modify(state, (s) => [
|
|
246
|
+
* s.count,
|
|
247
|
+
* { count: s.count + 1, total: s.total + s.count + 1 }
|
|
248
|
+
* ])
|
|
249
|
+
* })
|
|
250
|
+
*
|
|
251
|
+
* await Effect.runPromise(program) // => ["Previous value was 10", 20]
|
|
252
|
+
* await Effect.runPromise(program2) // => 0
|
|
334
253
|
* ```
|
|
335
254
|
*
|
|
336
|
-
* @
|
|
337
|
-
* @
|
|
255
|
+
* @see {@link updateAndGet} for returning the new stored value
|
|
256
|
+
* @see {@link modifySome} for optionally updating while returning a separate result
|
|
257
|
+
*
|
|
258
|
+
* @category mutations
|
|
259
|
+
* @since 2.0.0
|
|
338
260
|
*/
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
//#region ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/http/HttpBody.js
|
|
261
|
+
const modify$1 = /*#__PURE__*/ dual(2, (self, f) => sync(() => {
|
|
262
|
+
const [b, a] = f(self.ref.current);
|
|
263
|
+
self.ref.current = a;
|
|
264
|
+
return b;
|
|
265
|
+
}));
|
|
345
266
|
/**
|
|
346
|
-
*
|
|
347
|
-
* adapter.
|
|
267
|
+
* Updates the value of the Ref atomically using the given function.
|
|
348
268
|
*
|
|
349
|
-
*
|
|
350
|
-
* variant stores the payload together with metadata that can be known before
|
|
351
|
-
* sending it, such as `contentType` and `contentLength`. This module includes
|
|
352
|
-
* body constructors for common payload shapes, support for schema-encoded JSON
|
|
353
|
-
* bodies, streaming and file-backed bodies, and the error type used when body
|
|
354
|
-
* construction fails.
|
|
269
|
+
* **When to use**
|
|
355
270
|
*
|
|
356
|
-
*
|
|
271
|
+
* Use to apply a `Ref` state transition without returning a value.
|
|
272
|
+
*
|
|
273
|
+
* **Example** (Updating a value)
|
|
274
|
+
*
|
|
275
|
+
* ```ts import.meta.vitest
|
|
276
|
+
* import { Effect, Ref } from "effect"
|
|
277
|
+
*
|
|
278
|
+
* const program = Effect.gen(function*() {
|
|
279
|
+
* const counter = yield* Ref.make(5)
|
|
280
|
+
*
|
|
281
|
+
* yield* Ref.update(counter, (n) => n * 2)
|
|
282
|
+
* return yield* Ref.get(counter)
|
|
283
|
+
* })
|
|
284
|
+
*
|
|
285
|
+
* const program2 = Effect.gen(function*() {
|
|
286
|
+
* const counter = yield* Ref.make(5)
|
|
287
|
+
* yield* Ref.update(counter, (n: number) => n + 10)
|
|
288
|
+
* return yield* Ref.get(counter)
|
|
289
|
+
* })
|
|
290
|
+
*
|
|
291
|
+
* await Effect.runPromise(program) // => 10
|
|
292
|
+
* await Effect.runPromise(program2) // => 15
|
|
293
|
+
* ```
|
|
294
|
+
*
|
|
295
|
+
* @see {@link updateAndGet} for returning the new value
|
|
296
|
+
* @see {@link getAndUpdate} for returning the previous value
|
|
297
|
+
*
|
|
298
|
+
* @category mutations
|
|
299
|
+
* @since 2.0.0
|
|
357
300
|
*/
|
|
358
|
-
const
|
|
301
|
+
const update = /*#__PURE__*/ dual(2, (self, f) => sync(() => {
|
|
302
|
+
self.ref.current = f(self.ref.current);
|
|
303
|
+
}));
|
|
359
304
|
/**
|
|
360
|
-
*
|
|
305
|
+
* Updates the value of the Ref atomically using the given function and returns the new value.
|
|
361
306
|
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
307
|
+
* **When to use**
|
|
308
|
+
*
|
|
309
|
+
* Use to apply a `Ref` state transition and return the new stored value.
|
|
310
|
+
*
|
|
311
|
+
* **Example** (Updating and returning the new value)
|
|
312
|
+
*
|
|
313
|
+
* ```ts import.meta.vitest
|
|
314
|
+
* import { Effect, Ref } from "effect"
|
|
315
|
+
*
|
|
316
|
+
* const program = Effect.gen(function*() {
|
|
317
|
+
* const counter = yield* Ref.make(5)
|
|
318
|
+
*
|
|
319
|
+
* const newValue = yield* Ref.updateAndGet(counter, (n) => n * 3)
|
|
320
|
+
* const current = yield* Ref.get(counter)
|
|
321
|
+
* return [newValue, current]
|
|
322
|
+
* })
|
|
323
|
+
*
|
|
324
|
+
* await Effect.runPromise(program) // => [15, 15]
|
|
325
|
+
* ```
|
|
326
|
+
*
|
|
327
|
+
* @see {@link update} for updating without returning the new value
|
|
328
|
+
* @see {@link getAndUpdate} for returning the previous value instead
|
|
329
|
+
*
|
|
330
|
+
* @category mutations
|
|
331
|
+
* @since 2.0.0
|
|
364
332
|
*/
|
|
365
|
-
const
|
|
366
|
-
|
|
333
|
+
const updateAndGet = /*#__PURE__*/ dual(2, (self, f) => sync(() => self.ref.current = f(self.ref.current)));
|
|
334
|
+
//#endregion
|
|
335
|
+
//#region ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/http/HttpMethod.js
|
|
367
336
|
/**
|
|
368
|
-
*
|
|
337
|
+
* Defines supported HTTP method names for the unstable HTTP modules.
|
|
338
|
+
*
|
|
339
|
+
* Values are uppercase string literals such as `"GET"` and `"POST"`, matching
|
|
340
|
+
* the method tokens used by HTTP requests and routes. This module also includes
|
|
341
|
+
* helpers for checking whether a method can carry a request body and whether an
|
|
342
|
+
* unknown value is one of the supported methods.
|
|
369
343
|
*
|
|
370
|
-
* @category errors
|
|
371
344
|
* @since 4.0.0
|
|
372
345
|
*/
|
|
373
|
-
var HttpBodyError = class extends TaggedError("HttpBodyError") {
|
|
374
|
-
/**
|
|
375
|
-
* Marks this value as an HTTP body error for runtime guards.
|
|
376
|
-
*
|
|
377
|
-
* @since 4.0.0
|
|
378
|
-
*/
|
|
379
|
-
[HttpBodyErrorTypeId] = HttpBodyErrorTypeId;
|
|
380
|
-
};
|
|
381
|
-
var Proto$4 = class {
|
|
382
|
-
[TypeId$7];
|
|
383
|
-
constructor() {
|
|
384
|
-
this[TypeId$7] = TypeId$7;
|
|
385
|
-
}
|
|
386
|
-
[NodeInspectSymbol]() {
|
|
387
|
-
return this.toJSON();
|
|
388
|
-
}
|
|
389
|
-
toString() {
|
|
390
|
-
return format(this, { ignoreToString: true });
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
346
|
/**
|
|
394
|
-
*
|
|
347
|
+
* Returns `true` when a method can carry a request body and narrows it to `HttpMethod.WithBody`.
|
|
395
348
|
*
|
|
396
|
-
* @category
|
|
349
|
+
* @category guards
|
|
397
350
|
* @since 4.0.0
|
|
398
351
|
*/
|
|
399
|
-
|
|
400
|
-
_tag = "Empty";
|
|
401
|
-
toJSON() {
|
|
402
|
-
return {
|
|
403
|
-
_id: "effect/HttpBody",
|
|
404
|
-
_tag: "Empty"
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
};
|
|
352
|
+
const hasBody = (method) => method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE";
|
|
408
353
|
/**
|
|
409
|
-
* Provides
|
|
354
|
+
* Provides tuples mapping each supported HTTP method to its short
|
|
355
|
+
* request-constructor name.
|
|
410
356
|
*
|
|
411
357
|
* **When to use**
|
|
412
358
|
*
|
|
413
|
-
* Use when you need
|
|
359
|
+
* Use when you need the mapping from supported HTTP method literals to their
|
|
360
|
+
* short request-constructor names.
|
|
414
361
|
*
|
|
415
362
|
* @category constants
|
|
416
363
|
* @since 4.0.0
|
|
417
364
|
*/
|
|
418
|
-
const
|
|
365
|
+
const allShort = [
|
|
366
|
+
["GET", "get"],
|
|
367
|
+
["POST", "post"],
|
|
368
|
+
["PUT", "put"],
|
|
369
|
+
["DELETE", "del"],
|
|
370
|
+
["PATCH", "patch"],
|
|
371
|
+
["HEAD", "head"],
|
|
372
|
+
["OPTIONS", "options"],
|
|
373
|
+
["TRACE", "trace"]
|
|
374
|
+
];
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/http/UrlParams.js
|
|
419
377
|
/**
|
|
420
|
-
*
|
|
378
|
+
* Models URL query parameters as ordered string pairs.
|
|
379
|
+
*
|
|
380
|
+
* `UrlParams` is used for HTTP client query strings, URL-encoded form bodies,
|
|
381
|
+
* and server-side decoding. Values can be built from records, iterables, or
|
|
382
|
+
* native `URLSearchParams`, then updated, serialized, converted to a `URL`, or
|
|
383
|
+
* decoded with schemas.
|
|
421
384
|
*
|
|
422
|
-
* @category models
|
|
423
385
|
* @since 4.0.0
|
|
424
386
|
*/
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
387
|
+
const TypeId$8 = "~effect/http/UrlParams";
|
|
388
|
+
/**
|
|
389
|
+
* Returns `true` when a value is a `UrlParams` instance.
|
|
390
|
+
*
|
|
391
|
+
* @category guards
|
|
392
|
+
* @since 4.0.0
|
|
393
|
+
*/
|
|
394
|
+
const isUrlParams = (u) => hasProperty(u, TypeId$8);
|
|
395
|
+
const Proto$5 = {
|
|
396
|
+
...PipeInspectableProto,
|
|
397
|
+
[TypeId$8]: TypeId$8,
|
|
398
|
+
[Symbol.iterator]() {
|
|
399
|
+
return this.params[Symbol.iterator]();
|
|
400
|
+
},
|
|
436
401
|
toJSON() {
|
|
437
402
|
return {
|
|
438
|
-
_id: "
|
|
439
|
-
|
|
440
|
-
body: this.body,
|
|
441
|
-
contentType: this.contentType,
|
|
442
|
-
contentLength: this.contentLength
|
|
403
|
+
_id: "UrlParams",
|
|
404
|
+
params: Object.fromEntries(this.params)
|
|
443
405
|
};
|
|
406
|
+
},
|
|
407
|
+
[symbol](that) {
|
|
408
|
+
return Equivalence$1(this, that);
|
|
409
|
+
},
|
|
410
|
+
[symbol$1]() {
|
|
411
|
+
return array(this.params.flat());
|
|
444
412
|
}
|
|
445
413
|
};
|
|
446
414
|
/**
|
|
447
|
-
* Creates
|
|
415
|
+
* Creates `UrlParams` from ordered string key-value pairs.
|
|
416
|
+
*
|
|
417
|
+
* **Details**
|
|
418
|
+
*
|
|
419
|
+
* The input pairs are used as-is and are not coerced or normalized.
|
|
448
420
|
*
|
|
449
421
|
* @category constructors
|
|
450
422
|
* @since 4.0.0
|
|
451
423
|
*/
|
|
452
|
-
const
|
|
424
|
+
const make$4 = (params) => {
|
|
425
|
+
const self = Object.create(Proto$5);
|
|
426
|
+
self.params = params;
|
|
427
|
+
return self;
|
|
428
|
+
};
|
|
453
429
|
/**
|
|
454
|
-
*
|
|
430
|
+
* Creates `UrlParams` from a supported input shape.
|
|
455
431
|
*
|
|
456
432
|
* **Details**
|
|
457
433
|
*
|
|
458
|
-
*
|
|
434
|
+
* Primitive values are converted to strings, arrays produce repeated parameters,
|
|
435
|
+
* nested records use bracket notation, and `undefined` values are omitted.
|
|
459
436
|
*
|
|
460
|
-
* @category
|
|
437
|
+
* @category constructors
|
|
461
438
|
* @since 4.0.0
|
|
462
439
|
*/
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
440
|
+
const fromInput$1 = (input) => {
|
|
441
|
+
if (isUrlParams(input)) return input;
|
|
442
|
+
const parsed = fromInputNested(input);
|
|
443
|
+
const out = [];
|
|
444
|
+
for (let i = 0; i < parsed.length; i++) if (Array.isArray(parsed[i][0])) {
|
|
445
|
+
const [keys, value] = parsed[i];
|
|
446
|
+
out.push([`${keys[0]}[${keys.slice(1).join("][")}]`, value]);
|
|
447
|
+
} else out.push(parsed[i]);
|
|
448
|
+
return make$4(out);
|
|
449
|
+
};
|
|
450
|
+
const fromInputNested = (input) => {
|
|
451
|
+
const entries = typeof input[Symbol.iterator] === "function" ? fromIterable$1(input) : Object.entries(input);
|
|
452
|
+
const out = [];
|
|
453
|
+
for (const [key, value] of entries) if (Array.isArray(value)) {
|
|
454
|
+
for (let i = 0; i < value.length; i++) if (value[i] !== void 0) out.push([key, String(value[i])]);
|
|
455
|
+
} else if (typeof value === "object") {
|
|
456
|
+
const nested = fromInputNested(value);
|
|
457
|
+
for (const [k, v] of nested) out.push([[key, ...typeof k === "string" ? [k] : k], v]);
|
|
458
|
+
} else if (value !== void 0) out.push([key, String(value)]);
|
|
459
|
+
return out;
|
|
483
460
|
};
|
|
484
461
|
/**
|
|
485
|
-
*
|
|
462
|
+
* Provides an order-sensitive `Equivalence` instance for `UrlParams`.
|
|
486
463
|
*
|
|
487
464
|
* **Details**
|
|
488
465
|
*
|
|
489
|
-
*
|
|
466
|
+
* Two values are equivalent when they contain the same key-value pairs in the same
|
|
467
|
+
* order.
|
|
490
468
|
*
|
|
491
|
-
* @category
|
|
469
|
+
* @category instances
|
|
492
470
|
* @since 4.0.0
|
|
493
471
|
*/
|
|
494
|
-
const
|
|
495
|
-
const
|
|
472
|
+
const Equivalence$1 = /*#__PURE__*/ make$6((a, b) => arrayEquivalence(a.params, b.params));
|
|
473
|
+
const arrayEquivalence = /*#__PURE__*/ makeEquivalence(/*#__PURE__*/ makeEquivalence$1([/*#__PURE__*/ strictEqual(), /*#__PURE__*/ strictEqual()]));
|
|
496
474
|
/**
|
|
497
|
-
*
|
|
475
|
+
* Schema for `UrlParams`.
|
|
498
476
|
*
|
|
499
477
|
* **Details**
|
|
500
478
|
*
|
|
501
|
-
* The
|
|
479
|
+
* The encoded representation is an array of string key-value tuples.
|
|
480
|
+
*
|
|
481
|
+
* @category schemas
|
|
482
|
+
* @since 4.0.0
|
|
483
|
+
*/
|
|
484
|
+
const UrlParamsSchema = /*#__PURE__*/ declare(isUrlParams, {
|
|
485
|
+
representation: {
|
|
486
|
+
id: "effect/http/UrlParams",
|
|
487
|
+
payload: null
|
|
488
|
+
},
|
|
489
|
+
toCode: () => ({
|
|
490
|
+
runtime: "UrlParams.UrlParamsSchema",
|
|
491
|
+
Type: "UrlParams.UrlParams",
|
|
492
|
+
importDeclarations: [`import * as UrlParams from "effect/unstable/http/UrlParams"`]
|
|
493
|
+
}),
|
|
494
|
+
expected: "UrlParams",
|
|
495
|
+
toEquivalence: () => Equivalence$1,
|
|
496
|
+
toCodec: () => link()(ArraySchema(Tuple([String$1, String$1])), transform$2({
|
|
497
|
+
decode: make$4,
|
|
498
|
+
encode: (self) => self.params
|
|
499
|
+
}))
|
|
500
|
+
});
|
|
501
|
+
/**
|
|
502
|
+
* An empty `UrlParams` value.
|
|
502
503
|
*
|
|
503
504
|
* @category constructors
|
|
504
505
|
* @since 4.0.0
|
|
505
506
|
*/
|
|
506
|
-
const
|
|
507
|
+
const empty$4 = /*#__PURE__*/ make$4([]);
|
|
507
508
|
/**
|
|
508
|
-
*
|
|
509
|
+
* Transforms the underlying ordered key-value pairs of `UrlParams`.
|
|
509
510
|
*
|
|
510
511
|
* **Details**
|
|
511
512
|
*
|
|
512
|
-
* The
|
|
513
|
+
* The result is wrapped in a new `UrlParams` value.
|
|
513
514
|
*
|
|
514
|
-
* @category
|
|
515
|
+
* @category combinators
|
|
515
516
|
* @since 4.0.0
|
|
516
517
|
*/
|
|
517
|
-
const
|
|
518
|
+
const transform$1 = /*#__PURE__*/ dual(2, (self, f) => make$4(f(self.params)));
|
|
518
519
|
/**
|
|
519
|
-
*
|
|
520
|
+
* Sets multiple query parameters from input.
|
|
520
521
|
*
|
|
521
522
|
* **Details**
|
|
522
523
|
*
|
|
523
|
-
*
|
|
524
|
+
* Keys present in the input replace existing values for those keys, while
|
|
525
|
+
* unmentioned existing parameters are preserved.
|
|
524
526
|
*
|
|
525
|
-
* @category
|
|
527
|
+
* @category combinators
|
|
526
528
|
* @since 4.0.0
|
|
527
529
|
*/
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
530
|
+
const setAll$1 = /*#__PURE__*/ dual(2, (self, input) => {
|
|
531
|
+
const out = fromInput$1(input);
|
|
532
|
+
const params = out.params;
|
|
533
|
+
const keys = /* @__PURE__ */ new Set();
|
|
534
|
+
for (let i = 0; i < params.length; i++) keys.add(params[i][0]);
|
|
535
|
+
for (let i = 0; i < self.params.length; i++) {
|
|
536
|
+
if (keys.has(self.params[i][0])) continue;
|
|
537
|
+
params.push(self.params[i]);
|
|
538
|
+
}
|
|
539
|
+
return out;
|
|
534
540
|
});
|
|
535
541
|
/**
|
|
536
|
-
*
|
|
542
|
+
* Appends all query parameters produced from the supplied input.
|
|
537
543
|
*
|
|
538
544
|
* **Details**
|
|
539
545
|
*
|
|
540
|
-
*
|
|
546
|
+
* Existing parameters are preserved.
|
|
541
547
|
*
|
|
542
|
-
* @category
|
|
548
|
+
* @category combinators
|
|
543
549
|
* @since 4.0.0
|
|
544
550
|
*/
|
|
545
|
-
const
|
|
546
|
-
const encode = encodeUnknownEffect(toCodecJson(schema));
|
|
547
|
-
return (body, contentType) => encode(body, options).pipe(mapError((issue) => new HttpBodyError({
|
|
548
|
-
reason: {
|
|
549
|
-
_tag: "SchemaError",
|
|
550
|
-
issue
|
|
551
|
-
},
|
|
552
|
-
cause: issue
|
|
553
|
-
})), flatMap((body) => json(body, contentType)));
|
|
554
|
-
};
|
|
551
|
+
const appendAll = /*#__PURE__*/ dual(2, (self, input) => transform$1(self, appendAll$1(fromInput$1(input).params)));
|
|
555
552
|
/**
|
|
556
|
-
*
|
|
553
|
+
* Serializes `UrlParams` to a URL query string without a leading question mark.
|
|
557
554
|
*
|
|
558
|
-
* @category
|
|
555
|
+
* @category converting
|
|
559
556
|
* @since 4.0.0
|
|
560
557
|
*/
|
|
561
|
-
const
|
|
558
|
+
const toString = (input) => new URLSearchParams(fromInput$1(input).params).toString();
|
|
562
559
|
/**
|
|
563
|
-
*
|
|
560
|
+
* Builds a `Record` containing all the key-value pairs in the given `UrlParams`
|
|
561
|
+
* as `string` (if only one value for a key) or a `NonEmptyArray<string>`
|
|
562
|
+
* (when more than one value for a key)
|
|
564
563
|
*
|
|
565
|
-
* **
|
|
564
|
+
* **Example** (Converting parameters to a record)
|
|
566
565
|
*
|
|
567
|
-
*
|
|
566
|
+
* ```ts import.meta.vitest
|
|
567
|
+
* import { UrlParams } from "effect/unstable/http"
|
|
568
568
|
*
|
|
569
|
-
*
|
|
569
|
+
* const urlParams = UrlParams.fromInput({
|
|
570
|
+
* a: 1,
|
|
571
|
+
* b: true,
|
|
572
|
+
* c: "string",
|
|
573
|
+
* e: [1, 2, 3]
|
|
574
|
+
* })
|
|
575
|
+
* UrlParams.toRecord(urlParams) // => { a: "1", b: "true", c: "string", e: ["1", "2", "3"] }
|
|
576
|
+
* ```
|
|
577
|
+
*
|
|
578
|
+
* @category converting
|
|
570
579
|
* @since 4.0.0
|
|
571
580
|
*/
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
this.formData = formData;
|
|
580
|
-
}
|
|
581
|
-
toJSON() {
|
|
582
|
-
return {
|
|
583
|
-
_id: "effect/HttpBody",
|
|
584
|
-
_tag: "FormData",
|
|
585
|
-
formData: this.formData
|
|
586
|
-
};
|
|
581
|
+
const toRecord = (self) => {
|
|
582
|
+
const out = {};
|
|
583
|
+
for (const [k, value] of self.params) if (!Object.hasOwn(out, k)) assignProperty(out, k, value);
|
|
584
|
+
else {
|
|
585
|
+
const current = out[k];
|
|
586
|
+
if (typeof current === "string") assignProperty(out, k, [current, value]);
|
|
587
|
+
else current.push(value);
|
|
587
588
|
}
|
|
589
|
+
return out;
|
|
588
590
|
};
|
|
589
591
|
/**
|
|
590
|
-
*
|
|
592
|
+
* Builds a readonly record from `UrlParams`.
|
|
591
593
|
*
|
|
592
|
-
*
|
|
593
|
-
* @since 4.0.0
|
|
594
|
-
*/
|
|
595
|
-
const formData = (body) => new FormData(body);
|
|
596
|
-
/**
|
|
597
|
-
* HTTP body variant backed by a stream of `Uint8Array` chunks.
|
|
594
|
+
* **Details**
|
|
598
595
|
*
|
|
599
|
-
*
|
|
596
|
+
* Keys with one value map to a string, and keys with multiple values map to a
|
|
597
|
+
* non-empty readonly array of strings.
|
|
598
|
+
*
|
|
599
|
+
* @category converting
|
|
600
600
|
* @since 4.0.0
|
|
601
601
|
*/
|
|
602
|
-
|
|
603
|
-
_tag = "Stream";
|
|
604
|
-
stream;
|
|
605
|
-
contentType;
|
|
606
|
-
contentLength;
|
|
607
|
-
constructor(stream, contentType, contentLength) {
|
|
608
|
-
super();
|
|
609
|
-
this.stream = stream;
|
|
610
|
-
this.contentType = contentType;
|
|
611
|
-
this.contentLength = contentLength;
|
|
612
|
-
}
|
|
613
|
-
toJSON() {
|
|
614
|
-
return {
|
|
615
|
-
_id: "effect/HttpBody",
|
|
616
|
-
_tag: "Stream",
|
|
617
|
-
contentType: this.contentType,
|
|
618
|
-
contentLength: this.contentLength
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
};
|
|
602
|
+
const toReadonlyRecord = toRecord;
|
|
622
603
|
/**
|
|
623
|
-
*
|
|
604
|
+
* Schema that decodes `UrlParams` into a record of key-value pairs.
|
|
624
605
|
*
|
|
625
606
|
* **Details**
|
|
626
607
|
*
|
|
627
|
-
*
|
|
608
|
+
* Keys with one value decode to a string, and keys with multiple values decode to
|
|
609
|
+
* a non-empty readonly array of strings.
|
|
628
610
|
*
|
|
629
|
-
*
|
|
611
|
+
* **Example** (Decoding URL parameters to a record)
|
|
612
|
+
*
|
|
613
|
+
* ```ts import.meta.vitest
|
|
614
|
+
* import { Schema } from "effect"
|
|
615
|
+
* import { UrlParams } from "effect/unstable/http"
|
|
616
|
+
*
|
|
617
|
+
* const toStruct = UrlParams.schemaRecord.pipe(
|
|
618
|
+
* Schema.decodeTo(Schema.Struct({
|
|
619
|
+
* some: Schema.String,
|
|
620
|
+
* number: Schema.FiniteFromString
|
|
621
|
+
* }))
|
|
622
|
+
* )
|
|
623
|
+
*
|
|
624
|
+
* const decoded = Schema.decodeSync(toStruct)(UrlParams.fromInput({
|
|
625
|
+
* some: "value",
|
|
626
|
+
* number: 42
|
|
627
|
+
* }))
|
|
628
|
+
* const result = [decoded.some, decoded.number] // => ["value", 42]
|
|
629
|
+
* ```
|
|
630
|
+
*
|
|
631
|
+
* @category schemas
|
|
630
632
|
* @since 4.0.0
|
|
631
633
|
*/
|
|
632
|
-
const
|
|
634
|
+
const schemaRecord = /*#__PURE__*/ UrlParamsSchema.pipe(/*#__PURE__*/ decodeTo(/*#__PURE__*/ Record(String$1, /*#__PURE__*/ Union([String$1, /*#__PURE__*/ NonEmptyArray(String$1)])), /*#__PURE__*/ transform$2({
|
|
635
|
+
decode: toReadonlyRecord,
|
|
636
|
+
encode: fromInput$1
|
|
637
|
+
})));
|
|
633
638
|
//#endregion
|
|
634
|
-
//#region ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/http/
|
|
639
|
+
//#region ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/http/HttpBody.js
|
|
635
640
|
/**
|
|
636
|
-
*
|
|
641
|
+
* Describes HTTP request and response bodies before they reach a platform
|
|
642
|
+
* adapter.
|
|
637
643
|
*
|
|
638
|
-
* `
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
644
|
+
* `HttpBody` is the shared body representation used by the HTTP modules. Each
|
|
645
|
+
* variant stores the payload together with metadata that can be known before
|
|
646
|
+
* sending it, such as `contentType` and `contentLength`. This module includes
|
|
647
|
+
* body constructors for common payload shapes, support for schema-encoded JSON
|
|
648
|
+
* bodies, streaming and file-backed bodies, and the error type used when body
|
|
649
|
+
* construction fails.
|
|
642
650
|
*
|
|
643
651
|
* @since 4.0.0
|
|
644
652
|
*/
|
|
653
|
+
const TypeId$7 = "~effect/http/HttpBody";
|
|
645
654
|
/**
|
|
646
|
-
*
|
|
655
|
+
* Returns `true` if the provided value is an `HttpBody`.
|
|
647
656
|
*
|
|
648
|
-
* @category
|
|
657
|
+
* @category guards
|
|
649
658
|
* @since 4.0.0
|
|
650
659
|
*/
|
|
651
|
-
const
|
|
652
|
-
const
|
|
653
|
-
[TypeId$6]: { value: TypeId$6 },
|
|
654
|
-
[symbolRedactable]: { value(context) {
|
|
655
|
-
return redact(this, get$2(context, CurrentRedactedNames));
|
|
656
|
-
} },
|
|
657
|
-
toJSON: { value() {
|
|
658
|
-
return redact$1(this);
|
|
659
|
-
} },
|
|
660
|
-
[symbol]: { value(that) {
|
|
661
|
-
return Equivalence(this, that);
|
|
662
|
-
} },
|
|
663
|
-
[symbol$1]: { value() {
|
|
664
|
-
return structure(this);
|
|
665
|
-
} },
|
|
666
|
-
toString: { value: BaseProto.toString },
|
|
667
|
-
[NodeInspectSymbol]: { value: BaseProto[NodeInspectSymbol] }
|
|
668
|
-
});
|
|
669
|
-
const make$4 = (input) => Object.assign(Object.create(Proto$3), input);
|
|
660
|
+
const isHttpBody = (u) => hasProperty(u, TypeId$7);
|
|
661
|
+
const HttpBodyErrorTypeId = "~effect/http/HttpBody/HttpBodyError";
|
|
670
662
|
/**
|
|
671
|
-
*
|
|
672
|
-
* and string values.
|
|
663
|
+
* Error produced while constructing an HTTP body from JSON or schema-encoded input.
|
|
673
664
|
*
|
|
674
|
-
* @category
|
|
665
|
+
* @category errors
|
|
675
666
|
* @since 4.0.0
|
|
676
667
|
*/
|
|
677
|
-
|
|
668
|
+
var HttpBodyError = class extends TaggedError("HttpBodyError") {
|
|
669
|
+
/**
|
|
670
|
+
* Marks this value as an HTTP body error for runtime guards.
|
|
671
|
+
*
|
|
672
|
+
* @since 4.0.0
|
|
673
|
+
*/
|
|
674
|
+
[HttpBodyErrorTypeId] = HttpBodyErrorTypeId;
|
|
675
|
+
};
|
|
676
|
+
var Proto$4 = class {
|
|
677
|
+
[TypeId$7];
|
|
678
|
+
constructor() {
|
|
679
|
+
this[TypeId$7] = TypeId$7;
|
|
680
|
+
}
|
|
681
|
+
[NodeInspectSymbol]() {
|
|
682
|
+
return this.toJSON();
|
|
683
|
+
}
|
|
684
|
+
toString() {
|
|
685
|
+
return format(this, { ignoreToString: true });
|
|
686
|
+
}
|
|
687
|
+
};
|
|
678
688
|
/**
|
|
679
|
-
*
|
|
689
|
+
* HTTP body variant representing the absence of request content.
|
|
680
690
|
*
|
|
681
|
-
* @category
|
|
691
|
+
* @category models
|
|
682
692
|
* @since 4.0.0
|
|
683
693
|
*/
|
|
684
|
-
|
|
694
|
+
var Empty = class extends Proto$4 {
|
|
695
|
+
_tag = "Empty";
|
|
696
|
+
toJSON() {
|
|
697
|
+
return {
|
|
698
|
+
_id: "effect/HttpBody",
|
|
699
|
+
_tag: "Empty"
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
};
|
|
685
703
|
/**
|
|
686
|
-
*
|
|
704
|
+
* Provides the singleton empty HTTP body.
|
|
687
705
|
*
|
|
688
|
-
* **
|
|
706
|
+
* **When to use**
|
|
689
707
|
*
|
|
690
|
-
*
|
|
708
|
+
* Use when you need an HTTP body value that represents no body content.
|
|
691
709
|
*
|
|
692
|
-
* @category
|
|
710
|
+
* @category constants
|
|
693
711
|
* @since 4.0.0
|
|
694
712
|
*/
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
713
|
+
const empty$3 = /*#__PURE__*/ new Empty();
|
|
714
|
+
/**
|
|
715
|
+
* HTTP body variant containing an arbitrary runtime body value with optional content metadata.
|
|
716
|
+
*
|
|
717
|
+
* @category models
|
|
718
|
+
* @since 4.0.0
|
|
719
|
+
*/
|
|
720
|
+
var Raw = class extends Proto$4 {
|
|
721
|
+
_tag = "Raw";
|
|
722
|
+
body;
|
|
723
|
+
contentType;
|
|
724
|
+
contentLength;
|
|
725
|
+
constructor(body, contentType, contentLength) {
|
|
726
|
+
super();
|
|
727
|
+
this.body = body;
|
|
728
|
+
this.contentType = contentType;
|
|
729
|
+
this.contentLength = contentLength;
|
|
730
|
+
}
|
|
731
|
+
toJSON() {
|
|
732
|
+
return {
|
|
733
|
+
_id: "effect/HttpBody",
|
|
734
|
+
_tag: "Raw",
|
|
735
|
+
body: this.body,
|
|
736
|
+
contentType: this.contentType,
|
|
737
|
+
contentLength: this.contentLength
|
|
738
|
+
};
|
|
701
739
|
}
|
|
702
|
-
const out = Object.create(Proto$3);
|
|
703
|
-
for (const [k, v] of Object.entries(input)) if (Array.isArray(v)) out[k.toLowerCase()] = v.join(", ");
|
|
704
|
-
else if (v !== void 0) out[k.toLowerCase()] = v;
|
|
705
|
-
return out;
|
|
706
740
|
};
|
|
707
741
|
/**
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
* **Gotchas**
|
|
711
|
-
*
|
|
712
|
-
* This mutates the record's prototype and does not normalize header names; callers must provide the expected lowercase keys.
|
|
742
|
+
* Creates a raw HTTP body from an arbitrary value and optional `contentType` and `contentLength` metadata.
|
|
713
743
|
*
|
|
714
744
|
* @category constructors
|
|
715
745
|
* @since 4.0.0
|
|
716
746
|
*/
|
|
717
|
-
const
|
|
747
|
+
const raw = (body, options) => new Raw(body, options?.contentType, options?.contentLength);
|
|
718
748
|
/**
|
|
719
|
-
*
|
|
749
|
+
* HTTP body variant backed by a `Uint8Array`.
|
|
720
750
|
*
|
|
721
751
|
* **Details**
|
|
722
752
|
*
|
|
723
|
-
*
|
|
753
|
+
* It stores the bytes, content type, and byte length.
|
|
724
754
|
*
|
|
725
|
-
* @category
|
|
755
|
+
* @category models
|
|
726
756
|
* @since 4.0.0
|
|
727
757
|
*/
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
758
|
+
var Uint8Array$1 = class extends Proto$4 {
|
|
759
|
+
_tag = "Uint8Array";
|
|
760
|
+
body;
|
|
761
|
+
contentType;
|
|
762
|
+
contentLength;
|
|
763
|
+
constructor(body, contentType, contentLength) {
|
|
764
|
+
super();
|
|
765
|
+
this.body = body;
|
|
766
|
+
this.contentType = contentType;
|
|
767
|
+
this.contentLength = contentLength;
|
|
768
|
+
}
|
|
769
|
+
toJSON() {
|
|
770
|
+
return {
|
|
771
|
+
_id: "effect/HttpBody",
|
|
772
|
+
_tag: "Uint8Array",
|
|
773
|
+
body: this.contentType.startsWith("text/") || this.contentType.endsWith("json") ? new TextDecoder().decode(this.body) : `Uint8Array(${this.body.length})`,
|
|
774
|
+
contentType: this.contentType,
|
|
775
|
+
contentLength: this.contentLength
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
};
|
|
733
779
|
/**
|
|
734
|
-
*
|
|
780
|
+
* Creates a byte-array HTTP body.
|
|
735
781
|
*
|
|
736
782
|
* **Details**
|
|
737
783
|
*
|
|
738
|
-
*
|
|
784
|
+
* The content type defaults to `application/octet-stream`, and the content length is the byte array length.
|
|
739
785
|
*
|
|
740
|
-
* @category
|
|
786
|
+
* @category constructors
|
|
741
787
|
* @since 4.0.0
|
|
742
788
|
*/
|
|
743
|
-
const
|
|
744
|
-
|
|
745
|
-
...fromInput(headers)
|
|
746
|
-
}));
|
|
789
|
+
const uint8Array = (body, contentType) => new Uint8Array$1(body, contentType ?? "application/octet-stream", body.length);
|
|
790
|
+
const encoder = /*#__PURE__*/ new TextEncoder();
|
|
747
791
|
/**
|
|
748
|
-
*
|
|
792
|
+
* Creates a UTF-8 encoded text HTTP body.
|
|
749
793
|
*
|
|
750
794
|
* **Details**
|
|
751
795
|
*
|
|
752
|
-
*
|
|
796
|
+
* The content type defaults to `text/plain`.
|
|
753
797
|
*
|
|
754
|
-
* @category
|
|
798
|
+
* @category constructors
|
|
755
799
|
* @since 4.0.0
|
|
756
800
|
*/
|
|
757
|
-
const
|
|
758
|
-
const out = make$4(self);
|
|
759
|
-
Object.assign(out, headers);
|
|
760
|
-
return out;
|
|
761
|
-
});
|
|
801
|
+
const text = (body, contentType) => uint8Array(encoder.encode(body), contentType ?? "text/plain");
|
|
762
802
|
/**
|
|
763
|
-
*
|
|
803
|
+
* Creates a JSON HTTP body using `JSON.stringify`, throwing if serialization fails.
|
|
764
804
|
*
|
|
765
805
|
* **Details**
|
|
766
806
|
*
|
|
767
|
-
* The
|
|
807
|
+
* The content type defaults to `application/json`.
|
|
768
808
|
*
|
|
769
|
-
* @category
|
|
809
|
+
* @category constructors
|
|
770
810
|
* @since 4.0.0
|
|
771
811
|
*/
|
|
772
|
-
const
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
812
|
+
const jsonUnsafe = (body, contentType) => text(JSON.stringify(body), contentType ?? "application/json");
|
|
813
|
+
/**
|
|
814
|
+
* Creates a JSON HTTP body in an `Effect`.
|
|
815
|
+
*
|
|
816
|
+
* **Details**
|
|
817
|
+
*
|
|
818
|
+
* `JSON.stringify` failures are captured as `HttpBodyError` values, and the content type defaults to `application/json`.
|
|
819
|
+
*
|
|
820
|
+
* @category constructors
|
|
821
|
+
* @since 4.0.0
|
|
822
|
+
*/
|
|
823
|
+
const json = (body, contentType) => try_({
|
|
824
|
+
try: () => text(JSON.stringify(body), contentType ?? "application/json"),
|
|
825
|
+
catch: (cause) => new HttpBodyError({
|
|
826
|
+
reason: { _tag: "JsonError" },
|
|
827
|
+
cause
|
|
828
|
+
})
|
|
829
|
+
});
|
|
830
|
+
/**
|
|
831
|
+
* Creates a JSON body constructor that first encodes values with the schema's JSON codec.
|
|
832
|
+
*
|
|
833
|
+
* **Details**
|
|
834
|
+
*
|
|
835
|
+
* Schema encoding issues and JSON serialization failures are returned as `HttpBodyError` values.
|
|
836
|
+
*
|
|
837
|
+
* @category constructors
|
|
838
|
+
* @since 4.0.0
|
|
839
|
+
*/
|
|
840
|
+
const jsonSchema = (schema, options) => {
|
|
841
|
+
const encode = encodeUnknownEffect(toCodecJson(schema));
|
|
842
|
+
return (body, contentType) => encode(body, options).pipe(mapError((issue) => new HttpBodyError({
|
|
843
|
+
reason: {
|
|
844
|
+
_tag: "SchemaError",
|
|
845
|
+
issue
|
|
846
|
+
},
|
|
847
|
+
cause: issue
|
|
848
|
+
})), flatMap((body) => json(body, contentType)));
|
|
849
|
+
};
|
|
850
|
+
/**
|
|
851
|
+
* Creates an `application/x-www-form-urlencoded` HTTP body from `UrlParams`.
|
|
852
|
+
*
|
|
853
|
+
* @category constructors
|
|
854
|
+
* @since 4.0.0
|
|
855
|
+
*/
|
|
856
|
+
const urlParams = (urlParams, contentType) => text(toString(fromInput$1(urlParams)), contentType ?? "application/x-www-form-urlencoded");
|
|
857
|
+
/**
|
|
858
|
+
* HTTP body variant backed by Web `FormData`.
|
|
859
|
+
*
|
|
860
|
+
* **Details**
|
|
861
|
+
*
|
|
862
|
+
* The content type and content length are left unset so the runtime can supply multipart boundaries.
|
|
863
|
+
*
|
|
864
|
+
* @category models
|
|
865
|
+
* @since 4.0.0
|
|
866
|
+
*/
|
|
867
|
+
var FormData = class extends Proto$4 {
|
|
868
|
+
_tag = "FormData";
|
|
869
|
+
contentType = void 0;
|
|
870
|
+
contentLength = void 0;
|
|
871
|
+
formData;
|
|
872
|
+
constructor(formData) {
|
|
873
|
+
super();
|
|
874
|
+
this.formData = formData;
|
|
875
|
+
}
|
|
876
|
+
toJSON() {
|
|
877
|
+
return {
|
|
878
|
+
_id: "effect/HttpBody",
|
|
879
|
+
_tag: "FormData",
|
|
880
|
+
formData: this.formData
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
/**
|
|
885
|
+
* Wraps a Web `FormData` value as an HTTP body.
|
|
886
|
+
*
|
|
887
|
+
* @category constructors
|
|
888
|
+
* @since 4.0.0
|
|
889
|
+
*/
|
|
890
|
+
const formData = (body) => new FormData(body);
|
|
891
|
+
/**
|
|
892
|
+
* HTTP body variant backed by a stream of `Uint8Array` chunks.
|
|
893
|
+
*
|
|
894
|
+
* @category models
|
|
895
|
+
* @since 4.0.0
|
|
896
|
+
*/
|
|
897
|
+
var Stream = class extends Proto$4 {
|
|
898
|
+
_tag = "Stream";
|
|
899
|
+
stream;
|
|
900
|
+
contentType;
|
|
901
|
+
contentLength;
|
|
902
|
+
constructor(stream, contentType, contentLength) {
|
|
903
|
+
super();
|
|
904
|
+
this.stream = stream;
|
|
905
|
+
this.contentType = contentType;
|
|
906
|
+
this.contentLength = contentLength;
|
|
907
|
+
}
|
|
908
|
+
toJSON() {
|
|
909
|
+
return {
|
|
910
|
+
_id: "effect/HttpBody",
|
|
911
|
+
_tag: "Stream",
|
|
912
|
+
contentType: this.contentType,
|
|
913
|
+
contentLength: this.contentLength
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
/**
|
|
918
|
+
* Creates a streaming HTTP body from a stream of byte chunks.
|
|
919
|
+
*
|
|
920
|
+
* **Details**
|
|
921
|
+
*
|
|
922
|
+
* The content type defaults to `application/octet-stream`; content length is optional.
|
|
923
|
+
*
|
|
924
|
+
* @category constructors
|
|
925
|
+
* @since 4.0.0
|
|
926
|
+
*/
|
|
927
|
+
const stream = (body, contentType, contentLength) => new Stream(body, contentType ?? "application/octet-stream", contentLength);
|
|
928
|
+
//#endregion
|
|
929
|
+
//#region ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/http/Headers.js
|
|
930
|
+
/**
|
|
931
|
+
* Models HTTP headers for the unstable HTTP client and server modules.
|
|
932
|
+
*
|
|
933
|
+
* `Headers` values are immutable maps keyed by lowercase header name. This
|
|
934
|
+
* module converts common header inputs into that shape, provides helpers for
|
|
935
|
+
* reading and updating header values, and redacts configured sensitive headers
|
|
936
|
+
* when values are inspected.
|
|
937
|
+
*
|
|
938
|
+
* @since 4.0.0
|
|
939
|
+
*/
|
|
940
|
+
/**
|
|
941
|
+
* Runtime type identifier for `Headers` values.
|
|
942
|
+
*
|
|
943
|
+
* @category type IDs
|
|
944
|
+
* @since 4.0.0
|
|
945
|
+
*/
|
|
946
|
+
const TypeId$6 = /*#__PURE__*/ Symbol.for("~effect/http/Headers");
|
|
947
|
+
const Proto$3 = /*#__PURE__*/ Object.defineProperties(/*#__PURE__*/ Object.create(null), {
|
|
948
|
+
[TypeId$6]: { value: TypeId$6 },
|
|
949
|
+
[symbolRedactable]: { value(context) {
|
|
950
|
+
return redact(this, get$2(context, CurrentRedactedNames));
|
|
951
|
+
} },
|
|
952
|
+
toJSON: { value() {
|
|
953
|
+
return redact$1(this);
|
|
954
|
+
} },
|
|
955
|
+
[symbol]: { value(that) {
|
|
956
|
+
return Equivalence(this, that);
|
|
957
|
+
} },
|
|
958
|
+
[symbol$1]: { value() {
|
|
959
|
+
return structure(this);
|
|
960
|
+
} },
|
|
961
|
+
toString: { value: BaseProto.toString },
|
|
962
|
+
[NodeInspectSymbol]: { value: BaseProto[NodeInspectSymbol] }
|
|
963
|
+
});
|
|
964
|
+
const make$3 = (input) => Object.assign(Object.create(Proto$3), input);
|
|
965
|
+
/**
|
|
966
|
+
* Provides an `Equivalence` instance that compares `Headers` by header names
|
|
967
|
+
* and string values.
|
|
968
|
+
*
|
|
969
|
+
* @category instances
|
|
970
|
+
* @since 4.0.0
|
|
971
|
+
*/
|
|
972
|
+
const Equivalence = /*#__PURE__*/ makeEquivalence$2(/*#__PURE__*/ strictEqual());
|
|
973
|
+
/**
|
|
974
|
+
* An empty `Headers` collection.
|
|
975
|
+
*
|
|
976
|
+
* @category constructors
|
|
977
|
+
* @since 4.0.0
|
|
978
|
+
*/
|
|
979
|
+
const empty$2 = /*#__PURE__*/ Object.create(Proto$3);
|
|
980
|
+
/**
|
|
981
|
+
* Creates `Headers` from a record or iterable of header entries.
|
|
982
|
+
*
|
|
983
|
+
* **Details**
|
|
984
|
+
*
|
|
985
|
+
* Header names are normalized to lowercase. Array values in record input are joined with `", "`, and `undefined` values are omitted.
|
|
986
|
+
*
|
|
987
|
+
* @category constructors
|
|
988
|
+
* @since 4.0.0
|
|
989
|
+
*/
|
|
990
|
+
const fromInput = (input) => {
|
|
991
|
+
if (input === void 0) return empty$2;
|
|
992
|
+
else if (Symbol.iterator in input) {
|
|
993
|
+
const out = Object.create(Proto$3);
|
|
994
|
+
for (const [k, v] of input) out[k.toLowerCase()] = v;
|
|
995
|
+
return out;
|
|
996
|
+
}
|
|
997
|
+
const out = Object.create(Proto$3);
|
|
998
|
+
for (const [k, v] of Object.entries(input)) if (Array.isArray(v)) out[k.toLowerCase()] = v.join(", ");
|
|
999
|
+
else if (v !== void 0) out[k.toLowerCase()] = v;
|
|
1000
|
+
return out;
|
|
1001
|
+
};
|
|
1002
|
+
/**
|
|
1003
|
+
* Treats an existing record as `Headers` unsafely.
|
|
1004
|
+
*
|
|
1005
|
+
* **Gotchas**
|
|
1006
|
+
*
|
|
1007
|
+
* This mutates the record's prototype and does not normalize header names; callers must provide the expected lowercase keys.
|
|
1008
|
+
*
|
|
1009
|
+
* @category constructors
|
|
1010
|
+
* @since 4.0.0
|
|
1011
|
+
*/
|
|
1012
|
+
const fromRecordUnsafe = (input) => Object.setPrototypeOf(input, Proto$3);
|
|
1013
|
+
/**
|
|
1014
|
+
* Returns a new `Headers` collection with the given header set.
|
|
1015
|
+
*
|
|
1016
|
+
* **Details**
|
|
1017
|
+
*
|
|
1018
|
+
* The header name is normalized to lowercase.
|
|
1019
|
+
*
|
|
1020
|
+
* @category combinators
|
|
1021
|
+
* @since 4.0.0
|
|
1022
|
+
*/
|
|
1023
|
+
const set$1 = /*#__PURE__*/ dual(3, (self, key, value) => {
|
|
1024
|
+
const out = make$3(self);
|
|
1025
|
+
out[key.toLowerCase()] = value;
|
|
1026
|
+
return out;
|
|
1027
|
+
});
|
|
1028
|
+
/**
|
|
1029
|
+
* Returns a new `Headers` collection with all provided headers set.
|
|
1030
|
+
*
|
|
1031
|
+
* **Details**
|
|
1032
|
+
*
|
|
1033
|
+
* Input headers are normalized with `fromInput` and override existing headers with the same lowercase name.
|
|
1034
|
+
*
|
|
1035
|
+
* @category combinators
|
|
1036
|
+
* @since 4.0.0
|
|
1037
|
+
*/
|
|
1038
|
+
const setAll = /*#__PURE__*/ dual(2, (self, headers) => make$3({
|
|
1039
|
+
...self,
|
|
1040
|
+
...fromInput(headers)
|
|
1041
|
+
}));
|
|
1042
|
+
/**
|
|
1043
|
+
* Returns a new `Headers` collection containing headers from both collections.
|
|
1044
|
+
*
|
|
1045
|
+
* **Details**
|
|
1046
|
+
*
|
|
1047
|
+
* Headers from the second collection override headers from the first collection with the same name.
|
|
1048
|
+
*
|
|
1049
|
+
* @category combinators
|
|
1050
|
+
* @since 4.0.0
|
|
1051
|
+
*/
|
|
1052
|
+
const merge$1 = /*#__PURE__*/ dual(2, (self, headers) => {
|
|
1053
|
+
const out = make$3(self);
|
|
1054
|
+
Object.assign(out, headers);
|
|
1055
|
+
return out;
|
|
1056
|
+
});
|
|
1057
|
+
/**
|
|
1058
|
+
* Returns a new `Headers` collection with the named header removed.
|
|
1059
|
+
*
|
|
1060
|
+
* **Details**
|
|
1061
|
+
*
|
|
1062
|
+
* The provided header name is normalized to lowercase before removal.
|
|
1063
|
+
*
|
|
1064
|
+
* @category combinators
|
|
1065
|
+
* @since 4.0.0
|
|
1066
|
+
*/
|
|
1067
|
+
const remove = /*#__PURE__*/ dual(2, (self, key) => {
|
|
1068
|
+
const out = make$3(self);
|
|
1069
|
+
delete out[key.toLowerCase()];
|
|
1070
|
+
return out;
|
|
776
1071
|
});
|
|
777
1072
|
/**
|
|
778
1073
|
* Returns a plain record with selected header values wrapped in `Redacted`.
|
|
@@ -1097,7 +1392,7 @@ const merge = /*#__PURE__*/ dual(2, (self, that) => fromReadonlyRecord({
|
|
|
1097
1392
|
* @category combinators
|
|
1098
1393
|
* @since 4.0.0
|
|
1099
1394
|
*/
|
|
1100
|
-
const set
|
|
1395
|
+
const set = /*#__PURE__*/ dual((args) => isCookies(args[0]), (self, name, value, options) => map$1(makeCookie(name, value, options), (cookie) => fromReadonlyRecord(set$3(self.cookies, name, cookie))));
|
|
1101
1396
|
/**
|
|
1102
1397
|
* Serializes a cookie into a string.
|
|
1103
1398
|
*
|
|
@@ -1414,7 +1709,7 @@ var UrlError = class extends TaggedError("UrlError") {};
|
|
|
1414
1709
|
* @category constructors
|
|
1415
1710
|
* @since 4.0.0
|
|
1416
1711
|
*/
|
|
1417
|
-
const make$
|
|
1712
|
+
const make$2 = (url, params, hash) => try_$1({
|
|
1418
1713
|
try: () => {
|
|
1419
1714
|
const urlInstance = new URL(url, baseUrl());
|
|
1420
1715
|
for (let i = 0; i < params.params.length; i++) {
|
|
@@ -1486,7 +1781,7 @@ const empty = /*#__PURE__*/ makeWith$1("GET", "", empty$4, /*#__PURE__*/ none(),
|
|
|
1486
1781
|
* @category constructors
|
|
1487
1782
|
* @since 4.0.0
|
|
1488
1783
|
*/
|
|
1489
|
-
const make$
|
|
1784
|
+
const make$1 = (method) => (url, options) => modify(empty, {
|
|
1490
1785
|
method,
|
|
1491
1786
|
url,
|
|
1492
1787
|
...options ?? void 0
|
|
@@ -1497,28 +1792,28 @@ const make$2 = (method) => (url, options) => modify$1(empty, {
|
|
|
1497
1792
|
* @category constructors
|
|
1498
1793
|
* @since 4.0.0
|
|
1499
1794
|
*/
|
|
1500
|
-
const get
|
|
1795
|
+
const get = /*#__PURE__*/ make$1("GET");
|
|
1501
1796
|
/**
|
|
1502
1797
|
* Creates a `POST` request for the specified URL.
|
|
1503
1798
|
*
|
|
1504
1799
|
* @category constructors
|
|
1505
1800
|
* @since 4.0.0
|
|
1506
1801
|
*/
|
|
1507
|
-
const post = /*#__PURE__*/ make$
|
|
1802
|
+
const post = /*#__PURE__*/ make$1("POST");
|
|
1508
1803
|
/**
|
|
1509
1804
|
* Creates a `PUT` request for the specified URL.
|
|
1510
1805
|
*
|
|
1511
1806
|
* @category constructors
|
|
1512
1807
|
* @since 4.0.0
|
|
1513
1808
|
*/
|
|
1514
|
-
const put = /*#__PURE__*/ make$
|
|
1809
|
+
const put = /*#__PURE__*/ make$1("PUT");
|
|
1515
1810
|
/**
|
|
1516
1811
|
* Applies request options to an `HttpClientRequest`, returning a new request.
|
|
1517
1812
|
*
|
|
1518
1813
|
* @category combinators
|
|
1519
1814
|
* @since 4.0.0
|
|
1520
1815
|
*/
|
|
1521
|
-
const modify
|
|
1816
|
+
const modify = /*#__PURE__*/ dual(2, (self, options) => {
|
|
1522
1817
|
let result = self;
|
|
1523
1818
|
if (options.method) result = setMethod(result, options.method);
|
|
1524
1819
|
if (options.url) result = setUrl(result, options.url);
|
|
@@ -1543,7 +1838,7 @@ const setMethod = /*#__PURE__*/ dual(2, (self, method) => makeWith$1(method, sel
|
|
|
1543
1838
|
* @category combinators
|
|
1544
1839
|
* @since 4.0.0
|
|
1545
1840
|
*/
|
|
1546
|
-
const setHeader = /*#__PURE__*/ dual(3, (self, key, value) => makeWith$1(self.method, self.url, self.urlParams, self.hash, set$
|
|
1841
|
+
const setHeader = /*#__PURE__*/ dual(3, (self, key, value) => makeWith$1(self.method, self.url, self.urlParams, self.hash, set$1(self.headers, key, value), self.body));
|
|
1547
1842
|
/**
|
|
1548
1843
|
* Sets multiple request headers from an input collection, replacing existing values with matching names.
|
|
1549
1844
|
*
|
|
@@ -1640,8 +1935,8 @@ const setBody = /*#__PURE__*/ dual(2, (self, body) => {
|
|
|
1640
1935
|
let headers = self.headers;
|
|
1641
1936
|
if (body._tag === "Empty" || body._tag === "FormData") headers = remove(remove(headers, "Content-Type"), "Content-length");
|
|
1642
1937
|
else {
|
|
1643
|
-
if (body.contentType) headers = set$
|
|
1644
|
-
if (body.contentLength !== void 0) headers = set$
|
|
1938
|
+
if (body.contentType) headers = set$1(headers, "content-type", body.contentType);
|
|
1939
|
+
if (body.contentLength !== void 0) headers = set$1(headers, "content-length", body.contentLength.toString());
|
|
1645
1940
|
else headers = remove(headers, "content-length");
|
|
1646
1941
|
}
|
|
1647
1942
|
return makeWith$1(self.method, self.url, self.urlParams, self.hash, headers, body);
|
|
@@ -2023,301 +2318,6 @@ const w3c = (headers) => {
|
|
|
2023
2318
|
}
|
|
2024
2319
|
};
|
|
2025
2320
|
//#endregion
|
|
2026
|
-
//#region ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/Ref.js
|
|
2027
|
-
/**
|
|
2028
|
-
* Stores fiber-safe mutable state inside Effect programs.
|
|
2029
|
-
*
|
|
2030
|
-
* A `Ref<A>` holds one value and exposes reads, writes, and atomic
|
|
2031
|
-
* transformations as effects, so state changes compose with Effect's
|
|
2032
|
-
* concurrency model. This module includes constructors, safe and unsafe reads,
|
|
2033
|
-
* set and get-and-set helpers, update and modify helpers, and conditional
|
|
2034
|
-
* update variants that leave the value unchanged when an `Option.none` result
|
|
2035
|
-
* is returned.
|
|
2036
|
-
*
|
|
2037
|
-
* @since 2.0.0
|
|
2038
|
-
*/
|
|
2039
|
-
const RefProto = {
|
|
2040
|
-
["~effect/Ref"]: { _A: identity },
|
|
2041
|
-
...PipeInspectableProto,
|
|
2042
|
-
toJSON() {
|
|
2043
|
-
return {
|
|
2044
|
-
_id: "Ref",
|
|
2045
|
-
ref: this.ref
|
|
2046
|
-
};
|
|
2047
|
-
}
|
|
2048
|
-
};
|
|
2049
|
-
/**
|
|
2050
|
-
* Creates a new Ref with the specified initial value (unsafe version).
|
|
2051
|
-
*
|
|
2052
|
-
* **When to use**
|
|
2053
|
-
*
|
|
2054
|
-
* Use when you need immediate synchronous construction and can guarantee
|
|
2055
|
-
* that creating the `Ref` outside of `Effect` is safe.
|
|
2056
|
-
*
|
|
2057
|
-
* **Gotchas**
|
|
2058
|
-
*
|
|
2059
|
-
* Prefer `Ref.make` for Effect-wrapped creation in Effect programs.
|
|
2060
|
-
*
|
|
2061
|
-
* **Example** (Creating a ref unsafely)
|
|
2062
|
-
*
|
|
2063
|
-
* ```ts import.meta.vitest
|
|
2064
|
-
* import { Ref } from "effect"
|
|
2065
|
-
*
|
|
2066
|
-
* const counter = Ref.makeUnsafe(0)
|
|
2067
|
-
* Ref.getUnsafe(counter) // => 0
|
|
2068
|
-
* ```
|
|
2069
|
-
*
|
|
2070
|
-
* @category constructors
|
|
2071
|
-
* @since 4.0.0
|
|
2072
|
-
*/
|
|
2073
|
-
const makeUnsafe = (value) => {
|
|
2074
|
-
const self = Object.create(RefProto);
|
|
2075
|
-
self.ref = make$8(value);
|
|
2076
|
-
return self;
|
|
2077
|
-
};
|
|
2078
|
-
/**
|
|
2079
|
-
* Creates a new Ref with the specified initial value.
|
|
2080
|
-
*
|
|
2081
|
-
* **When to use**
|
|
2082
|
-
*
|
|
2083
|
-
* Use to create a `Ref` for shared mutable state inside an Effect program.
|
|
2084
|
-
*
|
|
2085
|
-
* **Example** (Creating a ref)
|
|
2086
|
-
*
|
|
2087
|
-
* ```ts import.meta.vitest
|
|
2088
|
-
* import { Effect, Ref } from "effect"
|
|
2089
|
-
*
|
|
2090
|
-
* const program = Effect.gen(function*() {
|
|
2091
|
-
* const ref = yield* Ref.make(42)
|
|
2092
|
-
* return yield* Ref.get(ref)
|
|
2093
|
-
* })
|
|
2094
|
-
*
|
|
2095
|
-
* await Effect.runPromise(program) // => 42
|
|
2096
|
-
* ```
|
|
2097
|
-
*
|
|
2098
|
-
* @see {@link makeUnsafe} for synchronous construction outside Effect code
|
|
2099
|
-
*
|
|
2100
|
-
* @category constructors
|
|
2101
|
-
* @since 2.0.0
|
|
2102
|
-
*/
|
|
2103
|
-
const make$1 = (value) => sync(() => makeUnsafe(value));
|
|
2104
|
-
/**
|
|
2105
|
-
* Gets the current value of the Ref.
|
|
2106
|
-
*
|
|
2107
|
-
* **When to use**
|
|
2108
|
-
*
|
|
2109
|
-
* Use to read the current `Ref` value without changing it.
|
|
2110
|
-
*
|
|
2111
|
-
* **Example** (Getting the current value)
|
|
2112
|
-
*
|
|
2113
|
-
* ```ts import.meta.vitest
|
|
2114
|
-
* import { Effect, Ref } from "effect"
|
|
2115
|
-
*
|
|
2116
|
-
* const program = Effect.gen(function*() {
|
|
2117
|
-
* const ref = yield* Ref.make(42)
|
|
2118
|
-
* return yield* Ref.get(ref)
|
|
2119
|
-
* })
|
|
2120
|
-
*
|
|
2121
|
-
* await Effect.runPromise(program) // => 42
|
|
2122
|
-
* ```
|
|
2123
|
-
*
|
|
2124
|
-
* @see {@link set} for replacing the current value
|
|
2125
|
-
*
|
|
2126
|
-
* @category getters
|
|
2127
|
-
* @since 2.0.0
|
|
2128
|
-
*/
|
|
2129
|
-
const get = (self) => sync(() => self.ref.current);
|
|
2130
|
-
/**
|
|
2131
|
-
* Sets the value of the Ref to the specified value.
|
|
2132
|
-
*
|
|
2133
|
-
* **When to use**
|
|
2134
|
-
*
|
|
2135
|
-
* Use to replace the current `Ref` value with a known value.
|
|
2136
|
-
*
|
|
2137
|
-
* **Example** (Setting a value)
|
|
2138
|
-
*
|
|
2139
|
-
* ```ts import.meta.vitest
|
|
2140
|
-
* import { Effect, Ref } from "effect"
|
|
2141
|
-
*
|
|
2142
|
-
* const program = Effect.gen(function*() {
|
|
2143
|
-
* const ref = yield* Ref.make(0)
|
|
2144
|
-
* yield* Ref.set(ref, 42)
|
|
2145
|
-
* return yield* Ref.get(ref)
|
|
2146
|
-
* })
|
|
2147
|
-
*
|
|
2148
|
-
* const program2 = Effect.gen(function*() {
|
|
2149
|
-
* const ref = yield* Ref.make(0)
|
|
2150
|
-
* yield* Ref.set(ref, 100)
|
|
2151
|
-
* return yield* Ref.get(ref)
|
|
2152
|
-
* })
|
|
2153
|
-
*
|
|
2154
|
-
* await Effect.runPromise(program) // => 42
|
|
2155
|
-
* await Effect.runPromise(program2) // => 100
|
|
2156
|
-
* ```
|
|
2157
|
-
*
|
|
2158
|
-
* @see {@link getAndSet} for setting while returning the previous value
|
|
2159
|
-
* @see {@link setAndGet} for setting while returning the new value
|
|
2160
|
-
*
|
|
2161
|
-
* @category mutations
|
|
2162
|
-
* @since 2.0.0
|
|
2163
|
-
*/
|
|
2164
|
-
const set = /*#__PURE__*/ dual(2, (self, value) => sync(() => set$4(self.ref, value)));
|
|
2165
|
-
/**
|
|
2166
|
-
* Gets the current value of the Ref, sets it to the specified value, and returns the previous value atomically.
|
|
2167
|
-
*
|
|
2168
|
-
* **When to use**
|
|
2169
|
-
*
|
|
2170
|
-
* Use to replace a plain `Ref` value while returning the previous value.
|
|
2171
|
-
*
|
|
2172
|
-
* **Example** (Replacing a value atomically)
|
|
2173
|
-
*
|
|
2174
|
-
* ```ts import.meta.vitest
|
|
2175
|
-
* import { Effect, Ref } from "effect"
|
|
2176
|
-
*
|
|
2177
|
-
* const program = Effect.gen(function*() {
|
|
2178
|
-
* const ref = yield* Ref.make("initial")
|
|
2179
|
-
*
|
|
2180
|
-
* const previous = yield* Ref.getAndSet(ref, "updated")
|
|
2181
|
-
* const current = yield* Ref.get(ref)
|
|
2182
|
-
* return [previous, current]
|
|
2183
|
-
* })
|
|
2184
|
-
*
|
|
2185
|
-
* await Effect.runPromise(program) // => ["initial", "updated"]
|
|
2186
|
-
* ```
|
|
2187
|
-
*
|
|
2188
|
-
* @see {@link set} for setting without returning the previous value
|
|
2189
|
-
* @see {@link getAndUpdate} for deriving the new value from the previous value
|
|
2190
|
-
*
|
|
2191
|
-
* @category mutations
|
|
2192
|
-
* @since 2.0.0
|
|
2193
|
-
*/
|
|
2194
|
-
const getAndSet = /*#__PURE__*/ dual(2, (self, value) => sync(() => {
|
|
2195
|
-
const current = self.ref.current;
|
|
2196
|
-
self.ref.current = value;
|
|
2197
|
-
return current;
|
|
2198
|
-
}));
|
|
2199
|
-
/**
|
|
2200
|
-
* Modifies the value of the Ref atomically using the given function.
|
|
2201
|
-
*
|
|
2202
|
-
* **When to use**
|
|
2203
|
-
*
|
|
2204
|
-
* Use to compute both a separate return value and the next stored `Ref` value
|
|
2205
|
-
* in one atomic update.
|
|
2206
|
-
*
|
|
2207
|
-
* **Details**
|
|
2208
|
-
*
|
|
2209
|
-
* The function receives the current value and returns a tuple of
|
|
2210
|
-
* `[result, newValue]`. The Ref is updated with `newValue`, and `result` is
|
|
2211
|
-
* returned by the effect.
|
|
2212
|
-
*
|
|
2213
|
-
* **Example** (Modifying a value atomically)
|
|
2214
|
-
*
|
|
2215
|
-
* ```ts import.meta.vitest
|
|
2216
|
-
* import { Effect, Ref } from "effect"
|
|
2217
|
-
*
|
|
2218
|
-
* const program = Effect.gen(function*() {
|
|
2219
|
-
* const counter = yield* Ref.make(10)
|
|
2220
|
-
*
|
|
2221
|
-
* const result = yield* Ref.modify(counter, (n) => [
|
|
2222
|
-
* `Previous value was ${n}`,
|
|
2223
|
-
* n * 2
|
|
2224
|
-
* ])
|
|
2225
|
-
* const current = yield* Ref.get(counter)
|
|
2226
|
-
* return [result, current]
|
|
2227
|
-
* })
|
|
2228
|
-
*
|
|
2229
|
-
* const program2 = Effect.gen(function*() {
|
|
2230
|
-
* const state = yield* Ref.make({ count: 0, total: 0 })
|
|
2231
|
-
* return yield* Ref.modify(state, (s) => [
|
|
2232
|
-
* s.count,
|
|
2233
|
-
* { count: s.count + 1, total: s.total + s.count + 1 }
|
|
2234
|
-
* ])
|
|
2235
|
-
* })
|
|
2236
|
-
*
|
|
2237
|
-
* await Effect.runPromise(program) // => ["Previous value was 10", 20]
|
|
2238
|
-
* await Effect.runPromise(program2) // => 0
|
|
2239
|
-
* ```
|
|
2240
|
-
*
|
|
2241
|
-
* @see {@link updateAndGet} for returning the new stored value
|
|
2242
|
-
* @see {@link modifySome} for optionally updating while returning a separate result
|
|
2243
|
-
*
|
|
2244
|
-
* @category mutations
|
|
2245
|
-
* @since 2.0.0
|
|
2246
|
-
*/
|
|
2247
|
-
const modify = /*#__PURE__*/ dual(2, (self, f) => sync(() => {
|
|
2248
|
-
const [b, a] = f(self.ref.current);
|
|
2249
|
-
self.ref.current = a;
|
|
2250
|
-
return b;
|
|
2251
|
-
}));
|
|
2252
|
-
/**
|
|
2253
|
-
* Updates the value of the Ref atomically using the given function.
|
|
2254
|
-
*
|
|
2255
|
-
* **When to use**
|
|
2256
|
-
*
|
|
2257
|
-
* Use to apply a `Ref` state transition without returning a value.
|
|
2258
|
-
*
|
|
2259
|
-
* **Example** (Updating a value)
|
|
2260
|
-
*
|
|
2261
|
-
* ```ts import.meta.vitest
|
|
2262
|
-
* import { Effect, Ref } from "effect"
|
|
2263
|
-
*
|
|
2264
|
-
* const program = Effect.gen(function*() {
|
|
2265
|
-
* const counter = yield* Ref.make(5)
|
|
2266
|
-
*
|
|
2267
|
-
* yield* Ref.update(counter, (n) => n * 2)
|
|
2268
|
-
* return yield* Ref.get(counter)
|
|
2269
|
-
* })
|
|
2270
|
-
*
|
|
2271
|
-
* const program2 = Effect.gen(function*() {
|
|
2272
|
-
* const counter = yield* Ref.make(5)
|
|
2273
|
-
* yield* Ref.update(counter, (n: number) => n + 10)
|
|
2274
|
-
* return yield* Ref.get(counter)
|
|
2275
|
-
* })
|
|
2276
|
-
*
|
|
2277
|
-
* await Effect.runPromise(program) // => 10
|
|
2278
|
-
* await Effect.runPromise(program2) // => 15
|
|
2279
|
-
* ```
|
|
2280
|
-
*
|
|
2281
|
-
* @see {@link updateAndGet} for returning the new value
|
|
2282
|
-
* @see {@link getAndUpdate} for returning the previous value
|
|
2283
|
-
*
|
|
2284
|
-
* @category mutations
|
|
2285
|
-
* @since 2.0.0
|
|
2286
|
-
*/
|
|
2287
|
-
const update = /*#__PURE__*/ dual(2, (self, f) => sync(() => {
|
|
2288
|
-
self.ref.current = f(self.ref.current);
|
|
2289
|
-
}));
|
|
2290
|
-
/**
|
|
2291
|
-
* Updates the value of the Ref atomically using the given function and returns the new value.
|
|
2292
|
-
*
|
|
2293
|
-
* **When to use**
|
|
2294
|
-
*
|
|
2295
|
-
* Use to apply a `Ref` state transition and return the new stored value.
|
|
2296
|
-
*
|
|
2297
|
-
* **Example** (Updating and returning the new value)
|
|
2298
|
-
*
|
|
2299
|
-
* ```ts import.meta.vitest
|
|
2300
|
-
* import { Effect, Ref } from "effect"
|
|
2301
|
-
*
|
|
2302
|
-
* const program = Effect.gen(function*() {
|
|
2303
|
-
* const counter = yield* Ref.make(5)
|
|
2304
|
-
*
|
|
2305
|
-
* const newValue = yield* Ref.updateAndGet(counter, (n) => n * 3)
|
|
2306
|
-
* const current = yield* Ref.get(counter)
|
|
2307
|
-
* return [newValue, current]
|
|
2308
|
-
* })
|
|
2309
|
-
*
|
|
2310
|
-
* await Effect.runPromise(program) // => [15, 15]
|
|
2311
|
-
* ```
|
|
2312
|
-
*
|
|
2313
|
-
* @see {@link update} for updating without returning the new value
|
|
2314
|
-
* @see {@link getAndUpdate} for returning the previous value instead
|
|
2315
|
-
*
|
|
2316
|
-
* @category mutations
|
|
2317
|
-
* @since 2.0.0
|
|
2318
|
-
*/
|
|
2319
|
-
const updateAndGet = /*#__PURE__*/ dual(2, (self, f) => sync(() => self.ref.current = f(self.ref.current)));
|
|
2320
|
-
//#endregion
|
|
2321
2321
|
//#region ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/http/HttpClient.js
|
|
2322
2322
|
const TypeId = "~effect/http/HttpClient";
|
|
2323
2323
|
/**
|
|
@@ -2394,7 +2394,7 @@ const Proto = {
|
|
|
2394
2394
|
return { _id: "effect/HttpClient" };
|
|
2395
2395
|
},
|
|
2396
2396
|
.../*#__PURE__*/ Object.fromEntries(/*#__PURE__*/ allShort.map(([fullMethod, method]) => [method, function(url, options) {
|
|
2397
|
-
return this.execute(make$
|
|
2397
|
+
return this.execute(make$1(fullMethod)(url, options));
|
|
2398
2398
|
}]))
|
|
2399
2399
|
};
|
|
2400
2400
|
/**
|
|
@@ -2410,7 +2410,7 @@ const Proto = {
|
|
|
2410
2410
|
const make = (f) => makeWith((effect) => flatMap(effect, (request) => withFiber((fiber) => {
|
|
2411
2411
|
const scopedController = scopedRequests.get(request);
|
|
2412
2412
|
const controller = scopedController ?? new AbortController();
|
|
2413
|
-
const urlResult = make$
|
|
2413
|
+
const urlResult = make$2(request.url, request.urlParams, getOrUndefined(request.hash));
|
|
2414
2414
|
if (isFailure(urlResult)) return fail$1(new HttpClientError({ reason: new InvalidUrlError({
|
|
2415
2415
|
request,
|
|
2416
2416
|
cause: urlResult.failure
|
|
@@ -2742,6 +2742,6 @@ const layer = /*#__PURE__*/ layerMergedContext(/*#__PURE__*/ succeed$1(/* @__PUR
|
|
|
2742
2742
|
return send(void 0);
|
|
2743
2743
|
})));
|
|
2744
2744
|
//#endregion
|
|
2745
|
-
export {
|
|
2745
|
+
export { fromRecordUnsafe as $, make$1 as A, __require as At, StatusCodeError as B, basicAuth as C, modify$1 as Ct, bodyJsonUnsafe as D, __commonJSMin as Dt, bodyJson as E, updateAndGet as Et, setHeader as F, isEmpty as G, isHttpClientError as H, setHeaders as I, set as J, merge as K, setUrl as L, prependUrl as M, put as N, bodyText as O, __exportAll as Ot, setBody as P, fromInput as Q, DecodeError as R, appendUrlParams as S, makeUnsafe as St, bodyFormData as T, update as Tt, empty$1 as U, TransportError as V, fromSetCookie as W, CurrentRedactedNames as X, toSetCookieHeaders as Y, empty$2 as Z, MaxBodySize as _, toString as _t, execute as a, empty$3 as at, schemaBodyJson as b, getAndSet as bt, make as c, jsonUnsafe as ct, transformResponse as d, text as dt, merge$1 as et, withScope as f, uint8Array as ft, matchStatus as g, toRecord as gt, filterStatusOk$1 as h, schemaRecord as ht, TracerPropagationEnabled as i, setAll as it, post as j, __toESM as jt, get as k, __reExport as kt, mapRequest as l, raw as lt, TypeId$1 as m, fromInput$1 as mt, layer as n, remove as nt, filterStatusOk as o, isHttpBody as ot, fromHeaders as p, urlParams as pt, parseHeader as q, HttpClient as r, set$1 as rt, layerMergedContext as s, jsonSchema as st, RequestInit as t, redact as tt, retryTransient as u, stream as ut, TypeId$2 as v, hasBody as vt, bearerToken as w, set$2 as wt, acceptJson as x, make$5 as xt, inspect as y, get$1 as yt, HttpClientError as z };
|
|
2746
2746
|
|
|
2747
|
-
//# sourceMappingURL=FetchHttpClient-
|
|
2747
|
+
//# sourceMappingURL=FetchHttpClient-DkBX_tvM.mjs.map
|