@deslop/stash 0.1.1090 → 0.1.1091
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/cli.js +112 -5
- package/dist/{contracts-CdQiWFv_.mjs → contracts-C1Rqhg6U.mjs} +741 -164
- package/dist/server.js +932 -478
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --max-old-space-size=16384 --heapsnapshot-near-heap-limit=3 --report-on-fatalerror
|
|
2
|
-
import { $ as constPong, $a as isPrivate, $c as isNoSuchElementError, $d as combine$1, $i as last$2, $l as DisablePropagation, $n as unwrap$1, $o as makeSpanScoped, $r as toEpochMillis, $s as withFiber, $t as String$1, $u as make$44, A as layer$10, Aa as badArgument, Ac as split, Ad as exists, Af as constUndefined, Ai as mapError$1, Al as TracerTimingEnabled, An as make$41, Ao as flatMap, Ar as FilterGroup, As as serviceOption, At as Boolean$2, Au as headNonEmpty, B as unwrap$4, Ba as nameServerFromInput, Bc as StackTrace, Bd as isNone, Bi as runForEach, Bl as isExit, Bn as toType, Bo as fromResult, Br as null_, Bs as timeoutOption, Bt as Finite, Bu as prepend$2, C as runMain, Ca as await_, Cc as length, Cd as getOrUndefinedUnsafe, Cf as isObject, Ci as groupedWithin, Cl as forkUnsafe$1, Cn as isGreaterThanOrEqualTo, Cr as toArrayBuffer, Cs as retry, Cu as flatMap$2, Da as interruptAllAs, Dc as replace$1, Dd as merge$1, Df as compose$1, Di as mapArray, Dl as CurrentLogAnnotations, Dn as isPattern, Do as fail$1, Dr as ChildProcessSpawner, Ds as runSync, Dt as isHttpClientError, Du as getUnsafe$1, E as layer$11, Ea as interruptAll, Ec as repeat$1, Ed as makeUnsafe$3, Ef as or$1, Ei as mapAccum, El as provide$1, En as isMinLength, Eo as exit, Er as make$40, Es as runForkWith, Et as TransportError, Eu as getSomes, F as String$2, Fa as zero, Fc as max$2, Fd as fromNullishOr, Ff as identity, Fi as orDie$1, Fl as makeUnsafe$4, Fn as tag, Fo as forever$1, Fr as Union$1, Fs as sync, Ft as Defect, Fu as last$1, G as RpcSerialization, Ga as formatUrlUnsafe, Gc as fail$4, Gd as match$1, Gi as succeed$3, Gl as effectIsExit, Gn as omit, Go as interruptible, Gr as string, Gs as uninterruptible, Gt as MutableJson, Gu as take$1, Ha as NetAddressError, Hc as combine, Hd as liftPredicate, Hl as isSuccess$1, Hn as withDecodingDefault, Ho as ignore$1, Hr as replaceChecks, Hs as transposeOption, Ht as Json, Hu as reverse, I as URL$1, Ia as Dns, Ic as parse$10, Id as fromUndefinedOr, If as pipe, Ii as pipeThroughChannel, Il as die, In as toCodecJson, Io as forkChild, Ir as decodeTo$1, Is as tap$1, It as Duration, Iu as lastNonEmpty, J as layerSchemaBinary, Ja as ipFromStringUnsafe, Jc as fromReasons, Jd as orElseSome, Ji as tap$2, Jl as forkUnsafe, Jn as CurrentRedactedNames$1, Jo as logDebug, Jr as transform$1, Js as updateService, Jt as Null, Ju as keys, K as json$1, Ka as inetAddressFromIpString, Kc as filterInterruptors, Kd as none, Ki as suspend$1, Kl as fiberEnterInterruptibleUnsafe, Kn as getReferenceKey, Ko as isEffect, Kr as toEncoded, Ks as uninterruptibleMask, Kt as Never, Ku as takeRight, L as option, La as DnsError, Ld as getOrElse, Lf as pipeArguments, Li as provideService$1, Ll as fail$3, Lo as forkIn, Lr as isNever, Ls as tapCause, Lt as Error$2, Lu as map$3, M as Port, Ma as fromInputUnsafe, Mc as toLowerCase, Md as flatMap$1, Mf as constant, Mi as mkString, Ml as doneUnsafe, Mn as mutable, Mo as fn$1, Mr as Objects, Ms as succeed$1, Mt as Class$1, Mu as isReadonlyArrayEmpty, N as Record, Na as gibibytes, Nc as trim, Nd as flatMapNullishOr, Nf as dual, Ni as mkUint8Array, Nl as into, Nn as optional$1, No as fnUntraced, Nr as PropertySignature, Ns as succeedNone, Nt as DateTimeUtc, Nu as isReadonlyArrayNonEmpty, Oa as interruptAs, Oc as replaceAll, Od as all$1, Of as constFalse, Oi as mapArrayEffect, Ol as CurrentLogSpans, On as isSchema, Oo as failCause, Or as Arrays, Os as scope, Ot as Any, Ou as groupBy, P as Redacted$1, Pa as mebibytes, Pc as trimEnd, Pd as flatten, Pf as flow, Pi as onEnd, Pl as isDeferred, Pn as optionalKey, Po as forEach, Pr as Suspend, Ps as suspend, Pt as DateTimeUtcFromString, Pu as join$1, Qa as isLoopback, Qd as String$3, Qi as unwrap$2, Qn as setAll$1, Qo as logWarning, Qr as now, Qs as whileLoop, Qt as Redacted, Qu as headUnsafe, R as schema, Ra as make$37, Rc as Clock, Rd as getOrNull, Ri as run$3, Rl as failCause$1, Rn as toEncoded$1, Ro as forkScoped, Rr as isOptional, Rs as tapError$1, Rt as Exit$1, S as make$38, Sa as makeUnsafe$5, Sc as isNonEmpty, Sd as getOrUndefined$1, Sf as isNotUndefined, Si as fromReadableStream, Sl as closeUnsafe, Sn as is$4, So as contextWith, Sr as pipeThroughDuplex, Ss as result$1, St as HttpClientError, Ta as interrupt$2, Tc as padStart, Td as make$42, Tf as isUndefined, Ti as map$2, Tl as makeUnsafe$2, Tn as isMaxLength, To as ensuring$1, Tr as fromWritable, Ts as runFork, Tt as StatusCodeError, Tu as get$6, U as withRun, Ua as formatInet, Uc as die$1, Ud as liftThrowable, Ui as runLast, Ul as succeed$4, Un as withDecodingDefaultKey, Ur as resolveDescription, Us as tryPromise, Ut as Literal$1, Uu as some$2, V as withDefault, Va as domainNameFromStringUnsafe, Vc as annotate, Vd as isSome, Vi as runForEachArray, Vl as isFailure$1, Vn as withConstructorDefault, Vo as gen, Vr as optionalKey$1, Vs as timeoutOrElse, Vt as Int, Vu as reduce, Wa as formatIp, Wd as map$4, Wi as scan, Wn as isSchemaError, Wo as interrupt, Wr as resolveIdentifier, Ws as try_, Wt as Literals, Wu as sort, X as ResponseDefectEncoded, Xa as isInetAddressV6, Xc as hasInterrupts, Xd as toArray$1, Xi as toReadableStreamEffect, Xl as onExitUnsafe, Xn as fromInput, Xo as logFatal, Xr as encode, Xs as void_, Xt as Number$2, Xu as toEntries, Y as RequestId, Ya as ipv4ToOctets, Yc as hasDies, Yd as some$1, Yi as toReadableStream, Yl as makeSpanUnsafe, Yn as empty$7, Yr as transformOptional, Ys as useSpan, Yt as NullOr, Yu as map$6, Z as constEof, Za as isLinkLocal, Zc as hasInterruptsOnly, Zd as Number$1, Zl as reportCauseUnsafe, Zn as redactUrl, Zo as logInfo, Zr as formatIso, Zs as when$2, Zt as Record$1, Zu as empty$12, _ as Organization, _c as Random$2, _d as Reference, _f as hash, _l as unwrap$3, _n as encodeEffect, _o as catchReason, _r as fromSetCookie, _s as provideContext, _u as every, a as FxConversation, aa as pipeTo, ac as zipWith, ad as isSuccess, af as contE, ai as catch_$1, al as buildWithMemoMap, an as URL$2, ao as annotateCurrentSpan, ar as empty$8, as as matchCauseEffectEager, at as isStreamSchema, au as random$1, ba as publishUnsafe, bc as includes, bf as isNotNull, bi as fromPubSub, bl as addFinalizerExit, bn as encodeUnknownEffect$1, bo as catch_, br as toSetCookieHeaders, bs as raceFirst, bt as EmptyBodyError, bu as findFirst, c as GitHubIssue, cc as forever, cd as try_$1, cf as getStackTraceLimit, ci as die$3, cl as effectDiscard, cn as Uint8ArrayFromBase64, co as asSome, cr as isRedactedName, cs as onError, ct as Collector, cu as TaggedError, d as ImageType, da as failCause$2, dd as max$1, df as Class, di as fail$2, dl as mergeAll, dn as Unknown, do as callback, dr as set$1, ds as onInterrupt, du as contains$2, ec as withFiberSucceed, ed as fail, ef as flip, ei as defaultFormatter, el as isTimeoutError, en as StringFromUriComponent, eo as isUnicast, er as fromIterable$3, es as map$1, et as ServerClient, eu as ParentSpan, f as Note, fa as make$36, fc as passthrough, fd as millis, ff as NodeInspectSymbol, fi as failCause$3, fl as provide, fn as decodeEffect, fo as catchCause, fr as setAll, fs as option$1, ft as SocketError, fu as dedupe, g as OEmbed, ga as shutdown, gd as zero$1, gf as equals, gi as fromArray, gl as sync$1, gn as decodeUnknownOption, go as catchIf, gr as empty$9, gs as provide$2, gt as fromWebSocket, gu as ensure, h as NotesError, ha as offerUnsafe, hc as catchDone, hd as toMillis, hf as redact, hi as flattenIterable, hl as succeedContext, hn as decodeUnknownEffect, hr as value$2, hs as promise, hu as empty$11, i as FileType, ic as withTracerEnabled, id as isResult, if as contA, ii as catchTags$1, il as CurrentMemoMap, in as Tuple, io as andThen, ir as CurrentRedactedNames, is as matchCauseEffect, it as getStreamSchemas, iu as nativeTracer, ja as fromInput$2, jc as startsWith, jd as filter$5, jf as constVoid, ji as mergeAll$1, jl as _await, jn as makeFilter, jo as flatMapEager, jr as Literal$2, js as sleep, ju as isArrayNonEmpty, ka as runIn, kc as slice$2, kd as contains$1, kf as constTrue, ki as mapEffect, kn as isSchemaError$1, ko as filterOrFail, kr as Filter, ks as scoped, kt as ArraySchema, ku as head, l as GitHubReadme, la as collect, lc as fromStep, ld as format$2, lf as setStackTraceLimit, li as empty$10, ll as launch, ln as UndefinedOr, lo as asVoid, lr as merge$2, ls as onExit, lt as makeCollectorUnsafe, m as NoteJson, ma as offerAll, mc as toStep, md as seconds, mf as format$1, mi as flatMap$3, ml as succeed$2, mn as decodeTo, mo as catchDefect, mr as make$43, ms as orElseSucceed, mt as SocketOpenError, mu as drop, n as Capture, na as map$5, nc as withParentSpan, nd as fromOption$1, nf as Prototype, ni as FileSystem, nl as prettyErrors, nn as TaggedError$1, no as acquireRelease, nr as fromIterable$2, ns as mapError, nt as isWrapper, nu as externalSpan, o as FxStatus, oa as make$34, oc as addDelay, od as match$3, oi as concat, ol as effect, on as URLFromString, oo as annotateLogs, or as fromInput$1, os as matchEffect, ot as spanAttributes, ou as Error$1, p as NoteId, pa as offer, pd as parts, pf as toJson, pi as filter$6, pl as provideMerge, pn as decodeSync, pr as isRedacted, ps as orDie, pu as dedupeAdjacentWith, q as layerJson$1, qa as ipFromString, qd as orElse$2, qi as takeUntil, ql as fiberEnterUninterruptibleUnsafe, qn as encodeUnknownEffect, qo as log, qr as passthrough$1, qs as updateContext, qt as NonEmptyArray, qu as has$3, r as Extraction, rc as withSpan, rd as isFailure, rf as PipeInspectableProto, ri as catchReason$1, rl as squash, ro as all, rr as get$7, rt as ClientAbort$1, ru as make$39, s as GitHubComment, sa as makeUnsafe$6, sd as succeed, sf as assignProperty, si as decodeText, sl as effectContext, sn as Uint8Array$2, so as as$1, sr as fromRecordUnsafe, ss as never, st as spanName, su as TaggedClass, t as RpcContracts, ta as fromTransform, tc as withLogSpan, td as failVoid, tf as mapInput, ti as Path, tl as makeDieReason, tn as Struct, to as unixPathAddress, tr as has$4, ts as mapEager, tt as exitSchema, tu as Tracer, u as GitHubRepo, ua as end$1, uc as isSchedule, ud as fromInputUnsafe$1, uf as BaseProto, ui as ensuring, ul as merge$3, un as Union, uo as cached, ur as remove$3, us as onExitPrimitive, ut as CloseEvent, uu as appendAll, v as Reader, va as take, vc as camelToSnake, vd as Service, vf as hasProperty, vi as fromEffect, vl as Scope, vn as encodeSync, vo as catchTag, vr as isEmpty$1, vs as provideService, vu as filter$4, wa as getCurrent, wc as match$2, wd as getUnsafe, wf as isTagged, wi as limitBytes, wl as make$35, wn as isInt, wo as die$2, wr as toUint8Array$1, wt as InvalidUrlError, wu as fromIterable$1, x as layer$12, xa as unbounded, xc as isEmpty$2, xd as get$5, xf as isNotNullish, xi as fromQueue, xl as close, xn as fromJsonString, xo as context, xr as fromReadable, xs as repeat, xt as EncodeError, xu as findFirstIndex, y as TikTokPage, ya as takeAll, yc as endsWith, yd as add$1, yf as isIterable, yi as fromIterable, yl as addFinalizer, yn as encodeTo, yo as catchTags, yr as parseHeader, ys as provideServiceEffect, yt as DecodeError, yu as filterMap, z as succeed$5, za as makeRecordUnsafe, zd as getOrUndefined, zi as runCollect, zl as interrupt$1, zn as toJsonSchemaDocument, zo as fromOption, zr as mapOrSame, zs as timeout, zu as of } from "./contracts-CdQiWFv_.mjs";
|
|
2
|
+
import { $ as succeed$5, $a as badArgument, $c as split, $d as make$40, $f as isUndefined, $i as mkString, $l as CurrentLogSpans, $n as toJsonSchemaDocument, $o as flatMap, $r as Suspend, $s as serviceOption, $u as groupBy, A as SignInParams, Aa as collect, Ad as isResult, Af as Prototype, Ai as empty$10, Al as buildWithMemoMap, An as decodeUnknownOption, Ao as as$1, Ar as make$45, As as never, At as fromWebSocket, Au as random$1, Ba as takeAll, Bc as Random$2, Bd as minutes, Bf as NodeInspectSymbol, Bi as fromIterable, Bl as succeedContext, Bn as isMinLength, Bo as catchReason, Br as fromReadable, Bs as provideContext, Bt as TransportError, Bu as empty$11, C as AuthError, Ca as map$4, Cc as withFiberSucceed, Cd as headUnsafe, Cf as some$1, Ci as FileSystem, Cn as UndefinedOr, Co as isUnicast, Cr as get$7, Cs as map$1, Ct as makeCollectorUnsafe, D as OAuthTokenError, Da as make$36, Dc as withTracerEnabled, Dd as fromOption$1, Df as combine$1, Di as concat, Dl as prettyErrors, Dn as decodeSync, Do as andThen, Dr as set$3, Ds as matchCauseEffect, Du as externalSpan, E as OAuthFlow, Ea as pipeTo, Ec as withSpan, Ed as failVoid, Ef as String$3, Ei as catch_$1, El as makeDieReason, En as decodeEffect, Eo as all$1, Er as remove$3, Et as SocketError, Eu as Tracer, F as runMain, Fa as offerAll, Fc as passthrough, Fd as days, Ff as assignProperty, Fi as flatMap$3, Fl as merge$3, Fn as fromJsonString, Fo as catchCause, Fr as fromSetCookie, Fs as option$1, Ft as EncodeError, Fu as appendAll, G as Port, Ga as makeUnsafe$6, Gc as isNonEmpty, Gd as Reference, Gf as hash, Gi as limitBytes, Gl as addFinalizerExit, Gn as makeFilter, Go as contextWith, Gr as make$43, Gs as result$1, Gu as findFirst, H as layer$10, Ha as unbounded, Hc as endsWith, Hd as seconds, Hf as format$1, Hi as fromQueue, Hl as unwrap$3, Hn as isSchema, Ho as catchTags, Hr as toArrayBuffer, Hs as provideServiceEffect, Ht as Any, Hu as every, Ia as offerUnsafe, Ic as spaced, Id as format$2, If as getStackTraceLimit, Ii as flattenIterable, Il as mergeAll, In as is$4, Ir as isEmpty$1, Is as orDie, It as HttpClientError, Iu as contains$1, J as String$2, Ja as interrupt$2, Jc as padStart, Jf as isNotNull, Ji as mapArray, Jl as forkUnsafe$1, Jn as optionalKey, Jo as ensuring$1, Jr as Filter, Js as runFork, Jt as DateTimeUtcFromString, Ju as flatMap$2, K as Record, Ka as await_, Kc as length, Kd as Service, Kf as hasProperty, Ki as map$2, Kl as close, Kn as mutable, Kr as ChildProcessSpawner, Ks as retry, Kt as Class$1, Ku as findFirstIndex, La as shutdown, Lc as toStep, Ld as fromInputUnsafe$1, Lf as setStackTraceLimit, Li as fromArray, Ll as provide$1, Ln as isGreaterThanOrEqualTo, Lo as catchDefect, Lr as parseHeader, Ls as orElseSucceed, Lu as dedupe, Ma as failCause$2, Mc as fromStep, Md as match$3, Mf as contA, Mi as fail$2, Ml as effectContext, Mn as encodeSync, Mo as asVoid, Mr as stringOrRedacted, Ms as onExit, Mu as TaggedClass, N as layer$12, Na as make$38, Nc as isSchedule, Nd as succeed, Nf as contE, Ni as failCause$3, Nl as effectDiscard, Nn as encodeTo, No as cached, Nr as empty$9, Ns as onExitPrimitive, Nt as DecodeError, Nu as TaggedError, O as OAuthTokenResponse, Oa as makeUnsafe$7, Oc as zipWith, Od as getSuccess, Of as flip, Oi as decodeText, Ol as squash, On as decodeTo, Oo as annotateCurrentSpan, Or as setAll, Os as matchCauseEffectEager, Ot as SocketOpenError, Ou as make$42, P as make$41, Pa as offer, Pd as try_$1, Pi as filter$6, Pl as launch, Pn as encodeUnknownEffect$1, Po as callback, Pr as expireCookieUnsafe$1, Ps as onInterrupt, Pt as EmptyBodyError, Q as schema, Qa as runIn, Qc as slice$2, Qd as getUnsafe, Qf as isTagged, Qi as mergeAll$1, Ql as CurrentLogAnnotations, Qn as toEncoded$1, Qo as filterOrFail, Qr as PropertySignature, Qs as scoped, Qt as Exit$1, Qu as getUnsafe$1, R as layer$11, Rc as catchDone, Rd as max$1, Rf as BaseProto, Rl as provideMerge, Rn as isInt, Rr as setUnsafe$2, Rs as promise, Rt as InvalidUrlError, Ru as dedupeAdjacentWith, S as RpcAuth, Sa as fromTransform, Sc as withFiber, Sd as empty$12, Sf as orElseSome, Si as Path, Sl as hasInterruptsOnly, Sn as Uint8ArrayFromBase64, So as isPrivate, Sr as fromRecordUnsafe, Ss as makeSpanScoped, St as Collector, Su as reportCauseUnsafe, T as GitHubUser, Tc as withParentSpan, Td as fail, Tf as Number$1, Ti as catchTags$1, Tl as isTimeoutError, Tn as Unknown, To as acquireRelease, Tr as merge$2, Ts as mapError, Tu as ParentSpan, U as Crypto, Ua as make$35, Uc as includes, Ud as toMillis, Uf as redact, Ui as fromReadableStream, Ul as Scope, Un as isSchemaError$1, Uo as catch_, Ur as toUint8Array$1, Us as raceFirst, Ut as ArraySchema, Uu as filter$5, Va as publishUnsafe, Vc as camelToSnake, Vd as parts, Vf as toJson, Vi as fromPubSub, Vl as sync$1, Vn as isPattern, Vo as catchTag, Vr as pipeThroughDuplex, Vs as provideService, Vt as isHttpClientError, Vu as ensure, W as Array$1, Wa as set$2, Wc as isEmpty$2, Wd as zero$1, Wf as equals, Wi as groupedWithin, Wl as addFinalizer, Wn as make$44, Wo as context, Wr as fromWritable, Ws as repeat, Wt as Boolean$2, Wu as filterMap, X as all, Xa as interruptAllAs, Xc as replace$1, Xd as getOrUndefined$1, Xf as isNotUndefined, Xi as mapEffect, Xl as makeUnsafe$3, Xn as toCodecJson, Xo as fail$1, Xr as Literal$2, Xs as runSync, Xt as Duration, Xu as get$8, Y as URL$1, Ya as interruptAll, Yc as repeat$1, Yd as get$6, Yf as isNotNullish, Yi as mapArrayEffect, Yl as make$37, Yn as tag, Yo as exit, Yr as FilterGroup, Ys as runForkWith, Yt as Defect, Yu as fromIterable$1, Z as option, Za as interruptAs, Zc as replaceAll, Zd as getOrUndefinedUnsafe, Zf as isObject, Zi as mapError$1, Zl as provide$2, Zo as failCause, Zr as Objects, Zs as scope, Zt as Error$2, Zu as getSomes, _ as Organization, _a as toReadableStreamEffect, _c as updateService, _d as takeRight, _f as liftThrowable, _i as encode$1, _l as filterInterruptors, _o as ipFromStringUnsafe, _r as fromIterable$3, _s as logDebug, _t as ClientAbort$1, _u as fiberEnterInterruptibleUnsafe, a as FxConversation, aa as run$3, ac as tap$1, ad as join$1, af as filter$4, ai as null_, al as parse$10, an as MutableJson, ao as Dns, ap as constVoid, ar as omit, as as forkChild, at as RpcSerialization, au as isDeferred, b as AUTH_URL, ba as last$2, bc as when$2, bd as map$6, bf as none, bi as toEpochMillis, bl as hasDies, bn as URLFromString, bo as isLinkLocal, br as empty$8, bs as logInfo, bt as spanAttributes, bu as makeSpanUnsafe, c as GitHubIssue, ca as runForEachArray, cc as timeout, cd as map$3, cf as flatten, ci as resolveDescription, cl as currentTimeMillis, cn as Null, co as makeRecordUnsafe, cp as flow, cr as CurrentRedactedNames$1, cs as fromOption, ct as layerSchemaBinary, cu as fail$3, d as ImageType, da as scan, dc as transposeOption, dd as prepend$2, df as getOrElse, di as toEncoded, dl as StackTrace, dn as Record$1, do as NetAddressError, dp as pipeArguments, dr as redactUrl, ds as ignore$1, dt as constEof, du as isExit, ea as mkUint8Array, ec as sleep, ed as head, ef as makeUnsafe$4, ei as Union$1, el as startsWith, en as Finite, eo as fromInput$2, ep as or$1, er as toType, es as flatMapEager, et as unwrap$4, f as Note, fa as succeed$3, fc as tryPromise, fd as reduce, ff as getOrNull, fi as passthrough$1, fl as annotate, fn as Redacted$1, fo as formatInet, fr as setAll$1, fu as isFailure$1, g as OEmbed, ga as toReadableStream, gc as updateContext, gd as take$1, gf as liftPredicate, gi as encode, gl as fail$4, gn as TaggedError$1, go as ipFromString, gr as has$3, gs as log, gt as isWrapper, gu as effectIsExit, h as NotesError, ha as tap$2, hc as uninterruptibleMask, hd as sort, hf as isSome, hi as decode$3, hn as Struct, ho as inetAddressFromIpString, hr as fromIterable$2, hs as isEffect, ht as exitSchema, i as FileType, ia as provideService$1, ic as sync, id as isReadonlyArrayNonEmpty, if as exists, ii as mapOrSame, il as max$2, in as Literals, io as zero, ip as constUndefined, ir as isSchemaError, is as forever$1, iu as into, j as Verification, ja as end$1, jc as forever, jd as isSuccess, jf as PipeInspectableProto, ji as ensuring, jl as effect, jn as encodeEffect, jo as asSome, jr as value$2, js as onError, ju as Error$1, k as Session, kc as addDelay, kd as isFailure, kf as mapInput, ki as die$3, kl as CurrentMemoMap, kn as decodeUnknownEffect, ko as annotateLogs, kr as isRedacted, ks as matchEffect, ku as nativeTracer, l as GitHubReadme, lc as timeoutOption, lf as fromNullishOr, li as resolveIdentifier, ln as NullOr, lo as nameServerFromInput, lp as identity, lr as empty$7, ls as fromResult, lt as RequestId, lu as failCause$1, m as NoteJson, ma as takeUntil, mc as uninterruptible, md as some$2, mf as isNone, mi as transformOptional, ml as die$1, mn as StringFromUriComponent, mo as formatUrlUnsafe, mr as unwrap$1, ms as interruptible, mt as ServerClient, mu as succeed$4, n as Capture, na as orDie$1, nc as succeedNone, nd as isArrayNonEmpty, nf as all$2, ni as isNever, nl as trim, nn as Json, no as gibibytes, np as constFalse, nr as withDecodingDefault, ns as fnUntraced, nu as _await, o as FxStatus, oa as runCollect, oc as tapCause, od as last$1, of as flatMap$1, oi as optionalKey$1, on as Never, oo as DnsError, op as constant, or as getReferenceKey, os as forkIn, ot as json$1, ou as makeUnsafe$5, p as NoteId, pa as suspend$1, pc as try_, pd as reverse, pf as getOrUndefined, pi as transform$1, pl as combine, pn as String$1, po as formatIp, pr as toString$2, ps as interrupt, pt as constPong, pu as isSuccess$1, q as Redacted, qa as getCurrent, qc as match$2, qd as add$1, qf as isIterable, qi as mapAccum, ql as closeUnsafe, qn as optional$1, qo as die$2, qr as Arrays, qt as DateTimeUtc, r as Extraction, ra as pipeThroughChannel, rc as suspend, rd as isReadonlyArrayEmpty, rf as contains$2, ri as isOptional, rl as trimEnd, rn as Literal$1, ro as mebibytes, rp as constTrue, rr as withDecodingDefaultKey, rs as forEach, rt as withRun, ru as doneUnsafe, s as GitHubComment, sa as runForEach, sc as tapError$1, sd as lastNonEmpty, sf as flatMapNullishOr, si as replaceChecks, sl as Clock, sn as NonEmptyArray, so as make$39, sp as dual, sr as encodeUnknownEffect, ss as forkScoped, st as layerJson$1, su as die, t as RpcContracts, ta as onEnd, tc as succeed$1, td as headNonEmpty, tf as merge$1, ti as decodeTo$1, tl as toLowerCase, tn as Int, to as fromInputUnsafe, tp as compose$1, tr as withConstructorDefault, ts as fn$1, tt as withDefault, tu as TracerTimingEnabled, u as GitHubRepo, ua as runLast, uc as timeoutOrElse, ud as of, uf as fromUndefinedOr, ui as string, ul as IllegalArgumentError, un as Number$2, uo as domainNameFromStringUnsafe, up as pipe, ur as fromInput, us as gen, ut as ResponseDefectEncoded, uu as interrupt$1, v as Reader, vc as useSpan, vd as has$4, vf as map$5, vi as formatIso, vn as Tuple, vo as ipv4ToOctets, vr as get$9, vt as getStreamSchemas, vu as fiberEnterUninterruptibleUnsafe, w as CallbackParams, wc as withLogSpan, wd as make$46, wf as toArray$1, wi as catchReason$1, wl as isNoSuchElementError, wn as Union, wo as unixPathAddress, wr as isRedactedName, ws as mapEager, wt as CloseEvent, wu as DisablePropagation, x as CurrentUser, xc as whileLoop, xd as toEntries, xf as orElse$2, xi as defaultFormatter, xl as hasInterrupts, xn as Uint8Array$2, xo as isLoopback, xr as fromInput$1, xs as logWarning, xt as spanName, xu as onExitUnsafe, y as TikTokPage, ya as unwrap$2, yc as void_, yd as keys, yf as match$1, yi as now, yl as fromReasons, yn as URL$2, yo as isInetAddressV6, yr as CurrentRedactedNames, ys as logFatal, yt as isStreamSchema, yu as forkUnsafe, za as take, zd as millis, zf as Class, zi as fromEffect, zl as succeed$2, zn as isMaxLength, zo as catchIf, zr as toSetCookieHeaders, zs as provide$3, zt as StatusCodeError, zu as drop } from "./contracts-C1Rqhg6U.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { Duplex, Readable, pipeline } from "node:stream";
|
|
5
5
|
import * as Http from "node:http";
|
|
@@ -210,7 +210,7 @@ const empty$6 = () => {
|
|
|
210
210
|
* @category getters
|
|
211
211
|
* @since 2.0.0
|
|
212
212
|
*/
|
|
213
|
-
const get$
|
|
213
|
+
const get$5 = /*#__PURE__*/ dual(2, (self, key) => {
|
|
214
214
|
if (self.backing.has(key)) return some$1(self.backing.get(key));
|
|
215
215
|
else if (isSimpleKey(key)) return none();
|
|
216
216
|
const hash$2 = hash(key);
|
|
@@ -288,7 +288,7 @@ const getFromBucket = (self, bucket, key) => {
|
|
|
288
288
|
* @category predicates
|
|
289
289
|
* @since 2.0.0
|
|
290
290
|
*/
|
|
291
|
-
const has$1 = /*#__PURE__*/ dual(2, (self, key) => isSome(get$
|
|
291
|
+
const has$1 = /*#__PURE__*/ dual(2, (self, key) => isSome(get$5(self, key)));
|
|
292
292
|
/**
|
|
293
293
|
* Sets a key-value pair in the MutableHashMap, mutating the map in place.
|
|
294
294
|
* If the key already exists, its value is updated.
|
|
@@ -329,7 +329,7 @@ const has$1 = /*#__PURE__*/ dual(2, (self, key) => isSome(get$4(self, key)));
|
|
|
329
329
|
* @category mutations
|
|
330
330
|
* @since 2.0.0
|
|
331
331
|
*/
|
|
332
|
-
const set = /*#__PURE__*/ dual(3, (self, key, value) => {
|
|
332
|
+
const set$1 = /*#__PURE__*/ dual(3, (self, key, value) => {
|
|
333
333
|
if (self.backing.has(key) || isSimpleKey(key)) {
|
|
334
334
|
self.backing.set(key, value);
|
|
335
335
|
return self;
|
|
@@ -414,6 +414,151 @@ const remove$2 = /*#__PURE__*/ dual(2, (self, key_) => {
|
|
|
414
414
|
return self;
|
|
415
415
|
});
|
|
416
416
|
//#endregion
|
|
417
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Ref.js
|
|
418
|
+
/**
|
|
419
|
+
* Stores fiber-safe mutable state inside Effect programs.
|
|
420
|
+
*
|
|
421
|
+
* A `Ref<A>` holds one value and exposes reads, writes, and atomic
|
|
422
|
+
* transformations as effects, so state changes compose with Effect's
|
|
423
|
+
* concurrency model. This module includes constructors, safe and unsafe reads,
|
|
424
|
+
* set and get-and-set helpers, update and modify helpers, and conditional
|
|
425
|
+
* update variants that leave the value unchanged when an `Option.none` result
|
|
426
|
+
* is returned.
|
|
427
|
+
*
|
|
428
|
+
* @stability stable
|
|
429
|
+
* @since 2.0.0
|
|
430
|
+
*/
|
|
431
|
+
const RefProto = {
|
|
432
|
+
["~effect/Ref"]: { _A: identity },
|
|
433
|
+
...PipeInspectableProto,
|
|
434
|
+
toJSON() {
|
|
435
|
+
return {
|
|
436
|
+
_id: "Ref",
|
|
437
|
+
ref: this.ref
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* Creates a new Ref with the specified initial value (unsafe version).
|
|
443
|
+
*
|
|
444
|
+
* **When to use**
|
|
445
|
+
*
|
|
446
|
+
* Use when you need immediate synchronous construction and can guarantee
|
|
447
|
+
* that creating the `Ref` outside of `Effect` is safe.
|
|
448
|
+
*
|
|
449
|
+
* **Gotchas**
|
|
450
|
+
*
|
|
451
|
+
* Prefer `Ref.make` for Effect-wrapped creation in Effect programs.
|
|
452
|
+
*
|
|
453
|
+
* **Example** (Creating a ref unsafely)
|
|
454
|
+
*
|
|
455
|
+
* ```ts import.meta.vitest
|
|
456
|
+
* import { Ref } from "effect"
|
|
457
|
+
*
|
|
458
|
+
* const counter = Ref.makeUnsafe(0)
|
|
459
|
+
* Ref.getUnsafe(counter) // => 0
|
|
460
|
+
* ```
|
|
461
|
+
*
|
|
462
|
+
* @stability stable
|
|
463
|
+
* @category constructors
|
|
464
|
+
* @since 4.0.0
|
|
465
|
+
*/
|
|
466
|
+
const makeUnsafe$2 = (value) => {
|
|
467
|
+
const self = Object.create(RefProto);
|
|
468
|
+
self.ref = make$35(value);
|
|
469
|
+
return self;
|
|
470
|
+
};
|
|
471
|
+
/**
|
|
472
|
+
* Creates a new Ref with the specified initial value.
|
|
473
|
+
*
|
|
474
|
+
* **When to use**
|
|
475
|
+
*
|
|
476
|
+
* Use to create a `Ref` for shared mutable state inside an Effect program.
|
|
477
|
+
*
|
|
478
|
+
* **Example** (Creating a ref)
|
|
479
|
+
*
|
|
480
|
+
* ```ts import.meta.vitest
|
|
481
|
+
* import { Effect, Ref } from "effect"
|
|
482
|
+
*
|
|
483
|
+
* const program = Effect.gen(function*() {
|
|
484
|
+
* const ref = yield* Ref.make(42)
|
|
485
|
+
* return yield* Ref.get(ref)
|
|
486
|
+
* })
|
|
487
|
+
*
|
|
488
|
+
* await Effect.runPromise(program) // => 42
|
|
489
|
+
* ```
|
|
490
|
+
*
|
|
491
|
+
* @see {@link makeUnsafe} for synchronous construction outside Effect code
|
|
492
|
+
*
|
|
493
|
+
* @stability stable
|
|
494
|
+
* @category constructors
|
|
495
|
+
* @since 2.0.0
|
|
496
|
+
*/
|
|
497
|
+
const make$34 = (value) => sync(() => makeUnsafe$2(value));
|
|
498
|
+
/**
|
|
499
|
+
* Gets the current value of the Ref.
|
|
500
|
+
*
|
|
501
|
+
* **When to use**
|
|
502
|
+
*
|
|
503
|
+
* Use to read the current `Ref` value without changing it.
|
|
504
|
+
*
|
|
505
|
+
* **Example** (Getting the current value)
|
|
506
|
+
*
|
|
507
|
+
* ```ts import.meta.vitest
|
|
508
|
+
* import { Effect, Ref } from "effect"
|
|
509
|
+
*
|
|
510
|
+
* const program = Effect.gen(function*() {
|
|
511
|
+
* const ref = yield* Ref.make(42)
|
|
512
|
+
* return yield* Ref.get(ref)
|
|
513
|
+
* })
|
|
514
|
+
*
|
|
515
|
+
* await Effect.runPromise(program) // => 42
|
|
516
|
+
* ```
|
|
517
|
+
*
|
|
518
|
+
* @see {@link set} for replacing the current value
|
|
519
|
+
*
|
|
520
|
+
* @stability stable
|
|
521
|
+
* @category getters
|
|
522
|
+
* @since 2.0.0
|
|
523
|
+
*/
|
|
524
|
+
const get$4 = (self) => sync(() => self.ref.current);
|
|
525
|
+
/**
|
|
526
|
+
* Sets the value of the Ref to the specified value.
|
|
527
|
+
*
|
|
528
|
+
* **When to use**
|
|
529
|
+
*
|
|
530
|
+
* Use to replace the current `Ref` value with a known value.
|
|
531
|
+
*
|
|
532
|
+
* **Example** (Setting a value)
|
|
533
|
+
*
|
|
534
|
+
* ```ts import.meta.vitest
|
|
535
|
+
* import { Effect, Ref } from "effect"
|
|
536
|
+
*
|
|
537
|
+
* const program = Effect.gen(function*() {
|
|
538
|
+
* const ref = yield* Ref.make(0)
|
|
539
|
+
* yield* Ref.set(ref, 42)
|
|
540
|
+
* return yield* Ref.get(ref)
|
|
541
|
+
* })
|
|
542
|
+
*
|
|
543
|
+
* const program2 = Effect.gen(function*() {
|
|
544
|
+
* const ref = yield* Ref.make(0)
|
|
545
|
+
* yield* Ref.set(ref, 100)
|
|
546
|
+
* return yield* Ref.get(ref)
|
|
547
|
+
* })
|
|
548
|
+
*
|
|
549
|
+
* await Effect.runPromise(program) // => 42
|
|
550
|
+
* await Effect.runPromise(program2) // => 100
|
|
551
|
+
* ```
|
|
552
|
+
*
|
|
553
|
+
* @see {@link getAndSet} for setting while returning the previous value
|
|
554
|
+
* @see {@link setAndGet} for setting while returning the new value
|
|
555
|
+
*
|
|
556
|
+
* @stability stable
|
|
557
|
+
* @category mutations
|
|
558
|
+
* @since 2.0.0
|
|
559
|
+
*/
|
|
560
|
+
const set = /*#__PURE__*/ dual(2, (self, value) => sync(() => set$2(self.ref, value)));
|
|
561
|
+
//#endregion
|
|
417
562
|
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpBody.js
|
|
418
563
|
const TypeId$18 = "~effect/http/HttpBody";
|
|
419
564
|
const HttpBodyErrorTypeId = "~effect/http/HttpBody/HttpBodyError";
|
|
@@ -631,6 +776,14 @@ const jsonSchema = (schema, options) => {
|
|
|
631
776
|
})), flatMap((body) => json(body, contentType)));
|
|
632
777
|
};
|
|
633
778
|
/**
|
|
779
|
+
* Creates an `application/x-www-form-urlencoded` HTTP body from `UrlParams`.
|
|
780
|
+
*
|
|
781
|
+
* @stability unstable
|
|
782
|
+
* @category constructors
|
|
783
|
+
* @since 4.0.0
|
|
784
|
+
*/
|
|
785
|
+
const urlParams = (urlParams, contentType) => text$3(toString$2(fromInput(urlParams)), contentType ?? "application/x-www-form-urlencoded");
|
|
786
|
+
/**
|
|
634
787
|
* HTTP body variant backed by Web `FormData`.
|
|
635
788
|
*
|
|
636
789
|
* **Details**
|
|
@@ -763,12 +916,23 @@ const compressBody$1 = (body, algorithm, options) => {
|
|
|
763
916
|
*/
|
|
764
917
|
const updateHeaders = (headers, body) => {
|
|
765
918
|
if (body._tag === "Empty" || body._tag === "FormData") return remove$3(remove$3(headers, "content-type"), "content-length");
|
|
766
|
-
headers = body.contentType === void 0 ? remove$3(headers, "content-type") : set$
|
|
767
|
-
return body.contentLength === void 0 ? remove$3(headers, "content-length") : set$
|
|
919
|
+
headers = body.contentType === void 0 ? remove$3(headers, "content-type") : set$3(headers, "content-type", body.contentType);
|
|
920
|
+
return body.contentLength === void 0 ? remove$3(headers, "content-length") : set$3(headers, "content-length", body.contentLength.toString());
|
|
768
921
|
};
|
|
769
922
|
//#endregion
|
|
770
923
|
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/Url.js
|
|
771
924
|
/**
|
|
925
|
+
* Parses and edits platform `URL` values.
|
|
926
|
+
*
|
|
927
|
+
* The HTTP modules use the standard `URL` object as their URL representation.
|
|
928
|
+
* This module adds safe parsing and helpers that return updated copies when
|
|
929
|
+
* changing credentials, host, path, protocol, query, or hash parts. Query
|
|
930
|
+
* strings can also be read or updated through `UrlParams`.
|
|
931
|
+
*
|
|
932
|
+
* @stability unstable
|
|
933
|
+
* @since 4.0.0
|
|
934
|
+
*/
|
|
935
|
+
/**
|
|
772
936
|
* Error returned when constructing a `URL` fails.
|
|
773
937
|
*
|
|
774
938
|
* @stability unstable
|
|
@@ -802,6 +966,51 @@ const make$33 = (url, params, hash) => try_$1({
|
|
|
802
966
|
const baseUrl = () => {
|
|
803
967
|
if ("location" in globalThis && globalThis.location !== void 0 && globalThis.location.origin !== void 0 && globalThis.location.pathname !== void 0) return location.origin + location.pathname;
|
|
804
968
|
};
|
|
969
|
+
/**
|
|
970
|
+
* Parses a URL string safely into a `URL` object, returning a `Result` type for
|
|
971
|
+
* error handling.
|
|
972
|
+
*
|
|
973
|
+
* **Details**
|
|
974
|
+
*
|
|
975
|
+
* This function converts a string into a `URL` object, enabling safe URL
|
|
976
|
+
* parsing with built-in error handling. If the string is invalid or fails to
|
|
977
|
+
* parse, this function does not throw an error; instead, it wraps the error in
|
|
978
|
+
* a `IllegalArgumentError` and returns it as the `Failure` value of an
|
|
979
|
+
* `Result`. The `Success` value contains the successfully parsed `URL`.
|
|
980
|
+
*
|
|
981
|
+
* An optional `base` parameter can be provided to resolve relative URLs. If
|
|
982
|
+
* specified, the function interprets the input `url` as relative to this
|
|
983
|
+
* `base`. This is especially useful when dealing with URLs that might not be
|
|
984
|
+
* fully qualified.
|
|
985
|
+
*
|
|
986
|
+
* **Example** (Parsing absolute and relative URLs)
|
|
987
|
+
*
|
|
988
|
+
* ```ts import.meta.vitest
|
|
989
|
+
* import { Result } from "effect"
|
|
990
|
+
* import { Url } from "effect/http"
|
|
991
|
+
*
|
|
992
|
+
* // Parse an absolute URL
|
|
993
|
+
* //
|
|
994
|
+
* // ┌─── Result<URL, IllegalArgumentError>
|
|
995
|
+
* // ▼
|
|
996
|
+
* const parsed = Url.fromString("https://example.com/path")
|
|
997
|
+
*
|
|
998
|
+
* Result.map(parsed, (url) => url.toString()) // => Result.succeed("https://example.com/path")
|
|
999
|
+
*
|
|
1000
|
+
* // Parse a relative URL with a base
|
|
1001
|
+
* const relativeParsed = Url.fromString("/relative-path", "https://example.com")
|
|
1002
|
+
*
|
|
1003
|
+
* Result.map(relativeParsed, (url) => url.toString()) // => Result.succeed("https://example.com/relative-path")
|
|
1004
|
+
* ```
|
|
1005
|
+
*
|
|
1006
|
+
* @stability unstable
|
|
1007
|
+
* @category constructors
|
|
1008
|
+
* @since 4.0.0
|
|
1009
|
+
*/
|
|
1010
|
+
const fromString = (url, base) => try_$1({
|
|
1011
|
+
try: () => new URL(url, base),
|
|
1012
|
+
catch: () => new IllegalArgumentError(`Invalid URL: "${url}"${base !== void 0 ? ` with base "${base}"` : ""}`)
|
|
1013
|
+
});
|
|
805
1014
|
//#endregion
|
|
806
1015
|
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpClientRequest.js
|
|
807
1016
|
const TypeId$17 = "~effect/http/HttpClientRequest";
|
|
@@ -919,7 +1128,7 @@ const setMethod = /*#__PURE__*/ dual(2, (self, method) => makeWith$1(method, sel
|
|
|
919
1128
|
* @category combinators
|
|
920
1129
|
* @since 4.0.0
|
|
921
1130
|
*/
|
|
922
|
-
const setHeader$1 = /*#__PURE__*/ dual(3, (self, key, value) => makeWith$1(self.method, self.url, self.urlParams, self.hash, set$
|
|
1131
|
+
const setHeader$1 = /*#__PURE__*/ dual(3, (self, key, value) => makeWith$1(self.method, self.url, self.urlParams, self.hash, set$3(self.headers, key, value), self.body));
|
|
923
1132
|
/**
|
|
924
1133
|
* Sets multiple request headers from an input collection, replacing existing values with matching names.
|
|
925
1134
|
*
|
|
@@ -929,6 +1138,14 @@ const setHeader$1 = /*#__PURE__*/ dual(3, (self, key, value) => makeWith$1(self.
|
|
|
929
1138
|
*/
|
|
930
1139
|
const setHeaders$1 = /*#__PURE__*/ dual(2, (self, input) => makeWith$1(self.method, self.url, self.urlParams, self.hash, setAll(self.headers, input), self.body));
|
|
931
1140
|
/**
|
|
1141
|
+
* Sets the `Authorization` header using a bearer token.
|
|
1142
|
+
*
|
|
1143
|
+
* @stability unstable
|
|
1144
|
+
* @category combinators
|
|
1145
|
+
* @since 4.0.0
|
|
1146
|
+
*/
|
|
1147
|
+
const bearerToken = /*#__PURE__*/ dual(2, (self, token) => setHeader$1(self, "Authorization", `Bearer ${stringOrRedacted(token)}`));
|
|
1148
|
+
/**
|
|
932
1149
|
* Sets the `Accept` header to the specified media type.
|
|
933
1150
|
*
|
|
934
1151
|
* @stability unstable
|
|
@@ -1055,6 +1272,14 @@ const compressBody = /*#__PURE__*/ dual((args) => isHttpClientRequest(args[0]),
|
|
|
1055
1272
|
*/
|
|
1056
1273
|
const bodyJsonUnsafe = /*#__PURE__*/ dual(2, (self, body) => setBody$1(self, jsonUnsafe(body)));
|
|
1057
1274
|
/**
|
|
1275
|
+
* Sets an `application/x-www-form-urlencoded` request body from URL parameter input.
|
|
1276
|
+
*
|
|
1277
|
+
* @stability unstable
|
|
1278
|
+
* @category combinators
|
|
1279
|
+
* @since 4.0.0
|
|
1280
|
+
*/
|
|
1281
|
+
const bodyUrlParams = /*#__PURE__*/ dual(2, (self, input) => setBody$1(self, urlParams(fromInput(input))));
|
|
1282
|
+
/**
|
|
1058
1283
|
* Sets a `FormData` request body.
|
|
1059
1284
|
*
|
|
1060
1285
|
* @stability unstable
|
|
@@ -2719,6 +2944,27 @@ const empty$3 = (options) => makeResponse$1({
|
|
|
2719
2944
|
cookies: options?.cookies
|
|
2720
2945
|
});
|
|
2721
2946
|
/**
|
|
2947
|
+
* Creates a redirect response with a `Location` header.
|
|
2948
|
+
*
|
|
2949
|
+
* **Details**
|
|
2950
|
+
*
|
|
2951
|
+
* The default status is `302`; custom headers are merged with the generated
|
|
2952
|
+
* `Location` header.
|
|
2953
|
+
*
|
|
2954
|
+
* @stability unstable
|
|
2955
|
+
* @category constructors
|
|
2956
|
+
* @since 4.0.0
|
|
2957
|
+
*/
|
|
2958
|
+
const redirect = (location, options) => {
|
|
2959
|
+
const headers = fromRecordUnsafe({ location: location.toString() });
|
|
2960
|
+
return makeResponse$1({
|
|
2961
|
+
status: options?.status ?? 302,
|
|
2962
|
+
statusText: options?.statusText,
|
|
2963
|
+
headers: options?.headers ? merge$2(headers, fromInput$1(options.headers)) : headers,
|
|
2964
|
+
cookies: options?.cookies ?? empty$9
|
|
2965
|
+
});
|
|
2966
|
+
};
|
|
2967
|
+
/**
|
|
2722
2968
|
* Creates an HTTP response whose body is a `Uint8Array`.
|
|
2723
2969
|
*
|
|
2724
2970
|
* @stability unstable
|
|
@@ -2834,7 +3080,7 @@ const stream$1 = (body, options) => {
|
|
|
2834
3080
|
* @category combinators
|
|
2835
3081
|
* @since 4.0.0
|
|
2836
3082
|
*/
|
|
2837
|
-
const setHeader = /*#__PURE__*/ dual(3, (self, key, value) => makeResponse$1(self, set$
|
|
3083
|
+
const setHeader = /*#__PURE__*/ dual(3, (self, key, value) => makeResponse$1(self, set$3(self.headers, key, value)));
|
|
2838
3084
|
/**
|
|
2839
3085
|
* Returns a response with the specified header removed.
|
|
2840
3086
|
*
|
|
@@ -2855,6 +3101,40 @@ const removeHeader = /*#__PURE__*/ dual(2, (self, key) => makeResponse$1({
|
|
|
2855
3101
|
*/
|
|
2856
3102
|
const setHeaders = /*#__PURE__*/ dual(2, (self, input) => makeResponse$1(self, setAll(self.headers, input)));
|
|
2857
3103
|
/**
|
|
3104
|
+
* Sets a cookie on an `HttpServerResponse`, throwing if the cookie cannot be
|
|
3105
|
+
* encoded.
|
|
3106
|
+
*
|
|
3107
|
+
* **When to use**
|
|
3108
|
+
*
|
|
3109
|
+
* Use when you need to set one trusted cookie and want encoding failures to
|
|
3110
|
+
* throw instead of being represented as `CookiesError` failures.
|
|
3111
|
+
*
|
|
3112
|
+
* @stability unstable
|
|
3113
|
+
* @category combinators
|
|
3114
|
+
* @since 4.0.0
|
|
3115
|
+
*/
|
|
3116
|
+
const setCookieUnsafe = /*#__PURE__*/ dual((args) => isHttpServerResponse(args[0]), (self, name, value, options) => makeResponse$1({
|
|
3117
|
+
...self,
|
|
3118
|
+
cookies: setUnsafe$2(self.cookies, name, value, options)
|
|
3119
|
+
}));
|
|
3120
|
+
/**
|
|
3121
|
+
* Sets an expired cookie on an `HttpServerResponse`, throwing if the expiration cookie
|
|
3122
|
+
* cannot be encoded.
|
|
3123
|
+
*
|
|
3124
|
+
* **When to use**
|
|
3125
|
+
*
|
|
3126
|
+
* Use when you need to expire one trusted cookie and want encoding failures to
|
|
3127
|
+
* throw instead of being represented as `CookiesError` failures.
|
|
3128
|
+
*
|
|
3129
|
+
* @stability unstable
|
|
3130
|
+
* @category combinators
|
|
3131
|
+
* @since 4.0.0
|
|
3132
|
+
*/
|
|
3133
|
+
const expireCookieUnsafe = /*#__PURE__*/ dual((args) => isHttpServerResponse(args[0]), (self, name, options) => makeResponse$1({
|
|
3134
|
+
...self,
|
|
3135
|
+
cookies: expireCookieUnsafe$1(self.cookies, name, options)
|
|
3136
|
+
}));
|
|
3137
|
+
/**
|
|
2858
3138
|
* Replaces the body of an `HttpServerResponse`.
|
|
2859
3139
|
*
|
|
2860
3140
|
* **Details**
|
|
@@ -3521,7 +3801,7 @@ const make$28 = /*#__PURE__*/ fnUntraced(function* (impl) {
|
|
|
3521
3801
|
const limit = bytesToRead === void 0 ? void 0 : offset + contentLength;
|
|
3522
3802
|
const start = yield* fileResponseNumber(offset, "offset");
|
|
3523
3803
|
const end = limit === void 0 ? void 0 : yield* fileResponseNumber(limit, "end");
|
|
3524
|
-
const headers = set$
|
|
3804
|
+
const headers = set$3(optionHeaders(options), "etag", toString$1(etag));
|
|
3525
3805
|
if (isSome(info.mtime)) headers["last-modified"] = info.mtime.value.toUTCString();
|
|
3526
3806
|
return impl.fileResponse(path, options?.status ?? 200, options?.statusText, headers, start, end, contentLength);
|
|
3527
3807
|
}),
|
|
@@ -3538,7 +3818,7 @@ const make$28 = /*#__PURE__*/ fnUntraced(function* (impl) {
|
|
|
3538
3818
|
});
|
|
3539
3819
|
const optionHeaders = (options) => {
|
|
3540
3820
|
const headers = options?.headers ? fromInput$1(options.headers) : empty$8;
|
|
3541
|
-
return options?.contentType ? set$
|
|
3821
|
+
return options?.contentType ? set$3(headers, "content-type", options.contentType) : headers;
|
|
3542
3822
|
};
|
|
3543
3823
|
const fileResponseSize = (input, field) => {
|
|
3544
3824
|
const size = fromInput$2(input);
|
|
@@ -4594,7 +4874,7 @@ const isMultipartError = (u) => hasProperty(u, MultipartErrorTypeId);
|
|
|
4594
4874
|
* @since 4.0.0
|
|
4595
4875
|
*/
|
|
4596
4876
|
const makeConfig = (headers) => withFiber((fiber) => {
|
|
4597
|
-
const mimeTypes = get$
|
|
4877
|
+
const mimeTypes = get$6(fiber.context, FieldMimeTypes);
|
|
4598
4878
|
return succeed$1({
|
|
4599
4879
|
headers,
|
|
4600
4880
|
maxParts: fiber.getRef(MaxParts),
|
|
@@ -4782,6 +5062,17 @@ const HttpServerRequest = /*#__PURE__*/ Service("effect/http/HttpServerRequest")
|
|
|
4782
5062
|
*/
|
|
4783
5063
|
var ParsedSearchParams = class extends (/*#__PURE__*/ Service()("effect/http/ParsedSearchParams")) {};
|
|
4784
5064
|
/**
|
|
5065
|
+
* Decodes a schema from the parsed search parameters of the current request.
|
|
5066
|
+
*
|
|
5067
|
+
* @stability unstable
|
|
5068
|
+
* @category schemas
|
|
5069
|
+
* @since 4.0.0
|
|
5070
|
+
*/
|
|
5071
|
+
const schemaSearchParams = (schema, options) => {
|
|
5072
|
+
const parse = decodeUnknownEffect(schema);
|
|
5073
|
+
return flatMap(ParsedSearchParams, (params) => parse(params, options));
|
|
5074
|
+
};
|
|
5075
|
+
/**
|
|
4785
5076
|
* Reads the current request body as JSON and decodes it with the supplied schema.
|
|
4786
5077
|
*
|
|
4787
5078
|
* **Details**
|
|
@@ -5082,7 +5373,7 @@ const toHandled = (self, handleResponse, middleware) => {
|
|
|
5082
5373
|
}
|
|
5083
5374
|
return withFiber((fiber) => {
|
|
5084
5375
|
fiberEnterUninterruptibleUnsafe(fiber);
|
|
5085
|
-
const scope = makeUnsafe$
|
|
5376
|
+
const scope = makeUnsafe$3();
|
|
5086
5377
|
const frame = new RequestFrame(scope, fiber.context, getUnsafe(fiber.context, HttpServerRequest));
|
|
5087
5378
|
fiber.setContext(add$1(frame.prev, Scope, scope));
|
|
5088
5379
|
const currentTracer = fiber.cache.tracer;
|
|
@@ -5555,7 +5846,7 @@ const makeMiddleware = (middleware, options) => options?.global ? effectDiscard(
|
|
|
5555
5846
|
const router = yield* HttpRouter;
|
|
5556
5847
|
const fn = isEffect(middleware) ? yield* middleware : middleware;
|
|
5557
5848
|
yield* router.addGlobalMiddleware(fn);
|
|
5558
|
-
})) : new MiddlewareImpl(isEffect(middleware) ? effectContext(map$1(middleware, (fn) => makeUnsafe$
|
|
5849
|
+
})) : new MiddlewareImpl(isEffect(middleware) ? effectContext(map$1(middleware, (fn) => makeUnsafe$4(/* @__PURE__ */ new Map([[fnContextKey, fn]])))) : succeedContext(makeUnsafe$4(/* @__PURE__ */ new Map([[fnContextKey, middleware]]))));
|
|
5559
5850
|
let middlewareId = 0;
|
|
5560
5851
|
const fnContextKey = "effect/http/HttpRouter/MiddlewareFn";
|
|
5561
5852
|
var MiddlewareImpl = class MiddlewareImpl {
|
|
@@ -5571,12 +5862,12 @@ var MiddlewareImpl = class MiddlewareImpl {
|
|
|
5571
5862
|
const stack = [getOrUndefinedUnsafe(context$2, fnContextKey)];
|
|
5572
5863
|
if (this.dependencies) {
|
|
5573
5864
|
const memoMap = yield* CurrentMemoMap;
|
|
5574
|
-
const scope = get$
|
|
5865
|
+
const scope = get$6(context$2, Scope);
|
|
5575
5866
|
const depsContext = yield* buildWithMemoMap(this.dependencies, memoMap, scope);
|
|
5576
5867
|
stack.push(...getMiddleware(depsContext));
|
|
5577
5868
|
}
|
|
5578
|
-
return makeUnsafe$
|
|
5579
|
-
})).pipe(provide(this.layerFn));
|
|
5869
|
+
return makeUnsafe$4(/* @__PURE__ */ new Map([[contextKey, stack]]));
|
|
5870
|
+
})).pipe(provide$1(this.layerFn));
|
|
5580
5871
|
}
|
|
5581
5872
|
layer;
|
|
5582
5873
|
combine(other) {
|
|
@@ -5623,12 +5914,12 @@ const getMiddleware = (context) => {
|
|
|
5623
5914
|
const serve = (appLayer, options) => {
|
|
5624
5915
|
let middleware = options?.middleware;
|
|
5625
5916
|
if (options?.disableLogger !== true) middleware = middleware ? compose$1(middleware, logger$1) : logger$1;
|
|
5626
|
-
const layerWithRouter = provideMerge(appLayer, options?.routerConfig ? provide(layer$8, succeed$2(RouterConfig)(options.routerConfig)) : layer$8);
|
|
5917
|
+
const layerWithRouter = provideMerge(appLayer, options?.routerConfig ? provide$1(layer$8, succeed$2(RouterConfig)(options.routerConfig)) : layer$8);
|
|
5627
5918
|
return contextWith((context) => {
|
|
5628
5919
|
const memoMap = CurrentMemoMap.forkOrCreate(context);
|
|
5629
|
-
return buildWithMemoMap(layerWithRouter, memoMap, get$
|
|
5920
|
+
return buildWithMemoMap(layerWithRouter, memoMap, get$6(context, Scope));
|
|
5630
5921
|
}).pipe(map$1((context) => {
|
|
5631
|
-
const handler = get$
|
|
5922
|
+
const handler = get$6(context, HttpRouter).asHttpEffect();
|
|
5632
5923
|
return merge$3(middleware ? serve$1(handler, middleware) : serve$1(handler), succeedContext(context));
|
|
5633
5924
|
}), unwrap$3, options?.disableListenLog ? identity : withLogAddress);
|
|
5634
5925
|
};
|
|
@@ -5728,7 +6019,7 @@ const makeUnsafe$1 = (backing, deferred) => {
|
|
|
5728
6019
|
* @category constructors
|
|
5729
6020
|
* @since 2.0.0
|
|
5730
6021
|
*/
|
|
5731
|
-
const make$20 = () => acquireRelease(sync(() => makeUnsafe$1(/* @__PURE__ */ new Set(), makeUnsafe$
|
|
6022
|
+
const make$20 = () => acquireRelease(sync(() => makeUnsafe$1(/* @__PURE__ */ new Set(), makeUnsafe$5())), (set) => suspend(() => {
|
|
5732
6023
|
const state = set.state;
|
|
5733
6024
|
if (state._tag === "Closed") return void_;
|
|
5734
6025
|
set.state = { _tag: "Closed" };
|
|
@@ -5999,12 +6290,12 @@ const makeNoSerialization = /*#__PURE__*/ fnUntraced(function* (group, options)
|
|
|
5999
6290
|
const concurrency = options.concurrency ?? "unbounded";
|
|
6000
6291
|
const disableFatalDefects = options.disableFatalDefects ?? false;
|
|
6001
6292
|
const services = yield* context();
|
|
6002
|
-
const scope = get$
|
|
6293
|
+
const scope = get$6(services, Scope);
|
|
6003
6294
|
const trackFiber = runIn(forkUnsafe$1(scope, "parallel"));
|
|
6004
|
-
const concurrencySemaphore = concurrency === "unbounded" ? void 0 : yield* make$
|
|
6295
|
+
const concurrencySemaphore = concurrency === "unbounded" ? void 0 : yield* make$36(concurrency);
|
|
6005
6296
|
const clients = /* @__PURE__ */ new Map();
|
|
6006
6297
|
let isShutdown = false;
|
|
6007
|
-
const shutdownLatch = makeUnsafe$
|
|
6298
|
+
const shutdownLatch = makeUnsafe$6(false);
|
|
6008
6299
|
yield* addFinalizer(scope, withFiber((parent) => {
|
|
6009
6300
|
isShutdown = true;
|
|
6010
6301
|
for (const client of clients.values()) {
|
|
@@ -6106,7 +6397,7 @@ const makeNoSerialization = /*#__PURE__*/ fnUntraced(function* (group, options)
|
|
|
6106
6397
|
}) : streamOrEffect;
|
|
6107
6398
|
const withMiddleware = rpc.middlewares.size === 0 ? handler : isStream ? flatMap(exit(applyMiddleware(services, handler, metadata)), (exit) => writeFailure ? failCause(writeFailure) : exit) : applyMiddleware(services, handler, metadata);
|
|
6108
6399
|
let responded = false;
|
|
6109
|
-
const scope = makeUnsafe$
|
|
6400
|
+
const scope = makeUnsafe$3();
|
|
6110
6401
|
let deferred = void 0;
|
|
6111
6402
|
let effect = onExit(withMiddleware, (exit) => {
|
|
6112
6403
|
responded = true;
|
|
@@ -6196,7 +6487,7 @@ const makeNoSerialization = /*#__PURE__*/ fnUntraced(function* (group, options)
|
|
|
6196
6487
|
client.latches ??= /* @__PURE__ */ new Map();
|
|
6197
6488
|
latch = client.latches.get(request.id);
|
|
6198
6489
|
if (!latch) {
|
|
6199
|
-
latch = makeUnsafe$
|
|
6490
|
+
latch = makeUnsafe$6(false);
|
|
6200
6491
|
client.latches.set(request.id, latch);
|
|
6201
6492
|
}
|
|
6202
6493
|
}
|
|
@@ -6285,7 +6576,7 @@ const make$19 = /*#__PURE__*/ fnUntraced(function* (group, options) {
|
|
|
6285
6576
|
const { codecFor, disconnects, end, run, send, supportsAck, supportsSpanPropagation, supportsTransferables } = yield* Protocol;
|
|
6286
6577
|
const { encodeDefectUnsafe, encodeUnknownRequestExit } = defectCodecs(codecFor);
|
|
6287
6578
|
const services = yield* context();
|
|
6288
|
-
const scope = yield* make$
|
|
6579
|
+
const scope = yield* make$37();
|
|
6289
6580
|
const server = yield* makeNoSerialization(group, {
|
|
6290
6581
|
...options,
|
|
6291
6582
|
disableClientAcks: !supportsAck,
|
|
@@ -6311,7 +6602,7 @@ const make$19 = /*#__PURE__*/ fnUntraced(function* (group, options) {
|
|
|
6311
6602
|
return end(response.clientId);
|
|
6312
6603
|
}
|
|
6313
6604
|
}
|
|
6314
|
-
}).pipe(provide$
|
|
6605
|
+
}).pipe(provide$2(scope));
|
|
6315
6606
|
yield* forkChild(whileLoop({
|
|
6316
6607
|
while: constTrue,
|
|
6317
6608
|
body: constant(flatMap(take(disconnects), (clientId) => {
|
|
@@ -6441,7 +6732,7 @@ const layer$7 = (group, options) => effectDiscard(forkScoped(make$19(group, opti
|
|
|
6441
6732
|
* @category layers
|
|
6442
6733
|
* @since 4.0.0
|
|
6443
6734
|
*/
|
|
6444
|
-
const layerHttp = (options) => layer$7(options.group, options).pipe(provide(options.protocol === "http" ? layerProtocolHttp(options) : layerProtocolWebsocket(options)));
|
|
6735
|
+
const layerHttp = (options) => layer$7(options.group, options).pipe(provide$1(options.protocol === "http" ? layerProtocolHttp(options) : layerProtocolWebsocket(options)));
|
|
6445
6736
|
/**
|
|
6446
6737
|
* Defines the service interface for an RPC server transport, responsible for receiving
|
|
6447
6738
|
* encoded client messages, sending encoded responses, tracking clients, and
|
|
@@ -6522,7 +6813,7 @@ const makeProtocolWithHttpEffect = /*#__PURE__*/ fnUntraced(function* (options =
|
|
|
6522
6813
|
const { encodeDefectUnsafe } = defectCodecs(serialization.codecFor);
|
|
6523
6814
|
const includesFraming = serialization.includesFraming;
|
|
6524
6815
|
const isBinary = !serialization.contentType.includes("json");
|
|
6525
|
-
const disconnects = yield* make$
|
|
6816
|
+
const disconnects = yield* make$38();
|
|
6526
6817
|
let writeRequest;
|
|
6527
6818
|
let clientId = 0;
|
|
6528
6819
|
const clients = /* @__PURE__ */ new Map();
|
|
@@ -6535,7 +6826,7 @@ const makeProtocolWithHttpEffect = /*#__PURE__*/ fnUntraced(function* (options =
|
|
|
6535
6826
|
const requestHeaders = Object.entries(request.headers);
|
|
6536
6827
|
const data = yield* orDie(isBinary ? map$1(request.arrayBuffer, (buf) => new Uint8Array(buf)) : request.text);
|
|
6537
6828
|
const id = clientId++;
|
|
6538
|
-
const queue = yield* make$
|
|
6829
|
+
const queue = yield* make$38({ capacity: includesFraming && options.streamBufferSize !== "unbounded" ? options.streamBufferSize ?? 16 : void 0 });
|
|
6539
6830
|
const parser = serialization.makeUnsafe();
|
|
6540
6831
|
const requestIds = [];
|
|
6541
6832
|
const offer$1 = (data) => typeof data === "string" ? offer(queue, encoder.encode(data)) : offer(queue, data);
|
|
@@ -6652,7 +6943,7 @@ const layerProtocolHttp = (options) => {
|
|
|
6652
6943
|
const makeSocketProtocol = /*#__PURE__*/ gen(function* () {
|
|
6653
6944
|
const serialization = yield* RpcSerialization;
|
|
6654
6945
|
const { encodeDefectUnsafe } = defectCodecs(serialization.codecFor);
|
|
6655
|
-
const disconnects = yield* make$
|
|
6946
|
+
const disconnects = yield* make$38();
|
|
6656
6947
|
let clientId = 0;
|
|
6657
6948
|
const clients = /* @__PURE__ */ new Map();
|
|
6658
6949
|
const clientIds = /* @__PURE__ */ new Set();
|
|
@@ -6831,7 +7122,7 @@ const makeUnsafe = (backing, deferred) => {
|
|
|
6831
7122
|
* @category constructors
|
|
6832
7123
|
* @since 2.0.0
|
|
6833
7124
|
*/
|
|
6834
|
-
const make$18 = () => acquireRelease(sync(() => makeUnsafe(empty$6(), makeUnsafe$
|
|
7125
|
+
const make$18 = () => acquireRelease(sync(() => makeUnsafe(empty$6(), makeUnsafe$5())), (map) => suspend(() => {
|
|
6835
7126
|
const state = map.state;
|
|
6836
7127
|
if (state._tag === "Closed") return void_;
|
|
6837
7128
|
map.state = { _tag: "Closed" };
|
|
@@ -6887,7 +7178,7 @@ const setUnsafe$1 = /*#__PURE__*/ dual((args) => isFiberMap(args[0]), (self, key
|
|
|
6887
7178
|
fiber.interruptUnsafe(internalFiberId);
|
|
6888
7179
|
return;
|
|
6889
7180
|
}
|
|
6890
|
-
const previous = get$
|
|
7181
|
+
const previous = get$5(self.state.backing, key);
|
|
6891
7182
|
if (previous._tag === "Some") {
|
|
6892
7183
|
if (previous.value === fiber) return;
|
|
6893
7184
|
else if (options?.onlyIfMissing === true) {
|
|
@@ -6895,11 +7186,11 @@ const setUnsafe$1 = /*#__PURE__*/ dual((args) => isFiberMap(args[0]), (self, key
|
|
|
6895
7186
|
return;
|
|
6896
7187
|
}
|
|
6897
7188
|
}
|
|
6898
|
-
set(self.state.backing, key, fiber);
|
|
7189
|
+
set$1(self.state.backing, key, fiber);
|
|
6899
7190
|
if (previous._tag === "Some") previous.value.interruptUnsafe(internalFiberId);
|
|
6900
7191
|
fiber.addObserver((exit) => {
|
|
6901
7192
|
if (self.state._tag === "Closed") return;
|
|
6902
|
-
const current = get$
|
|
7193
|
+
const current = get$5(self.state.backing, key);
|
|
6903
7194
|
if (isSome(current) && fiber === current.value) remove$2(self.state.backing, key);
|
|
6904
7195
|
if (isFailure$1(exit) && (options?.propagateInterruption === true ? !isInternalInterruption(exit.cause) : !hasInterruptsOnly(exit.cause))) doneUnsafe(self.deferred, exit);
|
|
6905
7196
|
});
|
|
@@ -6964,7 +7255,7 @@ const hasUnsafe = /*#__PURE__*/ dual(2, (self, key) => self.state._tag === "Clos
|
|
|
6964
7255
|
*/
|
|
6965
7256
|
const remove$1 = /*#__PURE__*/ dual(2, (self, key) => suspend(() => {
|
|
6966
7257
|
if (self.state._tag === "Closed") return void_;
|
|
6967
|
-
const fiber = get$
|
|
7258
|
+
const fiber = get$5(self.state.backing, key);
|
|
6968
7259
|
if (fiber._tag === "None") return void_;
|
|
6969
7260
|
return interruptAs(fiber.value, internalFiberId);
|
|
6970
7261
|
}));
|
|
@@ -11211,7 +11502,7 @@ const make$16 = /*#__PURE__*/ make$28({
|
|
|
11211
11502
|
* @category layers
|
|
11212
11503
|
* @since 4.0.0
|
|
11213
11504
|
*/
|
|
11214
|
-
const layer$5 = /*#__PURE__*/ pipe(/*#__PURE__*/ effect(HttpPlatform)(make$16), /*#__PURE__*/ provide(layer$10), /*#__PURE__*/ provide(layer$9));
|
|
11505
|
+
const layer$5 = /*#__PURE__*/ pipe(/*#__PURE__*/ effect(HttpPlatform)(make$16), /*#__PURE__*/ provide$1(layer$10), /*#__PURE__*/ provide$1(layer$9));
|
|
11215
11506
|
//#endregion
|
|
11216
11507
|
//#region ../../node_modules/.pnpm/@effect+platform-node@4.0.5_effect@4.0.5_redis@6.3.0_@opentelemetry+api@1.9.1_/node_modules/@effect/platform-node/dist/NodeMultipartParser.js
|
|
11217
11508
|
/**
|
|
@@ -11487,7 +11778,7 @@ const make$14 = /*#__PURE__*/ fnUntraced(function* (evaluate, options) {
|
|
|
11487
11778
|
noServer: true
|
|
11488
11779
|
})), (wss) => callback((resume) => {
|
|
11489
11780
|
wss.close(() => resume(void_));
|
|
11490
|
-
})).pipe(provide$
|
|
11781
|
+
})).pipe(provide$2(scope$2), cached);
|
|
11491
11782
|
return make$22({
|
|
11492
11783
|
address: boundAddress,
|
|
11493
11784
|
serve: fnUntraced(function* (httpApp, middleware) {
|
|
@@ -11747,7 +12038,7 @@ const handleResponse = (request, response) => {
|
|
|
11747
12038
|
});
|
|
11748
12039
|
case "Stream": {
|
|
11749
12040
|
nodeResponse.writeHead(response.status, response.statusText, headers);
|
|
11750
|
-
const drainLatch = makeUnsafe$
|
|
12041
|
+
const drainLatch = makeUnsafe$6();
|
|
11751
12042
|
nodeResponse.on("drain", () => drainLatch.openUnsafe());
|
|
11752
12043
|
return body.stream.pipe(orDie$1, runForEachArray((array) => {
|
|
11753
12044
|
const chunk = array.length > 1 ? Buffer.concat(array) : array[0];
|
|
@@ -12096,7 +12387,7 @@ const utf8Strings = (record) => {
|
|
|
12096
12387
|
*/
|
|
12097
12388
|
const layer$4 = /*#__PURE__*/ effect(Dns, /*#__PURE__*/ orDie(/*#__PURE__*/ (/* @__PURE__ */ fnUntraced(function* (options) {
|
|
12098
12389
|
const resolve = yield* resolver(options);
|
|
12099
|
-
return make$
|
|
12390
|
+
return make$39({
|
|
12100
12391
|
lookup,
|
|
12101
12392
|
resolve: (name, type) => map$1(resolve(name, type), map$3(utf8Strings))
|
|
12102
12393
|
});
|
|
@@ -12540,7 +12831,7 @@ const Proto$3 = {
|
|
|
12540
12831
|
*/
|
|
12541
12832
|
const make$12 = (value) => map$1(unbounded({ replay: 1 }), (pubsub) => {
|
|
12542
12833
|
const self = Object.create(Proto$3);
|
|
12543
|
-
self.semaphore = makeUnsafe$
|
|
12834
|
+
self.semaphore = makeUnsafe$7(1);
|
|
12544
12835
|
self.value = value;
|
|
12545
12836
|
self.pubsub = pubsub;
|
|
12546
12837
|
publishUnsafe(self.pubsub, value);
|
|
@@ -12977,6 +13268,491 @@ const evaluateConditionalRequest = (request, response) => {
|
|
|
12977
13268
|
if (ifModifiedSince !== void 0 && isNotModifiedSince(ifModifiedSince, response.headers["last-modified"])) return notModifiedResponse(response);
|
|
12978
13269
|
};
|
|
12979
13270
|
//#endregion
|
|
13271
|
+
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/encoding/Sse.js
|
|
13272
|
+
const SseErrorTypeId = "~effect/encoding/Sse/SseError";
|
|
13273
|
+
/**
|
|
13274
|
+
* Error reason raised when pending Server-Sent Events state exceeds the
|
|
13275
|
+
* configured maximum size.
|
|
13276
|
+
*
|
|
13277
|
+
* @stability unstable
|
|
13278
|
+
* @category errors
|
|
13279
|
+
* @since 4.0.0
|
|
13280
|
+
*/
|
|
13281
|
+
var EventTooLarge = class extends (/*#__PURE__*/ TaggedError("EventTooLarge")) {
|
|
13282
|
+
get message() {
|
|
13283
|
+
return `Pending SSE event exceeded the maximum size of ${this.maxEventSize}`;
|
|
13284
|
+
}
|
|
13285
|
+
};
|
|
13286
|
+
/**
|
|
13287
|
+
* Error raised when decoding a Server-Sent Events stream fails.
|
|
13288
|
+
*
|
|
13289
|
+
* @stability unstable
|
|
13290
|
+
* @category errors
|
|
13291
|
+
* @since 4.0.0
|
|
13292
|
+
*/
|
|
13293
|
+
var SseError = class extends (/*#__PURE__*/ TaggedError("SseError")) {
|
|
13294
|
+
/**
|
|
13295
|
+
* Marks this value as an SSE decoding error.
|
|
13296
|
+
*
|
|
13297
|
+
* @stability unstable
|
|
13298
|
+
* @since 4.0.0
|
|
13299
|
+
*/
|
|
13300
|
+
[SseErrorTypeId] = SseErrorTypeId;
|
|
13301
|
+
/**
|
|
13302
|
+
* Delegates the public message to the underlying SSE error reason.
|
|
13303
|
+
*
|
|
13304
|
+
* @stability unstable
|
|
13305
|
+
* @since 4.0.0
|
|
13306
|
+
*/
|
|
13307
|
+
get message() {
|
|
13308
|
+
return this.reason.message;
|
|
13309
|
+
}
|
|
13310
|
+
};
|
|
13311
|
+
const defaultMaxEventSize = 10485760;
|
|
13312
|
+
/**
|
|
13313
|
+
* Creates a channel that parses Server-Sent Events text chunks into `Event` values.
|
|
13314
|
+
*
|
|
13315
|
+
* **Details**
|
|
13316
|
+
*
|
|
13317
|
+
* SSE `retry` directives are emitted as `Retry` failures so callers can
|
|
13318
|
+
* reconnect with the requested delay.
|
|
13319
|
+
*
|
|
13320
|
+
* @stability unstable
|
|
13321
|
+
* @category decoding
|
|
13322
|
+
* @since 4.0.0
|
|
13323
|
+
*/
|
|
13324
|
+
const decode$1 = (options) => fromTransform((upstream, _scope) => sync(() => {
|
|
13325
|
+
let buffer = [];
|
|
13326
|
+
let retry;
|
|
13327
|
+
const parser = makeParser((event) => {
|
|
13328
|
+
if (event._tag === "Retry") retry = event;
|
|
13329
|
+
else buffer.push(event);
|
|
13330
|
+
}, options);
|
|
13331
|
+
const pump = flatMap(upstream, (arr) => {
|
|
13332
|
+
for (let i = 0; i < arr.length; i++) {
|
|
13333
|
+
const error = parser.feed(arr[i]);
|
|
13334
|
+
if (error !== void 0) return fail$1(error);
|
|
13335
|
+
}
|
|
13336
|
+
return void_;
|
|
13337
|
+
});
|
|
13338
|
+
return suspend(function loop() {
|
|
13339
|
+
if (isArrayNonEmpty(buffer)) {
|
|
13340
|
+
const out = buffer;
|
|
13341
|
+
buffer = [];
|
|
13342
|
+
return succeed$1(out);
|
|
13343
|
+
} else if (retry) return fail$1(retry);
|
|
13344
|
+
return flatMap(pump, loop);
|
|
13345
|
+
});
|
|
13346
|
+
}));
|
|
13347
|
+
/**
|
|
13348
|
+
* Creates an SSE decoder channel that decodes each parsed event with a schema.
|
|
13349
|
+
*
|
|
13350
|
+
* **Details**
|
|
13351
|
+
*
|
|
13352
|
+
* The schema receives `{ event, data, id? }`, with string `data`. Absent IDs are
|
|
13353
|
+
* omitted, even with default options: use `Schema.optional(Schema.String)`, not
|
|
13354
|
+
* `Schema.UndefinedOr(Schema.String)`, to accept events without an ID.
|
|
13355
|
+
*
|
|
13356
|
+
* With `onExcessProperty: "error"`, declare `event` (default: `"message"`) and
|
|
13357
|
+
* `id` if the stream carries IDs, including inherited IDs.
|
|
13358
|
+
*
|
|
13359
|
+
* @stability unstable
|
|
13360
|
+
* @category decoding
|
|
13361
|
+
* @since 4.0.0
|
|
13362
|
+
*/
|
|
13363
|
+
const decodeSchema = (schema, options, parseOptions) => pipeTo(decode$1(options), decode$2(Event$1.pipe(decodeTo(schema, transformEvent)), parseOptions)());
|
|
13364
|
+
/**
|
|
13365
|
+
* Creates an SSE decoder channel that JSON-decodes each event `data` field with a schema.
|
|
13366
|
+
*
|
|
13367
|
+
* **Details**
|
|
13368
|
+
*
|
|
13369
|
+
* The output preserves the SSE `event` name and optional `id` while replacing
|
|
13370
|
+
* `data` with the decoded value.
|
|
13371
|
+
*
|
|
13372
|
+
* @stability unstable
|
|
13373
|
+
* @category decoding
|
|
13374
|
+
* @since 4.0.0
|
|
13375
|
+
*/
|
|
13376
|
+
const decodeDataSchema = (schema, options) => {
|
|
13377
|
+
const eventSchema = Struct({
|
|
13378
|
+
...EventEncoded.fields,
|
|
13379
|
+
data: fromJsonString(schema)
|
|
13380
|
+
});
|
|
13381
|
+
return pipeTo(decode$1(options), map$4(decode$2(eventSchema)(), map$3((event) => ({
|
|
13382
|
+
...event,
|
|
13383
|
+
id: event.id
|
|
13384
|
+
}))));
|
|
13385
|
+
};
|
|
13386
|
+
/**
|
|
13387
|
+
* Creates a stateful Server-Sent Events parser.
|
|
13388
|
+
*
|
|
13389
|
+
* **Details**
|
|
13390
|
+
*
|
|
13391
|
+
* Call `feed` with text chunks to parse `Event` and `Retry` values through the
|
|
13392
|
+
* callback, and call `reset` to clear any buffered event state. `feed` returns
|
|
13393
|
+
* an `SseError` if the pending event exceeds `maxEventSize`.
|
|
13394
|
+
*
|
|
13395
|
+
* @stability unstable
|
|
13396
|
+
* @category decoding
|
|
13397
|
+
* @since 4.0.0
|
|
13398
|
+
*/
|
|
13399
|
+
function makeParser(onParse, options) {
|
|
13400
|
+
const maxEventSize = options?.maxEventSize ?? defaultMaxEventSize;
|
|
13401
|
+
const dispatchEmptyNamedEvents = options?.dispatchEmptyNamedEvents === true;
|
|
13402
|
+
let isFirstChunk;
|
|
13403
|
+
let pending;
|
|
13404
|
+
let pendingLength;
|
|
13405
|
+
let discardTrailingNewline;
|
|
13406
|
+
let generation = 0;
|
|
13407
|
+
let lastEventId;
|
|
13408
|
+
let eventName;
|
|
13409
|
+
let data;
|
|
13410
|
+
reset();
|
|
13411
|
+
return {
|
|
13412
|
+
feed,
|
|
13413
|
+
reset
|
|
13414
|
+
};
|
|
13415
|
+
function reset() {
|
|
13416
|
+
generation++;
|
|
13417
|
+
isFirstChunk = true;
|
|
13418
|
+
pending = [];
|
|
13419
|
+
pendingLength = 0;
|
|
13420
|
+
discardTrailingNewline = false;
|
|
13421
|
+
lastEventId = void 0;
|
|
13422
|
+
eventName = void 0;
|
|
13423
|
+
data = "";
|
|
13424
|
+
}
|
|
13425
|
+
function feed(chunk) {
|
|
13426
|
+
if (isFirstChunk && chunk.startsWith(BOM)) chunk = chunk.slice(BOM.length);
|
|
13427
|
+
isFirstChunk = false;
|
|
13428
|
+
const length = chunk.length;
|
|
13429
|
+
const currentGeneration = generation;
|
|
13430
|
+
let position = 0;
|
|
13431
|
+
while (position < length) {
|
|
13432
|
+
if (discardTrailingNewline) {
|
|
13433
|
+
discardTrailingNewline = false;
|
|
13434
|
+
if (chunk.charCodeAt(position) === LF) {
|
|
13435
|
+
++position;
|
|
13436
|
+
continue;
|
|
13437
|
+
}
|
|
13438
|
+
}
|
|
13439
|
+
let lineEnd = position;
|
|
13440
|
+
while (lineEnd < length) {
|
|
13441
|
+
const code = chunk.charCodeAt(lineEnd);
|
|
13442
|
+
if (code === CR || code === LF) break;
|
|
13443
|
+
++lineEnd;
|
|
13444
|
+
}
|
|
13445
|
+
if (lineEnd === length) {
|
|
13446
|
+
pending.push(chunk.slice(position));
|
|
13447
|
+
pendingLength += length - position;
|
|
13448
|
+
break;
|
|
13449
|
+
}
|
|
13450
|
+
discardTrailingNewline = chunk.charCodeAt(lineEnd) === CR;
|
|
13451
|
+
let line = chunk.slice(position, lineEnd);
|
|
13452
|
+
if (pending.length > 0) {
|
|
13453
|
+
pending.push(line);
|
|
13454
|
+
line = pending.join("");
|
|
13455
|
+
pending = [];
|
|
13456
|
+
pendingLength = 0;
|
|
13457
|
+
}
|
|
13458
|
+
parseLine(line);
|
|
13459
|
+
if (generation !== currentGeneration) return;
|
|
13460
|
+
position = lineEnd + 1;
|
|
13461
|
+
}
|
|
13462
|
+
if (pendingLength + data.length > maxEventSize) {
|
|
13463
|
+
const error = new SseError({ reason: new EventTooLarge({ maxEventSize }) });
|
|
13464
|
+
reset();
|
|
13465
|
+
return error;
|
|
13466
|
+
}
|
|
13467
|
+
}
|
|
13468
|
+
function parseLine(line) {
|
|
13469
|
+
if (line.length === 0) {
|
|
13470
|
+
const named = eventName !== void 0 && eventName !== "";
|
|
13471
|
+
const event = eventName || "message";
|
|
13472
|
+
const eventData = data;
|
|
13473
|
+
eventName = void 0;
|
|
13474
|
+
data = "";
|
|
13475
|
+
if (eventData.length > 0 || dispatchEmptyNamedEvents && named) onParse({
|
|
13476
|
+
_tag: "Event",
|
|
13477
|
+
id: lastEventId,
|
|
13478
|
+
event,
|
|
13479
|
+
data: eventData.slice(0, -1)
|
|
13480
|
+
});
|
|
13481
|
+
return;
|
|
13482
|
+
}
|
|
13483
|
+
const colon = line.indexOf(":");
|
|
13484
|
+
let field = line;
|
|
13485
|
+
let value = "";
|
|
13486
|
+
if (colon >= 0) {
|
|
13487
|
+
field = line.slice(0, colon);
|
|
13488
|
+
value = line.slice(line.charCodeAt(colon + 1) === SPACE ? colon + 2 : colon + 1);
|
|
13489
|
+
}
|
|
13490
|
+
if (field === "data") data += value + "\n";
|
|
13491
|
+
else if (field === "event") eventName = value;
|
|
13492
|
+
else if (field === "id" && !value.includes("\0")) lastEventId = value;
|
|
13493
|
+
else if (field === "retry" && /^\d+$/.test(value)) onParse(new Retry({
|
|
13494
|
+
duration: millis(parseInt(value, 10)),
|
|
13495
|
+
lastEventId
|
|
13496
|
+
}));
|
|
13497
|
+
}
|
|
13498
|
+
}
|
|
13499
|
+
const BOM = "";
|
|
13500
|
+
const LF = 10;
|
|
13501
|
+
const CR = 13;
|
|
13502
|
+
const SPACE = 32;
|
|
13503
|
+
/**
|
|
13504
|
+
* Schema for the untagged Server-Sent Events payload shape containing an optional `id`, `event`, and string `data` fields.
|
|
13505
|
+
*
|
|
13506
|
+
* @stability unstable
|
|
13507
|
+
* @category models
|
|
13508
|
+
* @since 4.0.0
|
|
13509
|
+
*/
|
|
13510
|
+
const EventEncoded = /*#__PURE__*/ Struct({
|
|
13511
|
+
id: /*#__PURE__*/ optional$1(String$1),
|
|
13512
|
+
event: String$1,
|
|
13513
|
+
data: String$1
|
|
13514
|
+
});
|
|
13515
|
+
/**
|
|
13516
|
+
* Schema for the tagged Server-Sent Events message model that adds `_tag: "Event"` to the event name, optional event ID, and string data payload.
|
|
13517
|
+
*
|
|
13518
|
+
* @stability unstable
|
|
13519
|
+
* @category models
|
|
13520
|
+
* @since 4.0.0
|
|
13521
|
+
*/
|
|
13522
|
+
const Event$1 = /*#__PURE__*/ Struct({
|
|
13523
|
+
_tag: /*#__PURE__*/ tag("Event"),
|
|
13524
|
+
id: /*#__PURE__*/ UndefinedOr(String$1),
|
|
13525
|
+
event: String$1,
|
|
13526
|
+
data: String$1
|
|
13527
|
+
});
|
|
13528
|
+
/**
|
|
13529
|
+
* Schema for transforming untagged SSE event payloads into tagged `Event`
|
|
13530
|
+
* models.
|
|
13531
|
+
*
|
|
13532
|
+
* @stability unstable
|
|
13533
|
+
* @category models
|
|
13534
|
+
* @since 4.0.0
|
|
13535
|
+
*/
|
|
13536
|
+
const transformEvent = /*#__PURE__*/ transform$1({
|
|
13537
|
+
decode: (event) => event.id === void 0 ? {
|
|
13538
|
+
event: event.event,
|
|
13539
|
+
data: event.data
|
|
13540
|
+
} : {
|
|
13541
|
+
id: event.id,
|
|
13542
|
+
event: event.event,
|
|
13543
|
+
data: event.data
|
|
13544
|
+
},
|
|
13545
|
+
encode: (event) => ({
|
|
13546
|
+
_tag: "Event",
|
|
13547
|
+
id: event.id,
|
|
13548
|
+
event: event.event ?? "message",
|
|
13549
|
+
data: event.data
|
|
13550
|
+
})
|
|
13551
|
+
});
|
|
13552
|
+
const RetryTypeId = "~effect/encoding/Sse/Retry";
|
|
13553
|
+
/**
|
|
13554
|
+
* Represents a Server-Sent Events retry directive.
|
|
13555
|
+
*
|
|
13556
|
+
* **Details**
|
|
13557
|
+
*
|
|
13558
|
+
* Decoders surface this value as a failure to request reconnection after
|
|
13559
|
+
* `duration`; encoders serialize an upstream `Retry` failure as a `retry:` line.
|
|
13560
|
+
*
|
|
13561
|
+
* @stability unstable
|
|
13562
|
+
* @category models
|
|
13563
|
+
* @since 4.0.0
|
|
13564
|
+
*/
|
|
13565
|
+
var Retry = class Retry extends (/*#__PURE__*/ TaggedClass("Retry")) {
|
|
13566
|
+
/**
|
|
13567
|
+
* Marks this value as an SSE retry directive for runtime guards.
|
|
13568
|
+
*
|
|
13569
|
+
* @stability unstable
|
|
13570
|
+
* @since 4.0.0
|
|
13571
|
+
*/
|
|
13572
|
+
[RetryTypeId] = RetryTypeId;
|
|
13573
|
+
/**
|
|
13574
|
+
* Returns `true` when the value is an SSE retry directive.
|
|
13575
|
+
*
|
|
13576
|
+
* @stability unstable
|
|
13577
|
+
* @since 4.0.0
|
|
13578
|
+
*/
|
|
13579
|
+
static is(u) {
|
|
13580
|
+
return hasProperty(u, RetryTypeId);
|
|
13581
|
+
}
|
|
13582
|
+
/**
|
|
13583
|
+
* Separates SSE retry directives from regular event values.
|
|
13584
|
+
*
|
|
13585
|
+
* @stability unstable
|
|
13586
|
+
* @since 4.0.0
|
|
13587
|
+
*/
|
|
13588
|
+
static filter(u) {
|
|
13589
|
+
return Retry.is(u) ? succeed(u) : fail(u);
|
|
13590
|
+
}
|
|
13591
|
+
};
|
|
13592
|
+
//#endregion
|
|
13593
|
+
//#region ../../packages/auth/src/service.ts
|
|
13594
|
+
const SESSION_COOKIE = "__Secure-session";
|
|
13595
|
+
const OAUTH_COOKIE = "__Host-oauth";
|
|
13596
|
+
const COOKIE = {
|
|
13597
|
+
httpOnly: true,
|
|
13598
|
+
path: "/",
|
|
13599
|
+
sameSite: "lax",
|
|
13600
|
+
secure: true
|
|
13601
|
+
};
|
|
13602
|
+
const SESSION_DURATION = days(365);
|
|
13603
|
+
const OAUTH_DURATION = minutes(10);
|
|
13604
|
+
Uint8Array.from([
|
|
13605
|
+
48,
|
|
13606
|
+
46,
|
|
13607
|
+
2,
|
|
13608
|
+
1,
|
|
13609
|
+
0,
|
|
13610
|
+
48,
|
|
13611
|
+
5,
|
|
13612
|
+
6,
|
|
13613
|
+
3,
|
|
13614
|
+
43,
|
|
13615
|
+
101,
|
|
13616
|
+
112,
|
|
13617
|
+
4,
|
|
13618
|
+
34,
|
|
13619
|
+
4,
|
|
13620
|
+
32
|
|
13621
|
+
]);
|
|
13622
|
+
all({
|
|
13623
|
+
clientId: String$2("GITHUB_CLIENT_ID"),
|
|
13624
|
+
clientSecret: Redacted("GITHUB_CLIENT_SECRET"),
|
|
13625
|
+
users: Array$1(Int, "GITHUB_USERS")
|
|
13626
|
+
});
|
|
13627
|
+
function bytes(text) {
|
|
13628
|
+
return new TextEncoder().encode(text);
|
|
13629
|
+
}
|
|
13630
|
+
function rejected(message) {
|
|
13631
|
+
return mapError((cause) => AuthError.make({
|
|
13632
|
+
cause,
|
|
13633
|
+
message
|
|
13634
|
+
}));
|
|
13635
|
+
}
|
|
13636
|
+
function respond(message, handler) {
|
|
13637
|
+
return catch_(handler, (cause) => as$1(logWarning(message, cause), text$2(message, { status: match(is$4(AuthError)(cause), {
|
|
13638
|
+
onFalse: () => 500,
|
|
13639
|
+
onTrue: () => 401
|
|
13640
|
+
}) })));
|
|
13641
|
+
}
|
|
13642
|
+
function userFrom(auth, headers) {
|
|
13643
|
+
return pipe(get$7(headers, "authorization"), filter$4(startsWith("Bearer ")), map$5(replace$1("Bearer ", "")), orElse$2(() => pipe(get$7(headers, "cookie"), flatMapNullishOr((cookie) => parseHeader(cookie)[SESSION_COOKIE]))), fromOption, rejected("Sign in first"), flatMap((token) => auth.verify(token)));
|
|
13644
|
+
}
|
|
13645
|
+
function provide(auth) {
|
|
13646
|
+
return pipe(make$40(Auth, auth), add$1(RpcAuth, RpcAuth.of((effect, request) => flatMap(userFrom(auth, request.headers), (user) => provideService(effect, CurrentUser, user)))));
|
|
13647
|
+
}
|
|
13648
|
+
function verifyWith(current) {
|
|
13649
|
+
return fn$1("Auth.verify")(function* (token) {
|
|
13650
|
+
const { publicKey, users } = yield* current;
|
|
13651
|
+
const parts = split(token, ".");
|
|
13652
|
+
const signature = yield* pipe(get$8(parts, 1), flatMap$1((part) => getSuccess(decode$3(part))), fromOption);
|
|
13653
|
+
if (!(yield* tryPromise(() => crypto.subtle.verify("Ed25519", publicKey, new Uint8Array(signature), bytes(headNonEmpty(parts)))))) return yield* AuthError.make({ message: "The session signature is invalid" });
|
|
13654
|
+
const session = yield* decodeEffect(Session)(headNonEmpty(parts));
|
|
13655
|
+
if (session.expiresAt <= (yield* currentTimeMillis)) return yield* AuthError.make({ message: "The session expired" });
|
|
13656
|
+
if (!has$3(users, session.user.id)) return yield* AuthError.make({ message: `${session.user.id} is not on the allow list` });
|
|
13657
|
+
return session.user;
|
|
13658
|
+
}, rejected("Sign in first"));
|
|
13659
|
+
}
|
|
13660
|
+
const SameOrigin = middleware((httpEffect) => gen(function* () {
|
|
13661
|
+
const request = yield* HttpServerRequest;
|
|
13662
|
+
if (exists(get$7(request.headers, "origin"), (origin) => !exists(toURL(request), (url) => url.origin === origin))) return text$2("The request comes from another origin", { status: 403 });
|
|
13663
|
+
return yield* httpEffect;
|
|
13664
|
+
}), { global: true });
|
|
13665
|
+
function parentDomain(request) {
|
|
13666
|
+
return pipe(toURL(request), map$5((url) => pipe(url.hostname, split("."), drop(1), join$1("."))), filter$4(isNonEmpty));
|
|
13667
|
+
}
|
|
13668
|
+
function callbackUrl(request) {
|
|
13669
|
+
return pipe(toURL(request), map$5((url) => new URL("/auth/github/callback", url).href), fromOption);
|
|
13670
|
+
}
|
|
13671
|
+
fnUntraced(function* (issuer, config, redirects) {
|
|
13672
|
+
const router = yield* HttpRouter;
|
|
13673
|
+
const random = yield* Crypto;
|
|
13674
|
+
const client = filterStatusOk(yield* HttpClient);
|
|
13675
|
+
yield* router.add("GET", "/auth/github", respond("Cannot start the GitHub sign-in", gen(function* () {
|
|
13676
|
+
const request = yield* HttpServerRequest;
|
|
13677
|
+
const query = yield* pipe(schemaSearchParams(SignInParams), rejected("The redirect is invalid"));
|
|
13678
|
+
const domain = parentDomain(request);
|
|
13679
|
+
if (exists(fromUndefinedOr(query.redirect), (redirect) => !contains$1(redirects, redirect) && !exists(getSuccess(fromString(redirect)), (url) => url.protocol === "https:" && exists(domain, (parent) => endsWith(`.${parent}`)(`.${url.hostname}`))))) return yield* AuthError.make({ message: "The redirect is not allowed" });
|
|
13680
|
+
const state = encode(yield* random.randomBytes(32));
|
|
13681
|
+
const verifier = encode(yield* random.randomBytes(32));
|
|
13682
|
+
const authorize = toString$2(fromInput({
|
|
13683
|
+
client_id: config.clientId,
|
|
13684
|
+
code_challenge: encode(yield* random.digest("SHA-256", bytes(verifier))),
|
|
13685
|
+
code_challenge_method: "S256",
|
|
13686
|
+
redirect_uri: yield* callbackUrl(request),
|
|
13687
|
+
response_type: "code",
|
|
13688
|
+
state
|
|
13689
|
+
}));
|
|
13690
|
+
return setCookieUnsafe(redirect(`https://github.com/login/oauth/authorize?${authorize}`), OAUTH_COOKIE, yield* encodeEffect(OAuthFlow)({
|
|
13691
|
+
...query,
|
|
13692
|
+
state,
|
|
13693
|
+
verifier
|
|
13694
|
+
}), {
|
|
13695
|
+
...COOKIE,
|
|
13696
|
+
maxAge: OAUTH_DURATION
|
|
13697
|
+
});
|
|
13698
|
+
})));
|
|
13699
|
+
yield* router.add("GET", "/auth/github/callback", respond("The GitHub sign-in failed", gen(function* () {
|
|
13700
|
+
const request = yield* HttpServerRequest;
|
|
13701
|
+
const params = yield* pipe(schemaSearchParams(CallbackParams), rejected("GitHub sent no code"));
|
|
13702
|
+
const flow = yield* pipe(decodeUnknownEffect(OAuthFlow)(request.cookies[OAUTH_COOKIE]), rejected("The sign-in expired"));
|
|
13703
|
+
if (flow.state !== params.state) return yield* AuthError.make({ message: "The sign-in state does not match" });
|
|
13704
|
+
const token = yield* pipe(post("https://github.com/login/oauth/access_token"), acceptJson, bodyUrlParams({
|
|
13705
|
+
client_id: config.clientId,
|
|
13706
|
+
client_secret: value$2(config.clientSecret),
|
|
13707
|
+
code: params.code,
|
|
13708
|
+
code_verifier: flow.verifier,
|
|
13709
|
+
grant_type: "authorization_code",
|
|
13710
|
+
redirect_uri: yield* callbackUrl(request)
|
|
13711
|
+
}), (exchange) => client.execute(exchange), flatMap(schemaBodyJson$1(OAuthTokenResponse)));
|
|
13712
|
+
if (is$4(OAuthTokenError)(token)) return yield* AuthError.make({ message: `GitHub rejected the code: ${token.error}` });
|
|
13713
|
+
const githubUser = yield* pipe(get$3("https://api.github.com/user"), bearerToken(token.access_token), setHeaders$1({
|
|
13714
|
+
accept: "application/vnd.github+json",
|
|
13715
|
+
"user-agent": "@deslop/auth"
|
|
13716
|
+
}), (lookup) => client.execute(lookup), flatMap(schemaBodyJson$1(GitHubUser)));
|
|
13717
|
+
const session = yield* issuer.issue({
|
|
13718
|
+
id: `github:${githubUser.id}`,
|
|
13719
|
+
name: githubUser.login
|
|
13720
|
+
});
|
|
13721
|
+
const redirect$1 = flow.redirect ?? "/";
|
|
13722
|
+
if (contains$1(redirects, redirect$1)) return expireCookieUnsafe(redirect(`${redirect$1}?${toString$2(fromInput({ token: session }))}`), OAUTH_COOKIE, COOKIE);
|
|
13723
|
+
return setCookieUnsafe(expireCookieUnsafe(redirect(redirect$1), OAUTH_COOKIE, COOKIE), SESSION_COOKIE, session, {
|
|
13724
|
+
...COOKIE,
|
|
13725
|
+
domain: getOrUndefined(parentDomain(request)),
|
|
13726
|
+
maxAge: SESSION_DURATION
|
|
13727
|
+
});
|
|
13728
|
+
})));
|
|
13729
|
+
});
|
|
13730
|
+
var Auth = class Auth extends Service()("@deslop/auth/service/Auth") {
|
|
13731
|
+
static layer = merge$3(SameOrigin, effectContext(gen(function* () {
|
|
13732
|
+
const client = filterStatusOk(yield* HttpClient);
|
|
13733
|
+
const url = yield* pipe(String$2("AUTH_URL"), withDefault(AUTH_URL));
|
|
13734
|
+
const read = pipe(client.get(`${url}/auth/keys`), flatMap(schemaBodyJson$1(Verification)), flatMap((verification) => map$1(pipe(fromResult(decode$3(verification.key)), flatMap((key) => tryPromise(() => crypto.subtle.importKey("raw", new Uint8Array(key), { name: "Ed25519" }, false, ["verify"])))), (publicKey) => ({
|
|
13735
|
+
publicKey,
|
|
13736
|
+
users: fromIterable$2(verification.users)
|
|
13737
|
+
}))), timeout("10 seconds"));
|
|
13738
|
+
const current = yield* make$34(yield* pipe(read, tapError$1((cause) => logWarning(`Cannot read the auth keys from ${url}`, cause)), retry(spaced("5 seconds"))));
|
|
13739
|
+
yield* pipe(read, flatMap((verification) => set(current, verification)), ignore$1({
|
|
13740
|
+
log: "Warn",
|
|
13741
|
+
message: `Cannot refresh the auth keys from ${url}`
|
|
13742
|
+
}), repeat(spaced("1 minute")), forkScoped);
|
|
13743
|
+
return provide(Auth.of({ verify: verifyWith(get$4(current)) }));
|
|
13744
|
+
})));
|
|
13745
|
+
};
|
|
13746
|
+
Service()("@deslop/auth/service/Issuer");
|
|
13747
|
+
const HttpAuth = middleware()(gen(function* () {
|
|
13748
|
+
const auth = yield* Auth;
|
|
13749
|
+
return (httpEffect) => gen(function* () {
|
|
13750
|
+
const user = yield* result$1(userFrom(auth, (yield* HttpServerRequest).headers));
|
|
13751
|
+
if (isFailure(user)) return yield* as$1(logWarning("Sign in first", user.failure), text$2("Sign in first", { status: 401 }));
|
|
13752
|
+
return yield* provideService(httpEffect, CurrentUser, user.success);
|
|
13753
|
+
});
|
|
13754
|
+
}));
|
|
13755
|
+
//#endregion
|
|
12980
13756
|
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/observability/OtlpExporter.js
|
|
12981
13757
|
/**
|
|
12982
13758
|
* Shared batch exporter for OTLP/HTTP observability modules.
|
|
@@ -13078,18 +13854,18 @@ const layerFlusher = /*#__PURE__*/ sync$1(Flusher, () => {
|
|
|
13078
13854
|
*/
|
|
13079
13855
|
const make$10 = /*#__PURE__*/ fnUntraced(function* (options) {
|
|
13080
13856
|
const services = yield* context();
|
|
13081
|
-
const clock = get$
|
|
13082
|
-
const scope = get$
|
|
13857
|
+
const clock = get$6(services, Clock);
|
|
13858
|
+
const scope = get$6(services, Scope);
|
|
13083
13859
|
const exportInterval = max$1(fromInputUnsafe$1(options.exportInterval), zero$1);
|
|
13084
13860
|
let disabledUntil = void 0;
|
|
13085
|
-
const client = get$
|
|
13861
|
+
const client = get$6(services, HttpClient).pipe(tap((response) => ignore$1(response.arrayBuffer)), tapError((error) => error.response ? ignore$1(error.response.arrayBuffer) : void_), filterStatusOk, transformResponse(provideService(TracerPropagationEnabled, false)), retryTransient({
|
|
13086
13862
|
schedule: policy,
|
|
13087
13863
|
times: 3
|
|
13088
13864
|
}));
|
|
13089
13865
|
const exporterUserAgent = `OTel-OTLP-Exporter-JavaScript-Effect-${options.label}/${getCurrentVersion()}`;
|
|
13090
13866
|
const userHeaders = fromInput$1(options.headers);
|
|
13091
13867
|
const userAgent = userHeaders["user-agent"];
|
|
13092
|
-
const headers = set$
|
|
13868
|
+
const headers = set$3(userHeaders, "user-agent", userAgent ? `${userAgent} ${exporterUserAgent}` : exporterUserAgent);
|
|
13093
13869
|
const request = post(options.url, { headers });
|
|
13094
13870
|
let buffer = [];
|
|
13095
13871
|
const runExport = suspend(() => {
|
|
@@ -13325,7 +14101,7 @@ const make$8 = /*#__PURE__*/ fnUntraced(function* (options) {
|
|
|
13325
14101
|
excludeLogSpans: options.excludeLogSpans ?? false,
|
|
13326
14102
|
clock: yield* Clock
|
|
13327
14103
|
};
|
|
13328
|
-
return make$
|
|
14104
|
+
return make$41((options) => {
|
|
13329
14105
|
exporter.push(makeLogRecord(options, opts));
|
|
13330
14106
|
});
|
|
13331
14107
|
});
|
|
@@ -13450,7 +14226,7 @@ const layer$1 = /*#__PURE__*/ flow(/* @__PURE__ */ fnUntraced(function* (options
|
|
|
13450
14226
|
if (!span.sampled) return;
|
|
13451
14227
|
exporter.push(makeOtlpSpan(span));
|
|
13452
14228
|
}
|
|
13453
|
-
return make$
|
|
14229
|
+
return make$42({
|
|
13454
14230
|
span(options) {
|
|
13455
14231
|
return new SpanImpl(options, exportFn);
|
|
13456
14232
|
},
|
|
@@ -13619,7 +14395,7 @@ function layerOtlp(serviceName, url) {
|
|
|
13619
14395
|
}), layer$2({
|
|
13620
14396
|
resource,
|
|
13621
14397
|
url: new URL("/v1/logs", url).href
|
|
13622
|
-
})), provide([layerJson, layer$6]));
|
|
14398
|
+
})), provide$1([layerJson, layer$6]));
|
|
13623
14399
|
}
|
|
13624
14400
|
//#endregion
|
|
13625
14401
|
//#region ../../packages/runtime/src/server.ts
|
|
@@ -43302,7 +44078,7 @@ function clock(seconds$1) {
|
|
|
43302
44078
|
function captionTranscript(input) {
|
|
43303
44079
|
const cues = pipe(input.vtt, replaceAll(/\r\n?/gu, "\n"), split("\n\n"), flatMap$2((block) => {
|
|
43304
44080
|
const lines = split(block, "\n");
|
|
43305
|
-
return pipe(findFirstIndex(lines, includes("-->")), map$
|
|
44081
|
+
return pipe(findFirstIndex(lines, includes("-->")), map$5((index) => {
|
|
43306
44082
|
const times = map$3(pipe(getUnsafe$1(lines, index), split(" --> ")), (time) => reduce(pipe(time, split(" "), headNonEmpty, split(":"), map$3(parse$10), getSomes), 0, (total, part) => total * 60 + part));
|
|
43307
44083
|
return map$3(drop(lines, index + 1), (line) => ({
|
|
43308
44084
|
end: lastNonEmpty(times),
|
|
@@ -43310,25 +44086,25 @@ function captionTranscript(input) {
|
|
|
43310
44086
|
text: pipe(line, replaceAll(/<[^>]+>/gu, ""), replaceAll(" ", " "), replaceAll("<", "<"), replaceAll(">", ">"), replaceAll("&", "&"), trim)
|
|
43311
44087
|
}));
|
|
43312
44088
|
}), getOrElse(empty$11));
|
|
43313
|
-
}), filter$
|
|
43314
|
-
return join$1(map$3(filter$
|
|
44089
|
+
}), filter$5((cue) => isNonEmpty(cue.text)));
|
|
44090
|
+
return join$1(map$3(filter$5(cues, (cue, index) => pipe(get$8(cues, index - 1), match$1({
|
|
43315
44091
|
onNone: () => true,
|
|
43316
44092
|
onSome: (previous) => input.authored || previous.text !== cue.text || previous.end < cue.start
|
|
43317
44093
|
}))), (cue) => `[${clock(cue.start)}] ${cue.text}\n`), "");
|
|
43318
44094
|
}
|
|
43319
44095
|
const spoken = replace$1(/^\[[^\]]+\] /u, "");
|
|
43320
44096
|
function speechOnly(transcript) {
|
|
43321
|
-
const lines = pipe(split(transcript, "\n"), filter$
|
|
44097
|
+
const lines = pipe(split(transcript, "\n"), filter$5(isNonEmpty), dedupeAdjacentWith((left, right) => spoken(left) === spoken(right)), filter$5((line) => {
|
|
43322
44098
|
const words = wordsOf(spoken(line));
|
|
43323
44099
|
return isReadonlyArrayNonEmpty(words) && dedupe(words).length * 3 > words.length;
|
|
43324
44100
|
}));
|
|
43325
44101
|
const words = flatMap$2(lines, (line) => wordsOf(spoken(line)));
|
|
43326
|
-
const seconds = pipe(last$1(lines), flatMap$1(match$2(/^\[(\d+):(\d+)\]/u)), map$
|
|
44102
|
+
const seconds = pipe(last$1(lines), flatMap$1(match$2(/^\[(\d+):(\d+)\]/u)), map$5((match) => [match[1] ?? "0", match[2] ?? "0"]), map$5((parts) => reduce(getSomes(map$3(parts, parse$10)), 0, (total, part) => total * 60 + part)), getOrElse(() => 0));
|
|
43327
44103
|
if (words.length < 8 || words.length * 60 < 40 * max$2(seconds, 15)) return none();
|
|
43328
44104
|
return some$1(join$1(map$3(lines, (line) => `${line}\n`), ""));
|
|
43329
44105
|
}
|
|
43330
44106
|
function wordsOf(text) {
|
|
43331
|
-
return pipe(text, toLowerCase, split(/[^\p{L}\p{N}']+/u), filter$
|
|
44107
|
+
return pipe(text, toLowerCase, split(/[^\p{L}\p{N}']+/u), filter$5(isNonEmpty));
|
|
43332
44108
|
}
|
|
43333
44109
|
//#endregion
|
|
43334
44110
|
//#region src/services/media/schema.ts
|
|
@@ -43360,11 +44136,11 @@ const Transcription = Struct({ chunks: ArraySchema(Struct({
|
|
|
43360
44136
|
const MAX_WHISPER_SECONDS = 7200;
|
|
43361
44137
|
const BLOCKED_ANSWER = /not a bot|requir(?:es|ing) login|login required|CONNECT tunnel failed|ProxyError|HTTP Error (?:403|429|5\d\d)|Requested format is not available|timed out/iu;
|
|
43362
44138
|
const run = fnUntraced(function* (command, args) {
|
|
43363
|
-
const handle = yield* make$
|
|
44139
|
+
const handle = yield* make$43(command, args, {
|
|
43364
44140
|
stderr: "pipe",
|
|
43365
44141
|
stdout: "pipe"
|
|
43366
44142
|
});
|
|
43367
|
-
return yield* all({
|
|
44143
|
+
return yield* all$1({
|
|
43368
44144
|
exitCode: handle.exitCode,
|
|
43369
44145
|
stderr: mkString(decodeText(handle.stderr)),
|
|
43370
44146
|
stdout: mkUint8Array(handle.stdout)
|
|
@@ -43376,7 +44152,7 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
|
|
|
43376
44152
|
const path = yield* Path;
|
|
43377
44153
|
const spawner = yield* ChildProcessSpawner;
|
|
43378
44154
|
const cache = path.join(yield* pipe(String$2("XDG_CACHE_HOME"), withDefault(path.join(yield* String$2("HOME"), ".cache"))), "deslop", "media");
|
|
43379
|
-
const whisper = yield* make$
|
|
44155
|
+
const whisper = yield* make$36(1);
|
|
43380
44156
|
const ytDlpArgs = [
|
|
43381
44157
|
"--js-runtimes",
|
|
43382
44158
|
"node",
|
|
@@ -43436,8 +44212,8 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
|
|
|
43436
44212
|
}
|
|
43437
44213
|
if (samples.length < 16e3) return none();
|
|
43438
44214
|
env.cacheDir = path.join(cache, "models");
|
|
43439
|
-
const spoken = map$
|
|
43440
|
-
const english = contains$
|
|
44215
|
+
const spoken = map$5(input.language, (language) => pipe(language, split("-"), headNonEmpty));
|
|
44216
|
+
const english = contains$2(spoken, "en");
|
|
43441
44217
|
const model = match(english, {
|
|
43442
44218
|
onFalse: () => "onnx-community/whisper-small",
|
|
43443
44219
|
onTrue: () => "onnx-community/whisper-small.en"
|
|
@@ -43462,7 +44238,7 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
|
|
|
43462
44238
|
});
|
|
43463
44239
|
const transcribe = fnUntraced(function* (link, media) {
|
|
43464
44240
|
const work = yield* fs.makeTempDirectoryScoped({ prefix: "deslop-media-" });
|
|
43465
|
-
const language = pipe(fromNullishOr(media.automatic_captions), flatMap$1((captions) => findFirst(keys(captions), endsWith("-orig"))), map$
|
|
44241
|
+
const language = pipe(fromNullishOr(media.automatic_captions), flatMap$1((captions) => findFirst(keys(captions), endsWith("-orig"))), map$5(replace$1(/-orig$/u, "")), orElse$2(() => fromNullishOr(media.language)), getOrElse(() => "en"));
|
|
43466
44242
|
yield* fetch([
|
|
43467
44243
|
...ytDlpArgs,
|
|
43468
44244
|
"--skip-download",
|
|
@@ -43479,8 +44255,8 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
|
|
|
43479
44255
|
link
|
|
43480
44256
|
]);
|
|
43481
44257
|
const captions = `captions.${language}.vtt`;
|
|
43482
|
-
if (contains$
|
|
43483
|
-
authored: exists(fromNullishOr(media.subtitles), (subtitles) => has$
|
|
44258
|
+
if (contains$1(yield* fs.readDirectory(work), captions)) return some$1(captionTranscript({
|
|
44259
|
+
authored: exists(fromNullishOr(media.subtitles), (subtitles) => has$4(subtitles, language)),
|
|
43484
44260
|
vtt: yield* fs.readFileString(path.join(work, captions))
|
|
43485
44261
|
}));
|
|
43486
44262
|
if (!exists(fromNullishOr(media.duration), (seconds) => seconds <= MAX_WHISPER_SECONDS)) {
|
|
@@ -43516,7 +44292,7 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
|
|
|
43516
44292
|
"csv=p=0",
|
|
43517
44293
|
video
|
|
43518
44294
|
]);
|
|
43519
|
-
const seconds = pipe(trim(new TextDecoder().decode(probe.stdout)), parse$10, filter$
|
|
44295
|
+
const seconds = pipe(trim(new TextDecoder().decode(probe.stdout)), parse$10, filter$4((value) => value > 0), getOrElse(() => 6));
|
|
43520
44296
|
const sampled = yield* run("ffmpeg", [
|
|
43521
44297
|
"-v",
|
|
43522
44298
|
"error",
|
|
@@ -43531,7 +44307,7 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
|
|
|
43531
44307
|
path.join(work, "frame-%02d.jpg")
|
|
43532
44308
|
]);
|
|
43533
44309
|
if (sampled.exitCode !== 0) return yield* MediaError.make({ message: `ffmpeg cannot sample the video: ${sampled.stderr}` });
|
|
43534
|
-
return yield* forEach(sort(filter$
|
|
44310
|
+
return yield* forEach(sort(filter$5(yield* fs.readDirectory(work), startsWith("frame-")), String$3), (file) => fs.readFile(path.join(work, file)), { concurrency: "unbounded" });
|
|
43535
44311
|
});
|
|
43536
44312
|
return Media.of({
|
|
43537
44313
|
fileFrames: fn$1("Media.fileFrames")(function* (file) {
|
|
@@ -43576,14 +44352,14 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
|
|
|
43576
44352
|
if (media._type === "playlist") return yield* MediaError.make({ message: "The link holds several videos." });
|
|
43577
44353
|
const details = pipe([
|
|
43578
44354
|
fromNullishOr(media.uploader),
|
|
43579
|
-
map$
|
|
43580
|
-
map$
|
|
43581
|
-
], getSomes, filter$
|
|
44355
|
+
map$5(fromNullishOr(media.upload_date), replace$1(/^(\d{4})(\d{2})(\d{2})$/u, "$1-$2-$3")),
|
|
44356
|
+
map$5(fromNullishOr(media.duration), clock)
|
|
44357
|
+
], getSomes, filter$5(isNonEmpty));
|
|
43582
44358
|
return {
|
|
43583
44359
|
info: join$1(getSomes([
|
|
43584
44360
|
some$1(`# ${media.title}\n\n${join$1(details, ", ")}\n${link}`),
|
|
43585
|
-
pipe(fromNullishOr(media.description), filter$
|
|
43586
|
-
map$
|
|
44361
|
+
pipe(fromNullishOr(media.description), filter$4(isNonEmpty), map$5((description) => `## Description\n\n${description}`)),
|
|
44362
|
+
map$5(fromNullishOr(media.chapters), (chapters) => `## Chapters\n\n${join$1(map$3(chapters, (chapter) => `- [${clock(chapter.start_time)}] ${chapter.title}`), "\n")}`)
|
|
43587
44363
|
]), "\n\n"),
|
|
43588
44364
|
transcript: withProcesses(scoped(transcribe(link, media)))
|
|
43589
44365
|
};
|
|
@@ -90112,18 +90888,18 @@ function withoutTrailingPunctuation(link) {
|
|
|
90112
90888
|
}
|
|
90113
90889
|
function canonicalUrl(link) {
|
|
90114
90890
|
const url = new URL(link);
|
|
90115
|
-
if (contains$
|
|
90891
|
+
if (contains$1(X_HOSTS, url.hostname)) url.hostname = "x.com";
|
|
90116
90892
|
if (sourceFor(url.href) === "Website") for (const key of TRACKING_PARAMETERS) url.searchParams.delete(key);
|
|
90117
90893
|
else url.search = "";
|
|
90118
90894
|
url.hash = "";
|
|
90119
90895
|
return url.href;
|
|
90120
90896
|
}
|
|
90121
90897
|
function captureUrl(text) {
|
|
90122
|
-
return pipe(match$2(URL_PATTERN)(text), flatMap$1(head), map$
|
|
90898
|
+
return pipe(match$2(URL_PATTERN)(text), flatMap$1(head), map$5(withoutTrailingPunctuation), flatMap$1(liftThrowable(canonicalUrl)), getOrUndefined);
|
|
90123
90899
|
}
|
|
90124
90900
|
function sourceFor(url) {
|
|
90125
90901
|
const host = new URL(url).hostname;
|
|
90126
|
-
if (contains$
|
|
90902
|
+
if (contains$1(X_HOSTS, host) || host === "t.co") return "X";
|
|
90127
90903
|
if (host === "tiktok.com" || endsWith(".tiktok.com")(host)) return "TikTok";
|
|
90128
90904
|
return "Website";
|
|
90129
90905
|
}
|
|
@@ -90142,7 +90918,7 @@ function plainText(text) {
|
|
|
90142
90918
|
return pipe(text, replaceAll(/\s+/gu, " "), trim);
|
|
90143
90919
|
}
|
|
90144
90920
|
function normalizeTags(tags) {
|
|
90145
|
-
return pipe(tags, map$3((tag) => pipe(tag, toLowerCase, plainText, replace$1(/^#+/u, ""), replaceAll(" ", "-"))), filter$
|
|
90921
|
+
return pipe(tags, map$3((tag) => pipe(tag, toLowerCase, plainText, replace$1(/^#+/u, ""), replaceAll(" ", "-"))), filter$5(isNonEmpty), dedupe);
|
|
90146
90922
|
}
|
|
90147
90923
|
function tagCounts(notes) {
|
|
90148
90924
|
return pipe(flatMap$2(notes, (note) => note.tags), groupBy((tag) => tag), toEntries, map$3((entry) => ({
|
|
@@ -90151,20 +90927,20 @@ function tagCounts(notes) {
|
|
|
90151
90927
|
})), sort(combine$1(mapInput(flip(Number$1), (entry) => entry.count), mapInput(String$3, (entry) => entry.tag))));
|
|
90152
90928
|
}
|
|
90153
90929
|
function diff(previous, next) {
|
|
90154
|
-
const before = fromIterable$
|
|
90155
|
-
const ids = fromIterable$
|
|
90930
|
+
const before = fromIterable$3(map$3(previous, (note) => [note.id, note]));
|
|
90931
|
+
const ids = fromIterable$2(map$3(next, (note) => note.id));
|
|
90156
90932
|
return {
|
|
90157
|
-
removed: filter$
|
|
90158
|
-
upserted: filter$
|
|
90933
|
+
removed: filter$5(map$3(previous, (note) => note.id), (id) => !has$3(ids, id)),
|
|
90934
|
+
upserted: filter$5(next, (note) => !exists(get$9(before, note.id), (old) => old === note))
|
|
90159
90935
|
};
|
|
90160
90936
|
}
|
|
90161
90937
|
function findNotes(notes, query) {
|
|
90162
|
-
const words = pipe(query, toLowerCase, split(/\s+/u), filter$
|
|
90163
|
-
const tags = pipe(words, filter$
|
|
90164
|
-
const terms = filter$
|
|
90938
|
+
const words = pipe(query, toLowerCase, split(/\s+/u), filter$5(isNonEmpty));
|
|
90939
|
+
const tags = pipe(words, filter$5(startsWith("#")), map$3(slice$2(1)), filter$5(isNonEmpty));
|
|
90940
|
+
const terms = filter$5(words, (word) => !startsWith("#")(word));
|
|
90165
90941
|
if (isReadonlyArrayEmpty(words)) return notes;
|
|
90166
|
-
return filter$
|
|
90167
|
-
if (!every(tags, (tag) => contains$
|
|
90942
|
+
return filter$5(notes, (note) => {
|
|
90943
|
+
if (!every(tags, (tag) => contains$1(note.tags, tag))) return false;
|
|
90168
90944
|
const haystack = pipe([
|
|
90169
90945
|
note.title,
|
|
90170
90946
|
note.summary,
|
|
@@ -90177,7 +90953,7 @@ function findNotes(notes, query) {
|
|
|
90177
90953
|
note.transcript,
|
|
90178
90954
|
note.url,
|
|
90179
90955
|
...note.tags
|
|
90180
|
-
], filter$
|
|
90956
|
+
], filter$5(isNotUndefined), join$1(" "), toLowerCase);
|
|
90181
90957
|
return every(terms, (term) => includes(term)(haystack));
|
|
90182
90958
|
});
|
|
90183
90959
|
}
|
|
@@ -90231,7 +91007,7 @@ const load = fnUntraced(function* (url, read) {
|
|
|
90231
91007
|
if (!every(addresses, isPublic)) return yield* NotesError.make({ message: "The link points to a private network." });
|
|
90232
91008
|
const address = formatIp(headNonEmpty(addresses));
|
|
90233
91009
|
const session = `${yield* nextIntBetween(1e7, 99999999)}`;
|
|
90234
|
-
const proxy = map$
|
|
91010
|
+
const proxy = map$5(yield* Exit, (exit) => sticky(exit, session));
|
|
90235
91011
|
return yield* pipe(get$2(url, { headers: {
|
|
90236
91012
|
accept: "text/html,application/json,image/*",
|
|
90237
91013
|
"accept-language": "en-US,en;q=0.9",
|
|
@@ -90241,7 +91017,7 @@ const load = fnUntraced(function* (url, read) {
|
|
|
90241
91017
|
location: response.headers["location"],
|
|
90242
91018
|
status: response.status,
|
|
90243
91019
|
type: response.headers["content-type"] ?? ""
|
|
90244
|
-
}))), scoped, provide$
|
|
91020
|
+
}))), scoped, provide$3(pipe(layerNodeHttpNoAgent, provide$1(match$1(proxy, {
|
|
90245
91021
|
onNone: () => layerAgentOptions({
|
|
90246
91022
|
autoSelectFamily: false,
|
|
90247
91023
|
lookup: (_hostname, _options, callback) => callback(null, address, 4)
|
|
@@ -90258,7 +91034,7 @@ const load = fnUntraced(function* (url, read) {
|
|
|
90258
91034
|
});
|
|
90259
91035
|
const follow = fnUntraced(function* (url, read, hops) {
|
|
90260
91036
|
const proxied = isSome(yield* Exit);
|
|
90261
|
-
const answer = yield* pipe(load(url, read), filterOrFail((found) => !proxied || !contains$
|
|
91037
|
+
const answer = yield* pipe(load(url, read), filterOrFail((found) => !proxied || !contains$1([
|
|
90262
91038
|
403,
|
|
90263
91039
|
429,
|
|
90264
91040
|
500,
|
|
@@ -90284,14 +91060,14 @@ const follow = fnUntraced(function* (url, read, hops) {
|
|
|
90284
91060
|
})
|
|
90285
91061
|
});
|
|
90286
91062
|
});
|
|
90287
|
-
const decode
|
|
91063
|
+
const decode = fnUntraced(function* (schema, url) {
|
|
90288
91064
|
return yield* pipe(decodeEffect(fromJsonString(schema))((yield* follow(url, api, 0)).body), mapError((cause) => NotesError.make({
|
|
90289
91065
|
cause,
|
|
90290
91066
|
message: "The source answered in an unknown format."
|
|
90291
91067
|
})));
|
|
90292
91068
|
});
|
|
90293
91069
|
const resolve = fnUntraced(function* (url, hops) {
|
|
90294
|
-
if (!contains$
|
|
91070
|
+
if (!contains$1([
|
|
90295
91071
|
"vm.tiktok.com",
|
|
90296
91072
|
"vt.tiktok.com",
|
|
90297
91073
|
"t.co"
|
|
@@ -90304,7 +91080,7 @@ function canonical(url) {
|
|
|
90304
91080
|
return captureUrl(url.href) ?? url.href;
|
|
90305
91081
|
}
|
|
90306
91082
|
const fromOEmbed = fnUntraced(function* (endpoint, url, title) {
|
|
90307
|
-
const embed = yield* decode
|
|
91083
|
+
const embed = yield* decode(OEmbed, new URL(`${endpoint}${encodeURIComponent(url.href)}`));
|
|
90308
91084
|
return Extraction.make({
|
|
90309
91085
|
author: fromUndefinedOr(embed.author_name),
|
|
90310
91086
|
image: fromNullishOr(embed.thumbnail_url),
|
|
@@ -90314,7 +91090,7 @@ const fromOEmbed = fnUntraced(function* (endpoint, url, title) {
|
|
|
90314
91090
|
});
|
|
90315
91091
|
});
|
|
90316
91092
|
const xOEmbed = fnUntraced(function* (url) {
|
|
90317
|
-
const embed = yield* decode
|
|
91093
|
+
const embed = yield* decode(OEmbed, new URL(`https://publish.x.com/oembed?omit_script=true&dnt=true&url=${encodeURIComponent(url.href)}`));
|
|
90318
91094
|
return Extraction.make({
|
|
90319
91095
|
author: fromUndefinedOr(embed.author_name),
|
|
90320
91096
|
image: none(),
|
|
@@ -90326,7 +91102,7 @@ const xOEmbed = fnUntraced(function* (url) {
|
|
|
90326
91102
|
function articleText(article) {
|
|
90327
91103
|
const lines = filterMap(article.content.blocks, (block) => {
|
|
90328
91104
|
const attached = pipe(block.entityRanges, filterMap((range) => fromOption$1(pipe(findFirst(article.content.entityMap, (entity) => entity.key === `${range.key}`), flatMapNullishOr((entity) => entity.value.data.markdown ?? entity.value.data.url)), () => void 0)));
|
|
90329
|
-
const text = pipe([trim(block.text), ...attached], filter$
|
|
91105
|
+
const text = pipe([trim(block.text), ...attached], filter$5(isNonEmpty), join$1(" "));
|
|
90330
91106
|
if (isEmpty$2(text)) return failVoid;
|
|
90331
91107
|
return succeed(pipe(value(block.type), when("header-one", () => `# ${text}`), when("header-two", () => `## ${text}`), when("header-three", () => `### ${text}`), when("unordered-list-item", () => `- ${text}`), when("ordered-list-item", () => `1. ${text}`), when("blockquote", () => `> ${text}`), orElse(() => text)));
|
|
90332
91108
|
});
|
|
@@ -90337,27 +91113,27 @@ function said(post) {
|
|
|
90337
91113
|
return pipe([`**${post.author.name} (@${post.author.screen_name})**: ${plainText(post.text)}`, match$1(fromNullishOr(post.article), {
|
|
90338
91114
|
onNone: () => "",
|
|
90339
91115
|
onSome: articleText
|
|
90340
|
-
})], filter$
|
|
91116
|
+
})], filter$5(isNonEmpty), join$1("\n\n"));
|
|
90341
91117
|
}
|
|
90342
91118
|
function section(title, posts) {
|
|
90343
91119
|
if (isReadonlyArrayEmpty(posts)) return "";
|
|
90344
91120
|
return `## ${title}\n\n${join$1(map$3(posts, said), "\n\n")}`;
|
|
90345
91121
|
}
|
|
90346
91122
|
const xThread = fnUntraced(function* (url) {
|
|
90347
|
-
const id = yield* pipe(match$2(/\/status\/(\d+)/u)(url.pathname), flatMap$1((match) => get$
|
|
90348
|
-
const conversation = yield* decode
|
|
91123
|
+
const id = yield* pipe(match$2(/\/status\/(\d+)/u)(url.pathname), flatMap$1((match) => get$8(match, 1)), fromOption, mapError(() => NotesError.make({ message: "The link names no post." })));
|
|
91124
|
+
const conversation = yield* decode(FxConversation, new URL(`https://api.fxtwitter.com/2/conversation/${id}`));
|
|
90349
91125
|
const status = conversation.status;
|
|
90350
91126
|
const quote = fromNullishOr(status.quote);
|
|
90351
91127
|
const media = flatMap$2([status, ...toArray$1(quote)], (post) => post.media?.all ?? []);
|
|
90352
91128
|
const replies = conversation.replies ?? [];
|
|
90353
|
-
const linked = yield* forEach(pipe(status.raw_text?.facets ?? [], filterMap((facet) => fromOption$1(pipe(fromNullishOr(facet.replacement), flatMap$1(match$2(/(?:x|twitter)\.com\/[^/]+\/status\/(\d+)/u)), flatMap$1((match) => get$
|
|
91129
|
+
const linked = yield* forEach(pipe(status.raw_text?.facets ?? [], filterMap((facet) => fromOption$1(pipe(fromNullishOr(facet.replacement), flatMap$1(match$2(/(?:x|twitter)\.com\/[^/]+\/status\/(\d+)/u)), flatMap$1((match) => get$8(match, 1))), () => void 0)), filter$5((linkedId) => linkedId !== status.id && !exists(quote, (post) => post.id === linkedId)), dedupe, take$1(5)), (linkedId) => option$1(map$1(decode(FxStatus, new URL(`https://api.fxtwitter.com/2/status/${linkedId}`)), (found) => found.status)), { concurrency: "unbounded" });
|
|
90354
91130
|
return Extraction.make({
|
|
90355
91131
|
author: some$1(status.author.name),
|
|
90356
|
-
image: map$
|
|
91132
|
+
image: map$5(head(media), (item) => item.thumbnail_url ?? item.url),
|
|
90357
91133
|
text: pipe([
|
|
90358
|
-
section("Earlier in the conversation", sort(filter$
|
|
91134
|
+
section("Earlier in the conversation", sort(filter$5(conversation.thread ?? [], (post) => post.id !== status.id), byTime)),
|
|
90359
91135
|
plainText(status.text),
|
|
90360
|
-
...pipe(filter$
|
|
91136
|
+
...pipe(filter$5(replies, (post) => post.author.id === status.author.id), sort(byTime), map$3((post) => plainText(post.text))),
|
|
90361
91137
|
match$1(quote, {
|
|
90362
91138
|
onNone: () => "",
|
|
90363
91139
|
onSome: (post) => `Quoting ${said(post)}`
|
|
@@ -90367,8 +91143,8 @@ const xThread = fnUntraced(function* (url) {
|
|
|
90367
91143
|
onSome: articleText
|
|
90368
91144
|
}),
|
|
90369
91145
|
section("Linked posts", getSomes(linked)),
|
|
90370
|
-
section("Replies", take$1(filter$
|
|
90371
|
-
], filter$
|
|
91146
|
+
section("Replies", take$1(filter$5(replies, (post) => post.author.id !== status.author.id), 30))
|
|
91147
|
+
], filter$5(isNonEmpty), join$1("\n\n")),
|
|
90372
91148
|
title: `${status.author.name} on X`,
|
|
90373
91149
|
url: canonical(url),
|
|
90374
91150
|
...pipe(findFirst(media, (item) => item.type === "video" || item.type === "gif"), match$1({
|
|
@@ -90388,43 +91164,43 @@ const tikTokPhotos = fnUntraced(function* (url) {
|
|
|
90388
91164
|
author: some$1(item.author.nickname),
|
|
90389
91165
|
image: head(images),
|
|
90390
91166
|
slides: drop(images, 1),
|
|
90391
|
-
text: pipe([item.imagePost.title, item.desc], filter$
|
|
91167
|
+
text: pipe([item.imagePost.title, item.desc], filter$5(isNotUndefined), map$3(plainText), filter$5(isNonEmpty), join$1("\n")),
|
|
90392
91168
|
title: `${item.author.nickname} on TikTok`,
|
|
90393
91169
|
url: canonical(url)
|
|
90394
91170
|
});
|
|
90395
91171
|
});
|
|
90396
91172
|
const issue = fnUntraced(function* (url, repository, number) {
|
|
90397
|
-
const found = yield* decode
|
|
90398
|
-
const comments = yield* decode
|
|
91173
|
+
const found = yield* decode(GitHubIssue, new URL(`https://api.github.com/repos/${repository}/issues/${number}`));
|
|
91174
|
+
const comments = yield* decode(ArraySchema(GitHubComment), new URL(`https://api.github.com/repos/${repository}/issues/${number}/comments?per_page=100`));
|
|
90399
91175
|
return Extraction.make({
|
|
90400
91176
|
author: some$1(found.user.login),
|
|
90401
91177
|
image: some$1(`https://opengraph.githubassets.com/1/${repository}/issues/${number}`),
|
|
90402
|
-
text: pipe([found, ...comments], map$3((post) => map$
|
|
91178
|
+
text: pipe([found, ...comments], map$3((post) => map$5(fromNullishOr(post.body), (body) => `**${post.user.login}**: ${body}`)), getSomes, prepend$2(`# ${found.title} (${found.state})`), join$1("\n\n")),
|
|
90403
91179
|
title: found.title,
|
|
90404
91180
|
url: canonical(url)
|
|
90405
91181
|
});
|
|
90406
91182
|
});
|
|
90407
91183
|
const repository = fnUntraced(function* (url, name) {
|
|
90408
|
-
const found = yield* decode
|
|
90409
|
-
const readme = yield* pipe(decode
|
|
91184
|
+
const found = yield* decode(GitHubRepo, new URL(`https://api.github.com/repos/${name}`));
|
|
91185
|
+
const readme = yield* pipe(decode(GitHubReadme, new URL(`https://api.github.com/repos/${name}/readme`)), flatMap((file) => follow(new URL(file.download_url), api, 0)), map$1((file) => file.body), option$1);
|
|
90410
91186
|
return Extraction.make({
|
|
90411
91187
|
author: some$1(found.owner.login),
|
|
90412
91188
|
image: some$1(`https://opengraph.githubassets.com/1/${name}`),
|
|
90413
91189
|
text: pipe([
|
|
90414
91190
|
fromNullishOr(found.description),
|
|
90415
|
-
pipe(fromNullishOr(found.topics), filter$
|
|
91191
|
+
pipe(fromNullishOr(found.topics), filter$4(isReadonlyArrayNonEmpty), map$5((topics) => `Topics: ${join$1(topics, ", ")}`)),
|
|
90416
91192
|
fromNullishOr(found.homepage),
|
|
90417
91193
|
readme
|
|
90418
|
-
], getSomes, filter$
|
|
91194
|
+
], getSomes, filter$5(isNonEmpty), join$1("\n\n")),
|
|
90419
91195
|
title: found.full_name,
|
|
90420
91196
|
url: canonical(url)
|
|
90421
91197
|
});
|
|
90422
91198
|
});
|
|
90423
91199
|
const gitHub = fnUntraced(function* (url) {
|
|
90424
|
-
const path = filter$
|
|
91200
|
+
const path = filter$5(split(url.pathname, "/"), isNonEmpty);
|
|
90425
91201
|
const name = join$1(take$1(path, 2), "/");
|
|
90426
91202
|
if (path.length === 2) return yield* repository(url, name);
|
|
90427
|
-
return yield* pipe(all$
|
|
91203
|
+
return yield* pipe(all$2([get$8(path, 2), get$8(path, 3)]), filter$4((parts) => parts[0] === "issues" || parts[0] === "pull"), match$1({
|
|
90428
91204
|
onNone: () => fail$1(NotesError.make({ message: "The GitHub page is neither a repository nor an issue." })),
|
|
90429
91205
|
onSome: (parts) => issue(url, name, parts[1])
|
|
90430
91206
|
}));
|
|
@@ -90440,7 +91216,7 @@ function markdown($, node, base) {
|
|
|
90440
91216
|
"h4",
|
|
90441
91217
|
"h5",
|
|
90442
91218
|
"h6"
|
|
90443
|
-
], (heading) => heading === node.tagName), map$
|
|
91219
|
+
], (heading) => heading === node.tagName), map$5((index) => `\n\n${repeat$1(index + 1)("#")} ${trim(inner)}\n\n`), getOrElse(() => element($, {
|
|
90444
91220
|
base,
|
|
90445
91221
|
inner,
|
|
90446
91222
|
node,
|
|
@@ -90455,10 +91231,10 @@ function element($, input) {
|
|
|
90455
91231
|
onTrue: () => `${$(input.node).index() + 1}.`
|
|
90456
91232
|
});
|
|
90457
91233
|
return `\n${repeat$1($(input.node).parents("ul, ol").length - 1)(" ")}${marker} ${text}`;
|
|
90458
|
-
}), when("pre", () => `\n\n\`\`\`\n${$(input.node).text()}\n\`\`\`\n\n`), when("code", () => `\`${text}\``), when("br", () => "\n"), when("tr", () => `\n${text}`), when((name) => name === "td" || name === "th", () => `${text} | `), when("a", () => pipe(fromNullishOr($(input.node).attr("href")), flatMap$1(liftThrowable((href) => new URL(href, input.base))), filter$
|
|
91234
|
+
}), when("pre", () => `\n\n\`\`\`\n${$(input.node).text()}\n\`\`\`\n\n`), when("code", () => `\`${text}\``), when("br", () => "\n"), when("tr", () => `\n${text}`), when((name) => name === "td" || name === "th", () => `${text} | `), when("a", () => pipe(fromNullishOr($(input.node).attr("href")), flatMap$1(liftThrowable((href) => new URL(href, input.base))), filter$4((link) => (link.protocol === "https:" || link.protocol === "http:") && isNonEmpty(text)), match$1({
|
|
90459
91235
|
onNone: () => input.inner,
|
|
90460
91236
|
onSome: (link) => `[${text}](${link.href})`
|
|
90461
|
-
}))), when((name) => contains$
|
|
91237
|
+
}))), when((name) => contains$1(BLOCK_TAGS, name), () => `\n\n${text}\n\n`), orElse(() => input.inner));
|
|
90462
91238
|
}
|
|
90463
91239
|
function pageText(html, url) {
|
|
90464
91240
|
const $ = load$1(html);
|
|
@@ -90474,15 +91250,15 @@ function pageText(html, url) {
|
|
|
90474
91250
|
onTrue: () => part
|
|
90475
91251
|
})), join$1("```"), trim);
|
|
90476
91252
|
return Extraction.make({
|
|
90477
|
-
author: pipe(fromUndefinedOr($("meta[property=\"og:site_name\"]").attr("content")), map$
|
|
91253
|
+
author: pipe(fromUndefinedOr($("meta[property=\"og:site_name\"]").attr("content")), map$5(plainText), filter$4(isNonEmpty), orElseSome(() => url.hostname)),
|
|
90478
91254
|
image: pipe(fromNullishOr($("meta[property=\"og:image\"]").attr("content") ?? $("meta[name=\"twitter:image\"]").attr("content")), flatMap$1(liftThrowable((image) => new URL(image, url).href))),
|
|
90479
|
-
text: pipe([map$
|
|
91255
|
+
text: pipe([map$5(fromUndefinedOr(description), plainText), some$1(body)], getSomes, filter$5(isNonEmpty), join$1("\n\n")),
|
|
90480
91256
|
title: plainText($("meta[property=\"og:title\"]").attr("content") ?? $("title").first().text()),
|
|
90481
91257
|
url: canonical(url)
|
|
90482
91258
|
});
|
|
90483
91259
|
}
|
|
90484
91260
|
const reader = fnUntraced(function* (url) {
|
|
90485
|
-
const answer = yield* pipe(decode
|
|
91261
|
+
const answer = yield* pipe(decode(Reader, new URL(`https://r.jina.ai/${url.href}`)), timeLimit("30 seconds", "The reader took too long."));
|
|
90486
91262
|
if (CHALLENGE.test(answer.data.content) || isEmpty$2(trim(answer.data.content))) return yield* NotesError.make({ message: "The site blocks automated reading." });
|
|
90487
91263
|
return Extraction.make({
|
|
90488
91264
|
author: some$1(url.hostname),
|
|
@@ -90535,7 +91311,7 @@ var Sources = class Sources extends Service()("@deslop/stash/services/notes/lib/
|
|
|
90535
91311
|
try: () => new URL(link)
|
|
90536
91312
|
});
|
|
90537
91313
|
const image = yield* follow(url, readBytes, 0);
|
|
90538
|
-
const type = yield* pipe(image.type, split(";"), head, map$
|
|
91314
|
+
const type = yield* pipe(image.type, split(";"), head, map$5(trim), filter$4(is$4(ImageType)), fromOption, mapError(() => NotesError.make({ message: "The preview is not a JPEG, PNG, WebP or GIF image." })));
|
|
90539
91315
|
return {
|
|
90540
91316
|
bytes: image.body,
|
|
90541
91317
|
type
|
|
@@ -90548,328 +91324,6 @@ var Sources = class Sources extends Service()("@deslop/stash/services/notes/lib/
|
|
|
90548
91324
|
}));
|
|
90549
91325
|
};
|
|
90550
91326
|
//#endregion
|
|
90551
|
-
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/encoding/Sse.js
|
|
90552
|
-
const SseErrorTypeId = "~effect/encoding/Sse/SseError";
|
|
90553
|
-
/**
|
|
90554
|
-
* Error reason raised when pending Server-Sent Events state exceeds the
|
|
90555
|
-
* configured maximum size.
|
|
90556
|
-
*
|
|
90557
|
-
* @stability unstable
|
|
90558
|
-
* @category errors
|
|
90559
|
-
* @since 4.0.0
|
|
90560
|
-
*/
|
|
90561
|
-
var EventTooLarge = class extends (/*#__PURE__*/ TaggedError("EventTooLarge")) {
|
|
90562
|
-
get message() {
|
|
90563
|
-
return `Pending SSE event exceeded the maximum size of ${this.maxEventSize}`;
|
|
90564
|
-
}
|
|
90565
|
-
};
|
|
90566
|
-
/**
|
|
90567
|
-
* Error raised when decoding a Server-Sent Events stream fails.
|
|
90568
|
-
*
|
|
90569
|
-
* @stability unstable
|
|
90570
|
-
* @category errors
|
|
90571
|
-
* @since 4.0.0
|
|
90572
|
-
*/
|
|
90573
|
-
var SseError = class extends (/*#__PURE__*/ TaggedError("SseError")) {
|
|
90574
|
-
/**
|
|
90575
|
-
* Marks this value as an SSE decoding error.
|
|
90576
|
-
*
|
|
90577
|
-
* @stability unstable
|
|
90578
|
-
* @since 4.0.0
|
|
90579
|
-
*/
|
|
90580
|
-
[SseErrorTypeId] = SseErrorTypeId;
|
|
90581
|
-
/**
|
|
90582
|
-
* Delegates the public message to the underlying SSE error reason.
|
|
90583
|
-
*
|
|
90584
|
-
* @stability unstable
|
|
90585
|
-
* @since 4.0.0
|
|
90586
|
-
*/
|
|
90587
|
-
get message() {
|
|
90588
|
-
return this.reason.message;
|
|
90589
|
-
}
|
|
90590
|
-
};
|
|
90591
|
-
const defaultMaxEventSize = 10485760;
|
|
90592
|
-
/**
|
|
90593
|
-
* Creates a channel that parses Server-Sent Events text chunks into `Event` values.
|
|
90594
|
-
*
|
|
90595
|
-
* **Details**
|
|
90596
|
-
*
|
|
90597
|
-
* SSE `retry` directives are emitted as `Retry` failures so callers can
|
|
90598
|
-
* reconnect with the requested delay.
|
|
90599
|
-
*
|
|
90600
|
-
* @stability unstable
|
|
90601
|
-
* @category decoding
|
|
90602
|
-
* @since 4.0.0
|
|
90603
|
-
*/
|
|
90604
|
-
const decode = (options) => fromTransform((upstream, _scope) => sync(() => {
|
|
90605
|
-
let buffer = [];
|
|
90606
|
-
let retry;
|
|
90607
|
-
const parser = makeParser((event) => {
|
|
90608
|
-
if (event._tag === "Retry") retry = event;
|
|
90609
|
-
else buffer.push(event);
|
|
90610
|
-
}, options);
|
|
90611
|
-
const pump = flatMap(upstream, (arr) => {
|
|
90612
|
-
for (let i = 0; i < arr.length; i++) {
|
|
90613
|
-
const error = parser.feed(arr[i]);
|
|
90614
|
-
if (error !== void 0) return fail$1(error);
|
|
90615
|
-
}
|
|
90616
|
-
return void_;
|
|
90617
|
-
});
|
|
90618
|
-
return suspend(function loop() {
|
|
90619
|
-
if (isArrayNonEmpty(buffer)) {
|
|
90620
|
-
const out = buffer;
|
|
90621
|
-
buffer = [];
|
|
90622
|
-
return succeed$1(out);
|
|
90623
|
-
} else if (retry) return fail$1(retry);
|
|
90624
|
-
return flatMap(pump, loop);
|
|
90625
|
-
});
|
|
90626
|
-
}));
|
|
90627
|
-
/**
|
|
90628
|
-
* Creates an SSE decoder channel that decodes each parsed event with a schema.
|
|
90629
|
-
*
|
|
90630
|
-
* **Details**
|
|
90631
|
-
*
|
|
90632
|
-
* The schema receives `{ event, data, id? }`, with string `data`. Absent IDs are
|
|
90633
|
-
* omitted, even with default options: use `Schema.optional(Schema.String)`, not
|
|
90634
|
-
* `Schema.UndefinedOr(Schema.String)`, to accept events without an ID.
|
|
90635
|
-
*
|
|
90636
|
-
* With `onExcessProperty: "error"`, declare `event` (default: `"message"`) and
|
|
90637
|
-
* `id` if the stream carries IDs, including inherited IDs.
|
|
90638
|
-
*
|
|
90639
|
-
* @stability unstable
|
|
90640
|
-
* @category decoding
|
|
90641
|
-
* @since 4.0.0
|
|
90642
|
-
*/
|
|
90643
|
-
const decodeSchema = (schema, options, parseOptions) => pipeTo(decode(options), decode$2(Event$1.pipe(decodeTo(schema, transformEvent)), parseOptions)());
|
|
90644
|
-
/**
|
|
90645
|
-
* Creates an SSE decoder channel that JSON-decodes each event `data` field with a schema.
|
|
90646
|
-
*
|
|
90647
|
-
* **Details**
|
|
90648
|
-
*
|
|
90649
|
-
* The output preserves the SSE `event` name and optional `id` while replacing
|
|
90650
|
-
* `data` with the decoded value.
|
|
90651
|
-
*
|
|
90652
|
-
* @stability unstable
|
|
90653
|
-
* @category decoding
|
|
90654
|
-
* @since 4.0.0
|
|
90655
|
-
*/
|
|
90656
|
-
const decodeDataSchema = (schema, options) => {
|
|
90657
|
-
const eventSchema = Struct({
|
|
90658
|
-
...EventEncoded.fields,
|
|
90659
|
-
data: fromJsonString(schema)
|
|
90660
|
-
});
|
|
90661
|
-
return pipeTo(decode(options), map$5(decode$2(eventSchema)(), map$3((event) => ({
|
|
90662
|
-
...event,
|
|
90663
|
-
id: event.id
|
|
90664
|
-
}))));
|
|
90665
|
-
};
|
|
90666
|
-
/**
|
|
90667
|
-
* Creates a stateful Server-Sent Events parser.
|
|
90668
|
-
*
|
|
90669
|
-
* **Details**
|
|
90670
|
-
*
|
|
90671
|
-
* Call `feed` with text chunks to parse `Event` and `Retry` values through the
|
|
90672
|
-
* callback, and call `reset` to clear any buffered event state. `feed` returns
|
|
90673
|
-
* an `SseError` if the pending event exceeds `maxEventSize`.
|
|
90674
|
-
*
|
|
90675
|
-
* @stability unstable
|
|
90676
|
-
* @category decoding
|
|
90677
|
-
* @since 4.0.0
|
|
90678
|
-
*/
|
|
90679
|
-
function makeParser(onParse, options) {
|
|
90680
|
-
const maxEventSize = options?.maxEventSize ?? defaultMaxEventSize;
|
|
90681
|
-
const dispatchEmptyNamedEvents = options?.dispatchEmptyNamedEvents === true;
|
|
90682
|
-
let isFirstChunk;
|
|
90683
|
-
let pending;
|
|
90684
|
-
let pendingLength;
|
|
90685
|
-
let discardTrailingNewline;
|
|
90686
|
-
let generation = 0;
|
|
90687
|
-
let lastEventId;
|
|
90688
|
-
let eventName;
|
|
90689
|
-
let data;
|
|
90690
|
-
reset();
|
|
90691
|
-
return {
|
|
90692
|
-
feed,
|
|
90693
|
-
reset
|
|
90694
|
-
};
|
|
90695
|
-
function reset() {
|
|
90696
|
-
generation++;
|
|
90697
|
-
isFirstChunk = true;
|
|
90698
|
-
pending = [];
|
|
90699
|
-
pendingLength = 0;
|
|
90700
|
-
discardTrailingNewline = false;
|
|
90701
|
-
lastEventId = void 0;
|
|
90702
|
-
eventName = void 0;
|
|
90703
|
-
data = "";
|
|
90704
|
-
}
|
|
90705
|
-
function feed(chunk) {
|
|
90706
|
-
if (isFirstChunk && chunk.startsWith(BOM)) chunk = chunk.slice(BOM.length);
|
|
90707
|
-
isFirstChunk = false;
|
|
90708
|
-
const length = chunk.length;
|
|
90709
|
-
const currentGeneration = generation;
|
|
90710
|
-
let position = 0;
|
|
90711
|
-
while (position < length) {
|
|
90712
|
-
if (discardTrailingNewline) {
|
|
90713
|
-
discardTrailingNewline = false;
|
|
90714
|
-
if (chunk.charCodeAt(position) === LF) {
|
|
90715
|
-
++position;
|
|
90716
|
-
continue;
|
|
90717
|
-
}
|
|
90718
|
-
}
|
|
90719
|
-
let lineEnd = position;
|
|
90720
|
-
while (lineEnd < length) {
|
|
90721
|
-
const code = chunk.charCodeAt(lineEnd);
|
|
90722
|
-
if (code === CR || code === LF) break;
|
|
90723
|
-
++lineEnd;
|
|
90724
|
-
}
|
|
90725
|
-
if (lineEnd === length) {
|
|
90726
|
-
pending.push(chunk.slice(position));
|
|
90727
|
-
pendingLength += length - position;
|
|
90728
|
-
break;
|
|
90729
|
-
}
|
|
90730
|
-
discardTrailingNewline = chunk.charCodeAt(lineEnd) === CR;
|
|
90731
|
-
let line = chunk.slice(position, lineEnd);
|
|
90732
|
-
if (pending.length > 0) {
|
|
90733
|
-
pending.push(line);
|
|
90734
|
-
line = pending.join("");
|
|
90735
|
-
pending = [];
|
|
90736
|
-
pendingLength = 0;
|
|
90737
|
-
}
|
|
90738
|
-
parseLine(line);
|
|
90739
|
-
if (generation !== currentGeneration) return;
|
|
90740
|
-
position = lineEnd + 1;
|
|
90741
|
-
}
|
|
90742
|
-
if (pendingLength + data.length > maxEventSize) {
|
|
90743
|
-
const error = new SseError({ reason: new EventTooLarge({ maxEventSize }) });
|
|
90744
|
-
reset();
|
|
90745
|
-
return error;
|
|
90746
|
-
}
|
|
90747
|
-
}
|
|
90748
|
-
function parseLine(line) {
|
|
90749
|
-
if (line.length === 0) {
|
|
90750
|
-
const named = eventName !== void 0 && eventName !== "";
|
|
90751
|
-
const event = eventName || "message";
|
|
90752
|
-
const eventData = data;
|
|
90753
|
-
eventName = void 0;
|
|
90754
|
-
data = "";
|
|
90755
|
-
if (eventData.length > 0 || dispatchEmptyNamedEvents && named) onParse({
|
|
90756
|
-
_tag: "Event",
|
|
90757
|
-
id: lastEventId,
|
|
90758
|
-
event,
|
|
90759
|
-
data: eventData.slice(0, -1)
|
|
90760
|
-
});
|
|
90761
|
-
return;
|
|
90762
|
-
}
|
|
90763
|
-
const colon = line.indexOf(":");
|
|
90764
|
-
let field = line;
|
|
90765
|
-
let value = "";
|
|
90766
|
-
if (colon >= 0) {
|
|
90767
|
-
field = line.slice(0, colon);
|
|
90768
|
-
value = line.slice(line.charCodeAt(colon + 1) === SPACE ? colon + 2 : colon + 1);
|
|
90769
|
-
}
|
|
90770
|
-
if (field === "data") data += value + "\n";
|
|
90771
|
-
else if (field === "event") eventName = value;
|
|
90772
|
-
else if (field === "id" && !value.includes("\0")) lastEventId = value;
|
|
90773
|
-
else if (field === "retry" && /^\d+$/.test(value)) onParse(new Retry({
|
|
90774
|
-
duration: millis(parseInt(value, 10)),
|
|
90775
|
-
lastEventId
|
|
90776
|
-
}));
|
|
90777
|
-
}
|
|
90778
|
-
}
|
|
90779
|
-
const BOM = "";
|
|
90780
|
-
const LF = 10;
|
|
90781
|
-
const CR = 13;
|
|
90782
|
-
const SPACE = 32;
|
|
90783
|
-
/**
|
|
90784
|
-
* Schema for the untagged Server-Sent Events payload shape containing an optional `id`, `event`, and string `data` fields.
|
|
90785
|
-
*
|
|
90786
|
-
* @stability unstable
|
|
90787
|
-
* @category models
|
|
90788
|
-
* @since 4.0.0
|
|
90789
|
-
*/
|
|
90790
|
-
const EventEncoded = /*#__PURE__*/ Struct({
|
|
90791
|
-
id: /*#__PURE__*/ optional$1(String$1),
|
|
90792
|
-
event: String$1,
|
|
90793
|
-
data: String$1
|
|
90794
|
-
});
|
|
90795
|
-
/**
|
|
90796
|
-
* Schema for the tagged Server-Sent Events message model that adds `_tag: "Event"` to the event name, optional event ID, and string data payload.
|
|
90797
|
-
*
|
|
90798
|
-
* @stability unstable
|
|
90799
|
-
* @category models
|
|
90800
|
-
* @since 4.0.0
|
|
90801
|
-
*/
|
|
90802
|
-
const Event$1 = /*#__PURE__*/ Struct({
|
|
90803
|
-
_tag: /*#__PURE__*/ tag("Event"),
|
|
90804
|
-
id: /*#__PURE__*/ UndefinedOr(String$1),
|
|
90805
|
-
event: String$1,
|
|
90806
|
-
data: String$1
|
|
90807
|
-
});
|
|
90808
|
-
/**
|
|
90809
|
-
* Schema for transforming untagged SSE event payloads into tagged `Event`
|
|
90810
|
-
* models.
|
|
90811
|
-
*
|
|
90812
|
-
* @stability unstable
|
|
90813
|
-
* @category models
|
|
90814
|
-
* @since 4.0.0
|
|
90815
|
-
*/
|
|
90816
|
-
const transformEvent = /*#__PURE__*/ transform$1({
|
|
90817
|
-
decode: (event) => event.id === void 0 ? {
|
|
90818
|
-
event: event.event,
|
|
90819
|
-
data: event.data
|
|
90820
|
-
} : {
|
|
90821
|
-
id: event.id,
|
|
90822
|
-
event: event.event,
|
|
90823
|
-
data: event.data
|
|
90824
|
-
},
|
|
90825
|
-
encode: (event) => ({
|
|
90826
|
-
_tag: "Event",
|
|
90827
|
-
id: event.id,
|
|
90828
|
-
event: event.event ?? "message",
|
|
90829
|
-
data: event.data
|
|
90830
|
-
})
|
|
90831
|
-
});
|
|
90832
|
-
const RetryTypeId = "~effect/encoding/Sse/Retry";
|
|
90833
|
-
/**
|
|
90834
|
-
* Represents a Server-Sent Events retry directive.
|
|
90835
|
-
*
|
|
90836
|
-
* **Details**
|
|
90837
|
-
*
|
|
90838
|
-
* Decoders surface this value as a failure to request reconnection after
|
|
90839
|
-
* `duration`; encoders serialize an upstream `Retry` failure as a `retry:` line.
|
|
90840
|
-
*
|
|
90841
|
-
* @stability unstable
|
|
90842
|
-
* @category models
|
|
90843
|
-
* @since 4.0.0
|
|
90844
|
-
*/
|
|
90845
|
-
var Retry = class Retry extends (/*#__PURE__*/ TaggedClass("Retry")) {
|
|
90846
|
-
/**
|
|
90847
|
-
* Marks this value as an SSE retry directive for runtime guards.
|
|
90848
|
-
*
|
|
90849
|
-
* @stability unstable
|
|
90850
|
-
* @since 4.0.0
|
|
90851
|
-
*/
|
|
90852
|
-
[RetryTypeId] = RetryTypeId;
|
|
90853
|
-
/**
|
|
90854
|
-
* Returns `true` when the value is an SSE retry directive.
|
|
90855
|
-
*
|
|
90856
|
-
* @stability unstable
|
|
90857
|
-
* @since 4.0.0
|
|
90858
|
-
*/
|
|
90859
|
-
static is(u) {
|
|
90860
|
-
return hasProperty(u, RetryTypeId);
|
|
90861
|
-
}
|
|
90862
|
-
/**
|
|
90863
|
-
* Separates SSE retry directives from regular event values.
|
|
90864
|
-
*
|
|
90865
|
-
* @stability unstable
|
|
90866
|
-
* @since 4.0.0
|
|
90867
|
-
*/
|
|
90868
|
-
static filter(u) {
|
|
90869
|
-
return Retry.is(u) ? succeed(u) : fail(u);
|
|
90870
|
-
}
|
|
90871
|
-
};
|
|
90872
|
-
//#endregion
|
|
90873
91327
|
//#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.5_effect@4.0.5/node_modules/@effect/ai-anthropic/dist/AnthropicConfig.js
|
|
90874
91328
|
/**
|
|
90875
91329
|
* The `AnthropicConfig` module lets a workflow temporarily customize the HTTP
|
|
@@ -94399,9 +94853,9 @@ const HttpRequestDetails$1 = /*#__PURE__*/ Struct({
|
|
|
94399
94853
|
"QUERY"
|
|
94400
94854
|
]),
|
|
94401
94855
|
url: String$1,
|
|
94402
|
-
urlParams: ArraySchema(Tuple([String$1, Union([String$1, Redacted(String$1)])])),
|
|
94856
|
+
urlParams: ArraySchema(Tuple([String$1, Union([String$1, Redacted$1(String$1)])])),
|
|
94403
94857
|
hash: optional$1(String$1),
|
|
94404
|
-
headers: Record$1(String$1, Union([String$1, Redacted(String$1)]))
|
|
94858
|
+
headers: Record$1(String$1, Union([String$1, Redacted$1(String$1)]))
|
|
94405
94859
|
}).annotate({ identifier: "HttpRequestDetails" });
|
|
94406
94860
|
/**
|
|
94407
94861
|
* Schema for HTTP responses from an AI provider.
|
|
@@ -94427,7 +94881,7 @@ const HttpRequestDetails$1 = /*#__PURE__*/ Struct({
|
|
|
94427
94881
|
*/
|
|
94428
94882
|
const HttpResponseDetails$1 = /*#__PURE__*/ Struct({
|
|
94429
94883
|
status: Int,
|
|
94430
|
-
headers: Record$1(String$1, Union([String$1, Redacted(String$1)]))
|
|
94884
|
+
headers: Record$1(String$1, Union([String$1, Redacted$1(String$1)]))
|
|
94431
94885
|
}).annotate({ identifier: "HttpResponseDetails" });
|
|
94432
94886
|
const ReasonTypeId = "~effect/ai/AiError/Reason";
|
|
94433
94887
|
const providerMetadataWithDefaults = () => ProviderMetadata$1.pipe(withConstructorDefault(succeed$1({})), withDecodingDefault(succeed$1({})));
|
|
@@ -96473,7 +96927,7 @@ const Strict = /*#__PURE__*/ Reference("effect/ai/Tool/Strict", { defaultValue:
|
|
|
96473
96927
|
* @category getters
|
|
96474
96928
|
* @since 4.0.0
|
|
96475
96929
|
*/
|
|
96476
|
-
const getStrictMode = (tool) => get$
|
|
96930
|
+
const getStrictMode = (tool) => get$6(tool.annotations, Strict);
|
|
96477
96931
|
const suspectProtoRx = /"__proto__"\s*:/;
|
|
96478
96932
|
const suspectConstructorRx = /"constructor"\s*:/;
|
|
96479
96933
|
function _parse(text) {
|
|
@@ -96593,7 +97047,7 @@ function toCodec(schema) {
|
|
|
96593
97047
|
const encoded = toEncoded(jsonCodec.ast);
|
|
96594
97048
|
const from = transform(encoded);
|
|
96595
97049
|
if (from === encoded) return jsonCodec.ast === schema.ast ? schema : jsonCodec;
|
|
96596
|
-
return make$
|
|
97050
|
+
return make$44(decodeTo$1(from, jsonCodec.ast, passthrough$1()));
|
|
96597
97051
|
}
|
|
96598
97052
|
function transform(root) {
|
|
96599
97053
|
let cache;
|
|
@@ -96723,7 +97177,7 @@ function compilerAnnotations(annotations) {
|
|
|
96723
97177
|
}
|
|
96724
97178
|
function optionalToNullable(type) {
|
|
96725
97179
|
return decodeTo$1(new Union$1([type, null_]), optionalKey$1(type), transformOptional({
|
|
96726
|
-
decode: filter$
|
|
97180
|
+
decode: filter$4(isNotNull),
|
|
96727
97181
|
encode: orElseSome(() => null)
|
|
96728
97182
|
}));
|
|
96729
97183
|
}
|
|
@@ -97530,7 +97984,7 @@ const fromResponseParts = (parts) => {
|
|
|
97530
97984
|
break;
|
|
97531
97985
|
case "file":
|
|
97532
97986
|
assistantParts.push(makePart$1("file", {
|
|
97533
|
-
data: encode(part.data),
|
|
97987
|
+
data: encode$1(part.data),
|
|
97534
97988
|
mediaType: part.mediaType,
|
|
97535
97989
|
options: part.metadata
|
|
97536
97990
|
}));
|
|
@@ -98341,7 +98795,7 @@ const TypeId$1 = "~effect/ai/Toolkit";
|
|
|
98341
98795
|
* @since 4.0.0
|
|
98342
98796
|
*/
|
|
98343
98797
|
const FailureOrigin = /*#__PURE__*/ Reference("effect/ai/Toolkit/FailureOrigin", { defaultValue: () => "result" });
|
|
98344
|
-
const failureCause = (error, origin) => annotate(fail$4(error), make$
|
|
98798
|
+
const failureCause = (error, origin) => annotate(fail$4(error), make$40(FailureOrigin, origin));
|
|
98345
98799
|
const Proto = {
|
|
98346
98800
|
.../*#__PURE__*/ Prototype({
|
|
98347
98801
|
label: "Toolkit",
|
|
@@ -98413,7 +98867,7 @@ const Proto = {
|
|
|
98413
98867
|
})));
|
|
98414
98868
|
}
|
|
98415
98869
|
const decodedParams = decodedParamsResult.success;
|
|
98416
|
-
const queue = yield* make$
|
|
98870
|
+
const queue = yield* make$38();
|
|
98417
98871
|
const context = {
|
|
98418
98872
|
toolCallId,
|
|
98419
98873
|
preliminary: (result) => asVoid(offer(queue, {
|
|
@@ -98479,7 +98933,7 @@ const Proto = {
|
|
|
98479
98933
|
context: services
|
|
98480
98934
|
});
|
|
98481
98935
|
}
|
|
98482
|
-
return makeUnsafe$
|
|
98936
|
+
return makeUnsafe$4(context$1);
|
|
98483
98937
|
});
|
|
98484
98938
|
},
|
|
98485
98939
|
toLayer(build) {
|
|
@@ -99090,11 +99544,11 @@ const make$1 = /*#__PURE__*/ fnUntraced(function* (params) {
|
|
|
99090
99544
|
return void_;
|
|
99091
99545
|
}) : identity)));
|
|
99092
99546
|
}
|
|
99093
|
-
const queue = yield* make$
|
|
99547
|
+
const queue = yield* make$38();
|
|
99094
99548
|
const deferredFinishParts = [];
|
|
99095
99549
|
if (preResolvedStreamParts.length > 0) yield* offerAll(queue, preResolvedStreamParts);
|
|
99096
99550
|
const toolCallFibers = yield* make$20();
|
|
99097
|
-
const toolCallSemaphore = concurrency === "unbounded" ? void 0 : yield* make$
|
|
99551
|
+
const toolCallSemaphore = concurrency === "unbounded" ? void 0 : yield* make$36(concurrency);
|
|
99098
99552
|
const pendingToolCalls = /* @__PURE__ */ new Map();
|
|
99099
99553
|
const bufferedToolCalls = [];
|
|
99100
99554
|
const handleToolCall = fnUntraced(function* (part) {
|
|
@@ -99703,7 +100157,7 @@ const prepareMessages = /*#__PURE__*/ fnUntraced(function* ({ betas, capabilitie
|
|
|
99703
100157
|
} : {
|
|
99704
100158
|
type: "base64",
|
|
99705
100159
|
media_type: mediaType,
|
|
99706
|
-
data: typeof part.data === "string" ? part.data.replace(/^data:[^;]+;base64,/, "") : encode(part.data)
|
|
100160
|
+
data: typeof part.data === "string" ? part.data.replace(/^data:[^;]+;base64,/, "") : encode$1(part.data)
|
|
99707
100161
|
};
|
|
99708
100162
|
content.push({
|
|
99709
100163
|
type: "image",
|
|
@@ -99720,7 +100174,7 @@ const prepareMessages = /*#__PURE__*/ fnUntraced(function* ({ betas, capabilitie
|
|
|
99720
100174
|
} : part.mediaType === "application/pdf" ? {
|
|
99721
100175
|
type: "base64",
|
|
99722
100176
|
media_type: "application/pdf",
|
|
99723
|
-
data: typeof part.data === "string" ? part.data : encode(part.data)
|
|
100177
|
+
data: typeof part.data === "string" ? part.data : encode$1(part.data)
|
|
99724
100178
|
} : {
|
|
99725
100179
|
type: "text",
|
|
99726
100180
|
media_type: "text/plain",
|
|
@@ -101203,7 +101657,7 @@ const INSTRUCTIONS = pipe([
|
|
|
101203
101657
|
], join$1(" "));
|
|
101204
101658
|
var Organizer = class Organizer extends Service()("@deslop/stash/services/notes/lib/organization/Organizer") {
|
|
101205
101659
|
static layer = effect(this, gen(function* () {
|
|
101206
|
-
const key = yield* option(Redacted
|
|
101660
|
+
const key = yield* option(Redacted("ANTHROPIC_API_KEY"));
|
|
101207
101661
|
const model = yield* pipe(make({
|
|
101208
101662
|
config: {
|
|
101209
101663
|
max_tokens: 32e3,
|
|
@@ -101222,7 +101676,7 @@ var Organizer = class Organizer extends Service()("@deslop/stash/services/notes/
|
|
|
101222
101676
|
`Link title: ${input.note.title}`,
|
|
101223
101677
|
`Saved text: ${input.note.text}`,
|
|
101224
101678
|
`Link content: ${slice$2(0, 15e4)(input.note.content)}`,
|
|
101225
|
-
`Video transcript: ${pipe(fromUndefinedOr(input.note.transcript), map$
|
|
101679
|
+
`Video transcript: ${pipe(fromUndefinedOr(input.note.transcript), map$5(slice$2(0, 15e4)), getOrElse(() => "none"))}`
|
|
101226
101680
|
], "\n");
|
|
101227
101681
|
const response = yield* model.generateObject({
|
|
101228
101682
|
prompt: [{
|
|
@@ -101246,7 +101700,7 @@ var Organizer = class Organizer extends Service()("@deslop/stash/services/notes/
|
|
|
101246
101700
|
tags: normalizeTags(response.value.tags)
|
|
101247
101701
|
};
|
|
101248
101702
|
}, timeout("5 minutes"), mapError((cause) => pipe(liftPredicate(cause, is$4(NotesError)), getOrElse(() => NotesError.make({
|
|
101249
|
-
cause: make$
|
|
101703
|
+
cause: make$45(cause),
|
|
101250
101704
|
message: "AI tagging failed; the note is saved as it is."
|
|
101251
101705
|
}))))) });
|
|
101252
101706
|
}));
|
|
@@ -101291,7 +101745,7 @@ const openStore = fnUntraced(function* (path) {
|
|
|
101291
101745
|
//#region src/services/notes/service.ts
|
|
101292
101746
|
function withWords(note, text) {
|
|
101293
101747
|
const known = pipe(note.text, toLowerCase, split(/\s+/u));
|
|
101294
|
-
const added = pipe(commentFor(text), split(" "), filter$
|
|
101748
|
+
const added = pipe(commentFor(text), split(" "), filter$5((word) => isNonEmpty(word) && !contains$1(known, toLowerCase(word))));
|
|
101295
101749
|
if (isReadonlyArrayEmpty(added)) return note;
|
|
101296
101750
|
return {
|
|
101297
101751
|
...note,
|
|
@@ -101324,7 +101778,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
101324
101778
|
const directory = yield* pipe(String$2("STASH_DATA_DIR"), withDefault(path.join(yield* String$2("HOME"), ".deslop", "stash")));
|
|
101325
101779
|
const images = path.join(directory, "images");
|
|
101326
101780
|
const files = path.join(directory, "files");
|
|
101327
|
-
const reading = yield* make$
|
|
101781
|
+
const reading = yield* make$36(2);
|
|
101328
101782
|
const runs = yield* make$18();
|
|
101329
101783
|
const storageFailed = mapError((cause) => NotesError.make({
|
|
101330
101784
|
cause,
|
|
@@ -101348,7 +101802,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
101348
101802
|
}));
|
|
101349
101803
|
}
|
|
101350
101804
|
function updateNote(id, change) {
|
|
101351
|
-
return transact((current) => make$
|
|
101805
|
+
return transact((current) => make$46(void 0, changeNote(current, id, change)));
|
|
101352
101806
|
}
|
|
101353
101807
|
function findNote(id) {
|
|
101354
101808
|
return map$1(get$1(state), (notes) => findFirst(notes, (note) => note.id === id));
|
|
@@ -101395,7 +101849,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
101395
101849
|
}));
|
|
101396
101850
|
}
|
|
101397
101851
|
const keepImages = fnUntraced(function* (note, page) {
|
|
101398
|
-
yield* pipe(forEach(toArray$1(filter$
|
|
101852
|
+
yield* pipe(forEach(toArray$1(filter$4(page.image, () => note.image === void 0)), (image) => flatMap(sources.image(image), (bytes) => storeImage(note.id, bytes)), {
|
|
101399
101853
|
concurrency: "unbounded",
|
|
101400
101854
|
discard: true
|
|
101401
101855
|
}), ignore$1({
|
|
@@ -101417,7 +101871,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
101417
101871
|
}),
|
|
101418
101872
|
onSuccess: (page) => ({
|
|
101419
101873
|
...omit(item, ["issue"]),
|
|
101420
|
-
...match$1(filter$
|
|
101874
|
+
...match$1(filter$4(page.author, isNonEmpty), {
|
|
101421
101875
|
onNone: () => ({}),
|
|
101422
101876
|
onSome: (author) => ({ author })
|
|
101423
101877
|
}),
|
|
@@ -101442,9 +101896,9 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
101442
101896
|
onSuccess: (page) => page.video ?? page.url
|
|
101443
101897
|
});
|
|
101444
101898
|
const read = yield* pipe(media.read(video), asSome, optional("The video could not be read", none));
|
|
101445
|
-
const transcript = yield* pipe(filter$
|
|
101899
|
+
const transcript = yield* pipe(filter$4(read, () => note.transcript === void 0), map$5((details) => pipe(details.transcript, optional("No transcript", none))), transposeOption, map$1(flatten));
|
|
101446
101900
|
yield* updateNote(note.id, (item) => ({
|
|
101447
|
-
...match$1(filter$
|
|
101901
|
+
...match$1(filter$4(read, () => sourceFor(url) !== "X" || isFailure(extraction)), {
|
|
101448
101902
|
onNone: () => item,
|
|
101449
101903
|
onSome: (details) => ({
|
|
101450
101904
|
...omit(item, ["issue"]),
|
|
@@ -101500,7 +101954,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
101500
101954
|
onTrue: () => void_
|
|
101501
101955
|
})), (effect) => run$1(runs, note.id, effect), asVoid);
|
|
101502
101956
|
}
|
|
101503
|
-
yield* forEach(filter$
|
|
101957
|
+
yield* forEach(filter$5(yield* get$1(state), (note) => note.status === "organizing"), start, {
|
|
101504
101958
|
concurrency: 1,
|
|
101505
101959
|
discard: true
|
|
101506
101960
|
});
|
|
@@ -101541,8 +101995,8 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
101541
101995
|
text: ""
|
|
101542
101996
|
});
|
|
101543
101997
|
const earlier = yield* transact((current) => match$1(findFirst(current, (item) => item.id === input.id), {
|
|
101544
|
-
onNone: () => make$
|
|
101545
|
-
onSome: (item) => make$
|
|
101998
|
+
onNone: () => make$46(none(), prepend$2(current, note)),
|
|
101999
|
+
onSome: (item) => make$46(some$1(item), current)
|
|
101546
102000
|
}));
|
|
101547
102001
|
return yield* match$1(earlier, {
|
|
101548
102002
|
onNone: () => as$1(start(note), note),
|
|
@@ -101553,7 +102007,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
101553
102007
|
capture: fn$1("Notes.capture")(function* (input) {
|
|
101554
102008
|
const text = trim(input.text);
|
|
101555
102009
|
if (isEmpty$2(text)) return yield* NotesError.make({ message: "Paste a link or write a note." });
|
|
101556
|
-
const url = yield* pipe(fromUndefinedOr(captureUrl(text)), map$
|
|
102010
|
+
const url = yield* pipe(fromUndefinedOr(captureUrl(text)), map$5((link) => orElseSucceed(sources.resolve(link), () => link)), transposeOption);
|
|
101557
102011
|
const createdAt = toEpochMillis(yield* now);
|
|
101558
102012
|
const saved = yield* transact((current) => match$1(findFirst(current, (note) => note.id === input.id || exists(url, (link) => note.url === link)), {
|
|
101559
102013
|
onNone: () => {
|
|
@@ -101575,18 +102029,18 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
101575
102029
|
onSome: (link) => ({ url: link })
|
|
101576
102030
|
})
|
|
101577
102031
|
});
|
|
101578
|
-
return make$
|
|
102032
|
+
return make$46({
|
|
101579
102033
|
fresh: true,
|
|
101580
102034
|
note
|
|
101581
102035
|
}, prepend$2(current, note));
|
|
101582
102036
|
},
|
|
101583
102037
|
onSome: (note) => {
|
|
101584
102038
|
const merged = withWords(note, text);
|
|
101585
|
-
if (note.id === input.id || merged === note) return make$
|
|
102039
|
+
if (note.id === input.id || merged === note) return make$46({
|
|
101586
102040
|
fresh: false,
|
|
101587
102041
|
note
|
|
101588
102042
|
}, current);
|
|
101589
|
-
return make$
|
|
102043
|
+
return make$46({
|
|
101590
102044
|
fresh: false,
|
|
101591
102045
|
note: merged
|
|
101592
102046
|
}, changeNote(current, note.id, () => merged));
|
|
@@ -101630,22 +102084,22 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
|
|
|
101630
102084
|
regenerate: fn$1("Notes.regenerate")(function* (input) {
|
|
101631
102085
|
yield* remove$1(runs, input.id);
|
|
101632
102086
|
const reset = yield* transact((current) => match$1(findFirst(current, (note) => note.id === input.id), {
|
|
101633
|
-
onNone: () => make$
|
|
102087
|
+
onNone: () => make$46(none(), current),
|
|
101634
102088
|
onSome: (found) => {
|
|
101635
102089
|
const next = {
|
|
101636
102090
|
...omit(found, ["issue", "transcript"]),
|
|
101637
102091
|
status: "organizing"
|
|
101638
102092
|
};
|
|
101639
|
-
return make$
|
|
102093
|
+
return make$46(some$1(next), changeNote(current, input.id, () => next));
|
|
101640
102094
|
}
|
|
101641
102095
|
}));
|
|
101642
102096
|
yield* pipe(fromOption(reset), missing, flatMap(start));
|
|
101643
102097
|
}),
|
|
101644
102098
|
remove: fn$1("Notes.remove")(function* (input) {
|
|
101645
102099
|
yield* remove$1(runs, input.id);
|
|
101646
|
-
yield* transact((current) => make$
|
|
102100
|
+
yield* transact((current) => make$46(void 0, match(some$2(current, (note) => note.id === input.id), {
|
|
101647
102101
|
onFalse: () => current,
|
|
101648
|
-
onTrue: () => filter$
|
|
102102
|
+
onTrue: () => filter$5(current, (note) => note.id !== input.id)
|
|
101649
102103
|
})));
|
|
101650
102104
|
yield* pipe(fs.remove(path.join(images, input.id), { force: true }), storageFailed);
|
|
101651
102105
|
yield* pipe(fs.remove(path.join(files, input.id), { force: true }), storageFailed);
|
|
@@ -101672,7 +102126,7 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
|
|
|
101672
102126
|
//#endregion
|
|
101673
102127
|
//#region src/main.server.ts
|
|
101674
102128
|
const noteIdParam = schemaPathParams(Struct({ id: NoteId }));
|
|
101675
|
-
const routes = use((router) => gen(function* () {
|
|
102129
|
+
const routes = pipe(use((router) => gen(function* () {
|
|
101676
102130
|
const notes = yield* Notes;
|
|
101677
102131
|
yield* router.add("POST", "/api/capture", gen(function* () {
|
|
101678
102132
|
return yield* schemaJson(Note)(yield* notes.capture(yield* schemaBodyJson(Capture)));
|
|
@@ -101693,12 +102147,12 @@ const routes = use((router) => gen(function* () {
|
|
|
101693
102147
|
headers: { "cache-control": "private, max-age=31536000, immutable" }
|
|
101694
102148
|
});
|
|
101695
102149
|
}));
|
|
101696
|
-
}));
|
|
102150
|
+
})), provide$1(HttpAuth.layer));
|
|
101697
102151
|
const rpc = pipe(layerHttp({
|
|
101698
102152
|
group: RpcContracts,
|
|
101699
102153
|
path: "/api/rpc",
|
|
101700
102154
|
protocol: "websocket"
|
|
101701
|
-
}), provide(RpcHandlers), provide(layerJson$1));
|
|
101702
|
-
runMain(pipe(serve(merge$3(rpc, routes), { disableLogger: true }), provide(Notes.layer), provide(mergeAll(Sources.layer, Media.layer, Organizer.layer)), provide(mergeAll(layer$4, layer$6, layer$11)), provide(layer("@deslop/stash")), provide(layerNodeHttpServer), launch));
|
|
102155
|
+
}), provide$1(RpcHandlers), provide$1(layerJson$1));
|
|
102156
|
+
runMain(pipe(serve(pipe(merge$3(rpc, routes), provide$1(Auth.layer)), { disableLogger: true }), provide$1(Notes.layer), provide$1(mergeAll(Sources.layer, Media.layer, Organizer.layer)), provide$1(mergeAll(layer$4, layer$6, layer$11)), provide$1(layer("@deslop/stash")), provide$1(layerNodeHttpServer), launch));
|
|
101703
102157
|
//#endregion
|
|
101704
102158
|
export {};
|