effect-start 0.23.1 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +18 -86
- package/src/Development.ts +3 -1
- package/src/Entity.ts +17 -0
- package/src/Fetch.ts +271 -0
- package/src/SqlIntrospect.ts +64 -70
- package/src/Start.ts +21 -24
- package/src/StartApp.ts +1 -1
- package/src/bun/BunServer.ts +42 -10
- package/src/hyper/HyperHtml.ts +0 -1
- package/src/sql/bun/index.ts +1 -1
- package/src/sql/index.ts +1 -0
- package/src/sql/libsql/index.ts +173 -0
- package/src/sql/libsql/libsql.d.ts +39 -0
- package/src/sql/mssql/index.ts +1 -1
- package/dist/BlobStore.d.ts +0 -80
- package/dist/BlobStore.js +0 -19
- package/dist/ChildProcess.d.ts +0 -60
- package/dist/ChildProcess.js +0 -30
- package/dist/Commander.d.ts +0 -100
- package/dist/Commander.js +0 -326
- package/dist/ContentNegotiation.d.ts +0 -12
- package/dist/ContentNegotiation.js +0 -359
- package/dist/Cookies.d.ts +0 -47
- package/dist/Cookies.js +0 -302
- package/dist/Development.d.ts +0 -39
- package/dist/Development.js +0 -58
- package/dist/Effectify.d.ts +0 -209
- package/dist/Effectify.js +0 -19
- package/dist/Entity.d.ts +0 -47
- package/dist/Entity.js +0 -224
- package/dist/FilePathPattern.d.ts +0 -29
- package/dist/FilePathPattern.js +0 -86
- package/dist/FileRouter.d.ts +0 -56
- package/dist/FileRouter.js +0 -148
- package/dist/FileRouterCodegen.d.ts +0 -18
- package/dist/FileRouterCodegen.js +0 -227
- package/dist/FileRouterPattern.d.ts +0 -9
- package/dist/FileRouterPattern.js +0 -35
- package/dist/FileSystem.d.ts +0 -158
- package/dist/FileSystem.js +0 -70
- package/dist/Http.d.ts +0 -37
- package/dist/Http.js +0 -88
- package/dist/HttpAppExtra.d.ts +0 -7
- package/dist/HttpAppExtra.js +0 -320
- package/dist/HttpUtils.d.ts +0 -3
- package/dist/HttpUtils.js +0 -11
- package/dist/PathPattern.d.ts +0 -134
- package/dist/PathPattern.js +0 -413
- package/dist/PlatformError.d.ts +0 -38
- package/dist/PlatformError.js +0 -25
- package/dist/PlatformRuntime.d.ts +0 -27
- package/dist/PlatformRuntime.js +0 -46
- package/dist/Route.d.ts +0 -97
- package/dist/Route.js +0 -100
- package/dist/RouteBody.d.ts +0 -47
- package/dist/RouteBody.js +0 -67
- package/dist/RouteError.d.ts +0 -98
- package/dist/RouteError.js +0 -55
- package/dist/RouteHook.d.ts +0 -12
- package/dist/RouteHook.js +0 -40
- package/dist/RouteHttp.d.ts +0 -21
- package/dist/RouteHttp.js +0 -258
- package/dist/RouteHttpTracer.d.ts +0 -10
- package/dist/RouteHttpTracer.js +0 -62
- package/dist/RouteMount.d.ts +0 -86
- package/dist/RouteMount.js +0 -63
- package/dist/RouteSchema.d.ts +0 -86
- package/dist/RouteSchema.js +0 -188
- package/dist/RouteSse.d.ts +0 -21
- package/dist/RouteSse.js +0 -79
- package/dist/RouteTree.d.ts +0 -57
- package/dist/RouteTree.js +0 -93
- package/dist/RouteTrie.d.ts +0 -20
- package/dist/RouteTrie.js +0 -152
- package/dist/RouterPattern.d.ts +0 -118
- package/dist/RouterPattern.js +0 -269
- package/dist/SchemaExtra.d.ts +0 -7
- package/dist/SchemaExtra.js +0 -74
- package/dist/Socket.d.ts +0 -27
- package/dist/Socket.js +0 -29
- package/dist/Sql.d.ts +0 -34
- package/dist/Sql.js +0 -5
- package/dist/SqlIntrospect.d.ts +0 -91
- package/dist/SqlIntrospect.js +0 -466
- package/dist/Start.d.ts +0 -44
- package/dist/Start.js +0 -49
- package/dist/StartApp.d.ts +0 -19
- package/dist/StartApp.js +0 -21
- package/dist/StreamExtra.d.ts +0 -28
- package/dist/StreamExtra.js +0 -100
- package/dist/System.d.ts +0 -7
- package/dist/System.js +0 -22
- package/dist/TuplePathPattern.d.ts +0 -9
- package/dist/TuplePathPattern.js +0 -68
- package/dist/Unique.d.ts +0 -50
- package/dist/Unique.js +0 -187
- package/dist/Values.d.ts +0 -27
- package/dist/Values.js +0 -36
- package/dist/bun/BunBlobStoreDisk.d.ts +0 -6
- package/dist/bun/BunBlobStoreDisk.js +0 -116
- package/dist/bun/BunBlobStoreS3.d.ts +0 -11
- package/dist/bun/BunBlobStoreS3.js +0 -89
- package/dist/bun/BunBlobWatcherDisk.d.ts +0 -6
- package/dist/bun/BunBlobWatcherDisk.js +0 -60
- package/dist/bun/BunBlobWatcherQueue.d.ts +0 -6
- package/dist/bun/BunBlobWatcherQueue.js +0 -17
- package/dist/bun/BunBundle.d.ts +0 -11
- package/dist/bun/BunBundle.js +0 -137
- package/dist/bun/BunChildProcessSpawner.d.ts +0 -3
- package/dist/bun/BunChildProcessSpawner.js +0 -103
- package/dist/bun/BunHttpServer.d.ts +0 -44
- package/dist/bun/BunHttpServer.js +0 -186
- package/dist/bun/BunHttpServer_web.d.ts +0 -60
- package/dist/bun/BunHttpServer_web.js +0 -252
- package/dist/bun/BunImportTrackerPlugin.d.ts +0 -13
- package/dist/bun/BunImportTrackerPlugin.js +0 -69
- package/dist/bun/BunPlatformHttpServer.d.ts +0 -10
- package/dist/bun/BunPlatformHttpServer.js +0 -53
- package/dist/bun/BunRoute.d.ts +0 -48
- package/dist/bun/BunRoute.js +0 -121
- package/dist/bun/BunRuntime.d.ts +0 -2
- package/dist/bun/BunRuntime.js +0 -31
- package/dist/bun/BunServer.d.ts +0 -40
- package/dist/bun/BunServer.js +0 -157
- package/dist/bun/BunServerRequest.d.ts +0 -60
- package/dist/bun/BunServerRequest.js +0 -252
- package/dist/bun/BunSql.d.ts +0 -4
- package/dist/bun/BunSql.js +0 -81
- package/dist/bun/BunVirtualFilesPlugin.d.ts +0 -4
- package/dist/bun/BunVirtualFilesPlugin.js +0 -40
- package/dist/bun/_BunEnhancedResolve.d.ts +0 -45
- package/dist/bun/_BunEnhancedResolve.js +0 -102
- package/dist/bun/index.d.ts +0 -5
- package/dist/bun/index.js +0 -5
- package/dist/bundler/Bundle.d.ts +0 -61
- package/dist/bundler/Bundle.js +0 -48
- package/dist/bundler/BundleFiles.d.ts +0 -13
- package/dist/bundler/BundleFiles.js +0 -96
- package/dist/bundler/BundleHttp.d.ts +0 -45
- package/dist/bundler/BundleHttp.js +0 -176
- package/dist/bundler/BundleRoute.d.ts +0 -27
- package/dist/bundler/BundleRoute.js +0 -51
- package/dist/client/Overlay.d.ts +0 -2
- package/dist/client/Overlay.js +0 -32
- package/dist/client/ScrollState.d.ts +0 -6
- package/dist/client/ScrollState.js +0 -94
- package/dist/client/index.d.ts +0 -6
- package/dist/client/index.js +0 -79
- package/dist/console/Console.d.ts +0 -6
- package/dist/console/Console.js +0 -26
- package/dist/console/ConsoleErrors.d.ts +0 -3
- package/dist/console/ConsoleErrors.js +0 -200
- package/dist/console/ConsoleLogger.d.ts +0 -3
- package/dist/console/ConsoleLogger.js +0 -47
- package/dist/console/ConsoleMetrics.d.ts +0 -3
- package/dist/console/ConsoleMetrics.js +0 -61
- package/dist/console/ConsoleProcess.d.ts +0 -3
- package/dist/console/ConsoleProcess.js +0 -49
- package/dist/console/ConsoleStore.d.ts +0 -144
- package/dist/console/ConsoleStore.js +0 -61
- package/dist/console/ConsoleTracer.d.ts +0 -3
- package/dist/console/ConsoleTracer.js +0 -94
- package/dist/console/Simulation.d.ts +0 -2
- package/dist/console/Simulation.js +0 -633
- package/dist/console/index.d.ts +0 -3
- package/dist/console/index.js +0 -3
- package/dist/console/routes/errors/route.d.ts +0 -10
- package/dist/console/routes/errors/route.js +0 -47
- package/dist/console/routes/fiberDetail.d.ts +0 -16
- package/dist/console/routes/fiberDetail.js +0 -38
- package/dist/console/routes/fibers/route.d.ts +0 -10
- package/dist/console/routes/fibers/route.js +0 -19
- package/dist/console/routes/git/route.d.ts +0 -11
- package/dist/console/routes/git/route.js +0 -33
- package/dist/console/routes/layout.d.ts +0 -9
- package/dist/console/routes/layout.js +0 -3
- package/dist/console/routes/logs/route.d.ts +0 -10
- package/dist/console/routes/logs/route.js +0 -32
- package/dist/console/routes/metrics/route.d.ts +0 -10
- package/dist/console/routes/metrics/route.js +0 -17
- package/dist/console/routes/route.d.ts +0 -6
- package/dist/console/routes/route.js +0 -5
- package/dist/console/routes/routes/route.d.ts +0 -6
- package/dist/console/routes/routes/route.js +0 -20
- package/dist/console/routes/services/route.d.ts +0 -6
- package/dist/console/routes/services/route.js +0 -12
- package/dist/console/routes/system/route.d.ts +0 -10
- package/dist/console/routes/system/route.js +0 -18
- package/dist/console/routes/traceDetail.d.ts +0 -16
- package/dist/console/routes/traceDetail.js +0 -14
- package/dist/console/routes/traces/route.d.ts +0 -10
- package/dist/console/routes/traces/route.js +0 -39
- package/dist/console/routes/tree.d.ts +0 -153
- package/dist/console/routes/tree.js +0 -29
- package/dist/console/ui/Errors.d.ts +0 -4
- package/dist/console/ui/Errors.js +0 -15
- package/dist/console/ui/Fibers.d.ts +0 -24
- package/dist/console/ui/Fibers.js +0 -121
- package/dist/console/ui/Git.d.ts +0 -20
- package/dist/console/ui/Git.js +0 -95
- package/dist/console/ui/Logs.d.ts +0 -4
- package/dist/console/ui/Logs.js +0 -25
- package/dist/console/ui/Metrics.d.ts +0 -4
- package/dist/console/ui/Metrics.js +0 -26
- package/dist/console/ui/Routes.d.ts +0 -8
- package/dist/console/ui/Routes.js +0 -70
- package/dist/console/ui/Services.d.ts +0 -10
- package/dist/console/ui/Services.js +0 -246
- package/dist/console/ui/Shell.d.ts +0 -10
- package/dist/console/ui/Shell.js +0 -7
- package/dist/console/ui/System.d.ts +0 -4
- package/dist/console/ui/System.js +0 -35
- package/dist/console/ui/Traces.d.ts +0 -12
- package/dist/console/ui/Traces.js +0 -179
- package/dist/datastar/actions/fetch.d.ts +0 -30
- package/dist/datastar/actions/fetch.js +0 -403
- package/dist/datastar/actions/peek.d.ts +0 -1
- package/dist/datastar/actions/peek.js +0 -13
- package/dist/datastar/actions/setAll.d.ts +0 -1
- package/dist/datastar/actions/setAll.js +0 -12
- package/dist/datastar/actions/toggleAll.d.ts +0 -1
- package/dist/datastar/actions/toggleAll.js +0 -12
- package/dist/datastar/attributes/attr.d.ts +0 -1
- package/dist/datastar/attributes/attr.js +0 -48
- package/dist/datastar/attributes/bind.d.ts +0 -1
- package/dist/datastar/attributes/bind.js +0 -175
- package/dist/datastar/attributes/class.d.ts +0 -1
- package/dist/datastar/attributes/class.js +0 -47
- package/dist/datastar/attributes/computed.d.ts +0 -1
- package/dist/datastar/attributes/computed.js +0 -26
- package/dist/datastar/attributes/effect.d.ts +0 -1
- package/dist/datastar/attributes/effect.js +0 -9
- package/dist/datastar/attributes/indicator.d.ts +0 -1
- package/dist/datastar/attributes/indicator.js +0 -30
- package/dist/datastar/attributes/init.d.ts +0 -1
- package/dist/datastar/attributes/init.js +0 -26
- package/dist/datastar/attributes/jsonSignals.d.ts +0 -1
- package/dist/datastar/attributes/jsonSignals.js +0 -30
- package/dist/datastar/attributes/on.d.ts +0 -1
- package/dist/datastar/attributes/on.js +0 -78
- package/dist/datastar/attributes/onIntersect.d.ts +0 -1
- package/dist/datastar/attributes/onIntersect.js +0 -53
- package/dist/datastar/attributes/onInterval.d.ts +0 -1
- package/dist/datastar/attributes/onInterval.js +0 -30
- package/dist/datastar/attributes/onSignalPatch.d.ts +0 -1
- package/dist/datastar/attributes/onSignalPatch.js +0 -42
- package/dist/datastar/attributes/ref.d.ts +0 -1
- package/dist/datastar/attributes/ref.js +0 -10
- package/dist/datastar/attributes/show.d.ts +0 -1
- package/dist/datastar/attributes/show.js +0 -31
- package/dist/datastar/attributes/signals.d.ts +0 -1
- package/dist/datastar/attributes/signals.js +0 -17
- package/dist/datastar/attributes/style.d.ts +0 -1
- package/dist/datastar/attributes/style.js +0 -50
- package/dist/datastar/attributes/text.d.ts +0 -1
- package/dist/datastar/attributes/text.js +0 -26
- package/dist/datastar/engine.d.ts +0 -162
- package/dist/datastar/engine.js +0 -999
- package/dist/datastar/happydom.d.ts +0 -1
- package/dist/datastar/happydom.js +0 -8
- package/dist/datastar/index.d.ts +0 -24
- package/dist/datastar/index.js +0 -24
- package/dist/datastar/load.d.ts +0 -24
- package/dist/datastar/load.js +0 -24
- package/dist/datastar/utils.d.ts +0 -51
- package/dist/datastar/utils.js +0 -202
- package/dist/datastar/watchers/patchElements.d.ts +0 -1
- package/dist/datastar/watchers/patchElements.js +0 -399
- package/dist/datastar/watchers/patchSignals.d.ts +0 -1
- package/dist/datastar/watchers/patchSignals.js +0 -14
- package/dist/experimental/EncryptedCookies.d.ts +0 -48
- package/dist/experimental/EncryptedCookies.js +0 -212
- package/dist/experimental/SseHttpResponse.d.ts +0 -7
- package/dist/experimental/SseHttpResponse.js +0 -28
- package/dist/experimental/index.d.ts +0 -1
- package/dist/experimental/index.js +0 -1
- package/dist/hyper/Hyper.d.ts +0 -25
- package/dist/hyper/Hyper.js +0 -23
- package/dist/hyper/HyperHtml.d.ts +0 -23
- package/dist/hyper/HyperHtml.js +0 -150
- package/dist/hyper/HyperHtml.test.d.ts +0 -1
- package/dist/hyper/HyperHtml.test.js +0 -197
- package/dist/hyper/HyperNode.d.ts +0 -14
- package/dist/hyper/HyperNode.js +0 -11
- package/dist/hyper/HyperRoute.d.ts +0 -8
- package/dist/hyper/HyperRoute.js +0 -32
- package/dist/hyper/HyperRoute.test.d.ts +0 -1
- package/dist/hyper/HyperRoute.test.js +0 -83
- package/dist/hyper/html.d.ts +0 -11
- package/dist/hyper/html.js +0 -30
- package/dist/hyper/index.d.ts +0 -6
- package/dist/hyper/index.js +0 -5
- package/dist/hyper/jsx-runtime.d.ts +0 -7
- package/dist/hyper/jsx-runtime.js +0 -8
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/inference_check.d.ts +0 -1
- package/dist/inference_check.js +0 -15
- package/dist/lint/plugin.d.ts +0 -86
- package/dist/lint/plugin.js +0 -341
- package/dist/middlewares/BasicAuthMiddleware.d.ts +0 -8
- package/dist/middlewares/BasicAuthMiddleware.js +0 -22
- package/dist/middlewares/index.d.ts +0 -1
- package/dist/middlewares/index.js +0 -1
- package/dist/node/Effectify.d.ts +0 -209
- package/dist/node/Effectify.js +0 -19
- package/dist/node/FileSystem.d.ts +0 -7
- package/dist/node/FileSystem.js +0 -420
- package/dist/node/NodeFileSystem.d.ts +0 -7
- package/dist/node/NodeFileSystem.js +0 -410
- package/dist/node/NodeUtils.d.ts +0 -2
- package/dist/node/NodeUtils.js +0 -20
- package/dist/node/PlatformError.d.ts +0 -46
- package/dist/node/PlatformError.js +0 -43
- package/dist/node/Utils.d.ts +0 -1
- package/dist/node/Utils.js +0 -19
- package/dist/repro_fail.d.ts +0 -1
- package/dist/repro_fail.js +0 -14
- package/dist/sql/bun/index.d.ts +0 -3
- package/dist/sql/bun/index.js +0 -75
- package/dist/sql/mssql/docker.d.ts +0 -2
- package/dist/sql/mssql/docker.js +0 -67
- package/dist/sql/mssql/index.d.ts +0 -21
- package/dist/sql/mssql/index.js +0 -113
- package/dist/testing/TestHttpClient.d.ts +0 -13
- package/dist/testing/TestHttpClient.js +0 -68
- package/dist/testing/TestLogger.d.ts +0 -13
- package/dist/testing/TestLogger.js +0 -32
- package/dist/testing/index.d.ts +0 -2
- package/dist/testing/index.js +0 -2
- package/dist/testing/utils.d.ts +0 -9
- package/dist/testing/utils.js +0 -39
- package/dist/x/cloudflare/CloudflareTunnel.d.ts +0 -10
- package/dist/x/cloudflare/CloudflareTunnel.js +0 -30
- package/dist/x/cloudflare/index.d.ts +0 -1
- package/dist/x/cloudflare/index.js +0 -1
- package/dist/x/datastar/Datastar.d.ts +0 -6
- package/dist/x/datastar/Datastar.js +0 -47
- package/dist/x/datastar/index.d.ts +0 -1
- package/dist/x/datastar/index.js +0 -1
- package/dist/x/tailscale/TailscaleTunnel.d.ts +0 -15
- package/dist/x/tailscale/TailscaleTunnel.js +0 -68
- package/dist/x/tailscale/index.d.ts +0 -1
- package/dist/x/tailscale/index.js +0 -1
- package/dist/x/tailwind/TailwindPlugin.d.ts +0 -23
- package/dist/x/tailwind/TailwindPlugin.js +0 -219
- package/dist/x/tailwind/compile.d.ts +0 -19
- package/dist/x/tailwind/compile.js +0 -154
- package/dist/x/tailwind/plugin.d.ts +0 -2
- package/dist/x/tailwind/plugin.js +0 -15
- /package/src/{Sql.ts → sql/Sql.ts} +0 -0
package/dist/StreamExtra.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import * as Cause from "effect/Cause";
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as Fiber from "effect/Fiber";
|
|
4
|
-
import * as Function from "effect/Function";
|
|
5
|
-
import * as Predicate from "effect/Predicate";
|
|
6
|
-
import * as Runtime from "effect/Runtime";
|
|
7
|
-
import * as Stream from "effect/Stream";
|
|
8
|
-
export const isStream = (u) => Predicate.hasProperty(u, Stream.StreamTypeId);
|
|
9
|
-
/**
|
|
10
|
-
* Patched version of original Stream.toReadableStreamRuntime (v3.14.4) to
|
|
11
|
-
* fix an issue in Bun when native stream controller stops working when request
|
|
12
|
-
* is terminated by the client:
|
|
13
|
-
*
|
|
14
|
-
* TypeError: Value of "this" must be of type ReadableStreamDefaultController
|
|
15
|
-
*
|
|
16
|
-
* See related issues:
|
|
17
|
-
* https://github.com/Effect-TS/effect/issues/4538
|
|
18
|
-
* https://github.com/oven-sh/bun/issues/17837
|
|
19
|
-
*/
|
|
20
|
-
export const toReadableStreamRuntimePatched = Function.dual((args) => Predicate.hasProperty(args[0], Stream.StreamTypeId) || Effect.isEffect(args[0]), (self, runtime, options) => {
|
|
21
|
-
const runFork = Runtime.runFork(runtime);
|
|
22
|
-
let currentResolve = undefined;
|
|
23
|
-
let fiber = undefined;
|
|
24
|
-
const latch = Effect.unsafeMakeLatch(false);
|
|
25
|
-
return new ReadableStream({
|
|
26
|
-
start(controller) {
|
|
27
|
-
fiber = runFork(Stream.runForEachChunk(self, (chunk) => latch.whenOpen(Effect.sync(() => {
|
|
28
|
-
latch.unsafeClose();
|
|
29
|
-
try {
|
|
30
|
-
for (const item of chunk) {
|
|
31
|
-
controller.enqueue(item);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
if (e.message ===
|
|
36
|
-
`Value of "this" must be of type ReadableStreamDefaultController`) {
|
|
37
|
-
// Do nothing when this happens in Bun.
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
throw e;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
currentResolve();
|
|
44
|
-
currentResolve = undefined;
|
|
45
|
-
}))));
|
|
46
|
-
// --- CHANGES HERE ---
|
|
47
|
-
// In original code, we had fiber.addObserver here that called
|
|
48
|
-
// error() or close() on controller. This patched version removes it.
|
|
49
|
-
},
|
|
50
|
-
pull() {
|
|
51
|
-
return new Promise((resolve) => {
|
|
52
|
-
currentResolve = resolve;
|
|
53
|
-
Effect.runSync(latch.open);
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
cancel() {
|
|
57
|
-
if (!fiber)
|
|
58
|
-
return;
|
|
59
|
-
return Effect.runPromise(Effect.asVoid(Fiber.interrupt(fiber)));
|
|
60
|
-
},
|
|
61
|
-
}, options?.strategy);
|
|
62
|
-
});
|
|
63
|
-
export const toReadableStreamRuntimePatched2 = Function.dual((args) => Predicate.hasProperty(args[0], Stream.StreamTypeId) || Effect.isEffect(args[0]), (self, runtime, options) => {
|
|
64
|
-
const runSync = Runtime.runSync(runtime);
|
|
65
|
-
const runFork = Runtime.runFork(runtime);
|
|
66
|
-
let currentResolve = undefined;
|
|
67
|
-
let fiber = undefined;
|
|
68
|
-
const latch = Effect.unsafeMakeLatch(false);
|
|
69
|
-
return new ReadableStream({
|
|
70
|
-
start(controller) {
|
|
71
|
-
fiber = runFork(Stream.runForEachChunk(self, (chunk) => latch.whenOpen(Effect.sync(() => {
|
|
72
|
-
latch.unsafeClose();
|
|
73
|
-
for (const item of chunk) {
|
|
74
|
-
controller.enqueue(item);
|
|
75
|
-
}
|
|
76
|
-
currentResolve();
|
|
77
|
-
currentResolve = undefined;
|
|
78
|
-
}))));
|
|
79
|
-
fiber.addObserver((exit) => {
|
|
80
|
-
if (exit._tag === "Failure") {
|
|
81
|
-
controller.error(Cause.squash(exit.cause));
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
controller.close();
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
pull() {
|
|
89
|
-
return new Promise((resolve) => {
|
|
90
|
-
currentResolve = resolve;
|
|
91
|
-
Effect.runSync(latch.open);
|
|
92
|
-
});
|
|
93
|
-
},
|
|
94
|
-
cancel() {
|
|
95
|
-
if (!fiber)
|
|
96
|
-
return;
|
|
97
|
-
return Effect.runPromise(Effect.asVoid(Fiber.interrupt(fiber)));
|
|
98
|
-
},
|
|
99
|
-
}, options?.strategy);
|
|
100
|
-
});
|
package/dist/System.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as Effect from "effect/Effect";
|
|
2
|
-
import type * as Scope from "effect/Scope";
|
|
3
|
-
import * as ChildProcess from "./ChildProcess.ts";
|
|
4
|
-
import * as PlatformError from "./PlatformError.ts";
|
|
5
|
-
export declare const cwd: Effect.Effect<string>;
|
|
6
|
-
export declare const which: (name: string) => Effect.Effect<string, PlatformError.SystemError>;
|
|
7
|
-
export declare const spawn: (command: string, args?: ReadonlyArray<string>, options?: ChildProcess.Command.Options) => Effect.Effect<ChildProcess.ChildProcessHandle, PlatformError.PlatformError, ChildProcess.ChildProcessSpawner | Scope.Scope>;
|
package/dist/System.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as Effect from "effect/Effect";
|
|
2
|
-
import * as ChildProcess from "./ChildProcess.js";
|
|
3
|
-
import * as PlatformError from "./PlatformError.js";
|
|
4
|
-
export const cwd = Effect.sync(() => process.cwd());
|
|
5
|
-
export const which = (name) => Effect.flatMap(Effect.try({
|
|
6
|
-
try: () => Bun.which(name),
|
|
7
|
-
catch: (err) => new PlatformError.SystemError({
|
|
8
|
-
reason: "Unknown",
|
|
9
|
-
module: "System",
|
|
10
|
-
method: "which",
|
|
11
|
-
description: err instanceof Error ? err.message : `Failed to look up "${name}"`,
|
|
12
|
-
cause: err,
|
|
13
|
-
}),
|
|
14
|
-
}), (path) => path === null
|
|
15
|
-
? Effect.fail(new PlatformError.SystemError({
|
|
16
|
-
reason: "NotFound",
|
|
17
|
-
module: "System",
|
|
18
|
-
method: "which",
|
|
19
|
-
description: `Executable not found: "${name}"`,
|
|
20
|
-
}))
|
|
21
|
-
: Effect.succeed(path));
|
|
22
|
-
export const spawn = (command, args, options) => ChildProcess.spawn(ChildProcess.make(command, args, options));
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type PathTuple = ReadonlyArray<string | [string, string?, string?] | [[string]]>;
|
|
2
|
-
export declare function format(tuple: PathTuple): `/${string}`;
|
|
3
|
-
export declare function toColon(tuple: PathTuple): string;
|
|
4
|
-
export declare const toHono: typeof toColon;
|
|
5
|
-
export declare function toExpress(tuple: PathTuple): string;
|
|
6
|
-
export declare const toEffect: typeof toColon;
|
|
7
|
-
export declare function toURLPattern(tuple: PathTuple): string;
|
|
8
|
-
export declare function toRemix(tuple: PathTuple): string;
|
|
9
|
-
export declare const toBun: typeof toColon;
|
package/dist/TuplePathPattern.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
export function format(tuple) {
|
|
2
|
-
return ("/" +
|
|
3
|
-
tuple
|
|
4
|
-
.map((el) => {
|
|
5
|
-
if (typeof el === "string")
|
|
6
|
-
return el;
|
|
7
|
-
if (Array.isArray(el[0]))
|
|
8
|
-
return "[[" + el[0][0] + "]]";
|
|
9
|
-
const [name, suffix, prefix] = el;
|
|
10
|
-
return (prefix ?? "") + "[" + name + "]" + (suffix ?? "");
|
|
11
|
-
})
|
|
12
|
-
.join("/"));
|
|
13
|
-
}
|
|
14
|
-
export function toColon(tuple) {
|
|
15
|
-
return ("/" +
|
|
16
|
-
tuple
|
|
17
|
-
.map((el) => {
|
|
18
|
-
if (typeof el === "string")
|
|
19
|
-
return el;
|
|
20
|
-
if (Array.isArray(el[0]))
|
|
21
|
-
return "*";
|
|
22
|
-
const [name, suffix, prefix] = el;
|
|
23
|
-
return (prefix ?? "") + ":" + name + (suffix ?? "");
|
|
24
|
-
})
|
|
25
|
-
.join("/"));
|
|
26
|
-
}
|
|
27
|
-
export const toHono = toColon;
|
|
28
|
-
export function toExpress(tuple) {
|
|
29
|
-
return ("/" +
|
|
30
|
-
tuple
|
|
31
|
-
.map((el) => {
|
|
32
|
-
if (typeof el === "string")
|
|
33
|
-
return el;
|
|
34
|
-
if (Array.isArray(el[0]))
|
|
35
|
-
return "*" + el[0][0];
|
|
36
|
-
const [name, suffix, prefix] = el;
|
|
37
|
-
return (prefix ?? "") + ":" + name + (suffix ?? "");
|
|
38
|
-
})
|
|
39
|
-
.join("/"));
|
|
40
|
-
}
|
|
41
|
-
export const toEffect = toColon;
|
|
42
|
-
export function toURLPattern(tuple) {
|
|
43
|
-
return ("/" +
|
|
44
|
-
tuple
|
|
45
|
-
.map((el) => {
|
|
46
|
-
if (typeof el === "string")
|
|
47
|
-
return el;
|
|
48
|
-
if (Array.isArray(el[0]))
|
|
49
|
-
return ":" + el[0][0] + "+";
|
|
50
|
-
const [name, suffix, prefix] = el;
|
|
51
|
-
return (prefix ?? "") + ":" + name + (suffix ?? "");
|
|
52
|
-
})
|
|
53
|
-
.join("/"));
|
|
54
|
-
}
|
|
55
|
-
export function toRemix(tuple) {
|
|
56
|
-
return ("/" +
|
|
57
|
-
tuple
|
|
58
|
-
.map((el) => {
|
|
59
|
-
if (typeof el === "string")
|
|
60
|
-
return el;
|
|
61
|
-
if (Array.isArray(el[0]))
|
|
62
|
-
return "$";
|
|
63
|
-
const [name, suffix, prefix] = el;
|
|
64
|
-
return (prefix ?? "") + "$" + name + (suffix ?? "");
|
|
65
|
-
})
|
|
66
|
-
.join("/"));
|
|
67
|
-
}
|
|
68
|
-
export const toBun = toColon;
|
package/dist/Unique.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export declare const ALPHABET_BASE32_CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
2
|
-
export declare const ALPHABET_BASE32_RFC4648 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
3
|
-
export declare const ALPHABET_BASE64_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
4
|
-
export declare const ALPHABET_HEX = "0123456789abcdef";
|
|
5
|
-
/**
|
|
6
|
-
* Generate a random string for ids, session tokens, and API keys.
|
|
7
|
-
* It uses human-friendly crockford base32 encoding (5 bit of entropy per char)
|
|
8
|
-
*
|
|
9
|
-
* Minimal recommended length:
|
|
10
|
-
* - public ids: 16 chars (~80 bits)
|
|
11
|
-
* - API keys: 32 chars (~160 bits)
|
|
12
|
-
* - session tokens: 32-40 chars (~160-200 bits)
|
|
13
|
-
*/
|
|
14
|
-
export declare function token(length?: number): string;
|
|
15
|
-
export declare function bytes(length: number): Uint8Array;
|
|
16
|
-
export declare const UUID_NIL = "00000000-0000-0000-0000-000000000000";
|
|
17
|
-
export declare function uuid4(): string;
|
|
18
|
-
export declare function uuid7(time?: number): string;
|
|
19
|
-
/**
|
|
20
|
-
* Decode a 48-bit Unix timestamp (ms) from UUID7 or ULID.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* const bytes = Unique.uuid7Bytes()
|
|
24
|
-
* const timestamp = Unique.toTimestamp(bytes)
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* const bytes = Unique.ulidBytes()
|
|
28
|
-
* const timestamp = Unique.toTimestamp(bytes)
|
|
29
|
-
*/
|
|
30
|
-
export declare function toTimestamp(bytes: Uint8Array): number;
|
|
31
|
-
export declare function uuid7Bytes(time?: number): Uint8Array;
|
|
32
|
-
/**
|
|
33
|
-
* Convert UUID bytes to canonical (RFC9562) representation.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* Unique.formatUuid(new Uint8Array(16))
|
|
37
|
-
*/
|
|
38
|
-
export declare function formatUuid(bytes: Uint8Array): string;
|
|
39
|
-
export declare function ulid(time?: number): string;
|
|
40
|
-
export declare function ulidBytes(time?: number): Uint8Array;
|
|
41
|
-
/**
|
|
42
|
-
* Generate a nanoid-style random string.
|
|
43
|
-
*
|
|
44
|
-
* FUN_FACT: Original nanoid implementation uses base64url alphabet
|
|
45
|
-
* with non-standard custom order where charater form common words found
|
|
46
|
-
* in source code (like use, random, strict) to make gzip/brotli more efficient.
|
|
47
|
-
* It's qt lil opt from the times where web developers
|
|
48
|
-
* were competing to have the smallest possible bundle size.
|
|
49
|
-
*/
|
|
50
|
-
export declare function nanoid(size?: number, alphabet?: string): string;
|
package/dist/Unique.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
export const ALPHABET_BASE32_CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
2
|
-
export const ALPHABET_BASE32_RFC4648 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
3
|
-
export const ALPHABET_BASE64_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
4
|
-
export const ALPHABET_HEX = "0123456789abcdef";
|
|
5
|
-
/**
|
|
6
|
-
* Generate a random string for ids, session tokens, and API keys.
|
|
7
|
-
* It uses human-friendly crockford base32 encoding (5 bit of entropy per char)
|
|
8
|
-
*
|
|
9
|
-
* Minimal recommended length:
|
|
10
|
-
* - public ids: 16 chars (~80 bits)
|
|
11
|
-
* - API keys: 32 chars (~160 bits)
|
|
12
|
-
* - session tokens: 32-40 chars (~160-200 bits)
|
|
13
|
-
*/
|
|
14
|
-
export function token(length = 32) {
|
|
15
|
-
if (length <= 0)
|
|
16
|
-
return "";
|
|
17
|
-
const buf = new Uint8Array(length);
|
|
18
|
-
crypto.getRandomValues(buf);
|
|
19
|
-
let result = "";
|
|
20
|
-
for (let i = 0; i < buf.length; i++) {
|
|
21
|
-
result += ALPHABET_BASE32_CROCKFORD[buf[i] & 31];
|
|
22
|
-
}
|
|
23
|
-
return result;
|
|
24
|
-
}
|
|
25
|
-
export function bytes(length) {
|
|
26
|
-
const buf = new Uint8Array(length);
|
|
27
|
-
crypto.getRandomValues(buf);
|
|
28
|
-
return buf;
|
|
29
|
-
}
|
|
30
|
-
export const UUID_NIL = "00000000-0000-0000-0000-000000000000";
|
|
31
|
-
export function uuid4() {
|
|
32
|
-
return formatUuid(uuid4bytes());
|
|
33
|
-
}
|
|
34
|
-
export function uuid7(time = Date.now()) {
|
|
35
|
-
return formatUuid(uuid7Bytes(time));
|
|
36
|
-
}
|
|
37
|
-
function uuid4bytes() {
|
|
38
|
-
const buf = bytes(16);
|
|
39
|
-
buf[6] = (buf[6] & 0x0f) | 0x40; // version 4
|
|
40
|
-
buf[8] = (buf[8] & 0x3f) | 0x80; // variant
|
|
41
|
-
return buf;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Decode a 48-bit Unix timestamp (ms) from UUID7 or ULID.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* const bytes = Unique.uuid7Bytes()
|
|
48
|
-
* const timestamp = Unique.toTimestamp(bytes)
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* const bytes = Unique.ulidBytes()
|
|
52
|
-
* const timestamp = Unique.toTimestamp(bytes)
|
|
53
|
-
*/
|
|
54
|
-
export function toTimestamp(bytes) {
|
|
55
|
-
if (bytes.length < 6)
|
|
56
|
-
return 0;
|
|
57
|
-
return (bytes[0] * 0x10000000000 +
|
|
58
|
-
bytes[1] * 0x100000000 +
|
|
59
|
-
bytes[2] * 0x1000000 +
|
|
60
|
-
bytes[3] * 0x10000 +
|
|
61
|
-
bytes[4] * 0x100 +
|
|
62
|
-
bytes[5]);
|
|
63
|
-
}
|
|
64
|
-
export function uuid7Bytes(time = Date.now()) {
|
|
65
|
-
const buf = new Uint8Array(16);
|
|
66
|
-
const timestamp = BigInt(toSafeTime(time));
|
|
67
|
-
// 48-bit timestamp (6 bytes)
|
|
68
|
-
buf[0] = Number((timestamp >> 40n) & 0xffn);
|
|
69
|
-
buf[1] = Number((timestamp >> 32n) & 0xffn);
|
|
70
|
-
buf[2] = Number((timestamp >> 24n) & 0xffn);
|
|
71
|
-
buf[3] = Number((timestamp >> 16n) & 0xffn);
|
|
72
|
-
buf[4] = Number((timestamp >> 8n) & 0xffn);
|
|
73
|
-
buf[5] = Number(timestamp & 0xffn);
|
|
74
|
-
// 12-bit random A (1.5 bytes)
|
|
75
|
-
crypto.getRandomValues(buf.subarray(6, 8));
|
|
76
|
-
buf[6] = (buf[6] & 0x0f) | 0x70; // version 7
|
|
77
|
-
// 2-bit variant + 62-bit random B (8 bytes)
|
|
78
|
-
crypto.getRandomValues(buf.subarray(8, 16));
|
|
79
|
-
buf[8] = (buf[8] & 0x3f) | 0x80; // variant
|
|
80
|
-
return buf;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Convert UUID bytes to canonical (RFC9562) representation.
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* Unique.formatUuid(new Uint8Array(16))
|
|
87
|
-
*/
|
|
88
|
-
export function formatUuid(bytes) {
|
|
89
|
-
if (bytes.length === 0)
|
|
90
|
-
return "";
|
|
91
|
-
let result = "";
|
|
92
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
93
|
-
const byte = bytes[i];
|
|
94
|
-
result += ALPHABET_HEX[(byte >> 4) & 0x0f];
|
|
95
|
-
result += ALPHABET_HEX[byte & 0x0f];
|
|
96
|
-
if (i === 3 || i === 5 || i === 7 || i === 9)
|
|
97
|
-
result += "-";
|
|
98
|
-
}
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
|
-
export function ulid(time = Date.now()) {
|
|
102
|
-
const bytes = ulidBytes(time);
|
|
103
|
-
return formatUlid(bytes);
|
|
104
|
-
}
|
|
105
|
-
export function ulidBytes(time = Date.now()) {
|
|
106
|
-
const buf = new Uint8Array(16);
|
|
107
|
-
const timestamp = BigInt(toSafeTime(time));
|
|
108
|
-
buf[0] = Number((timestamp >> 40n) & 0xffn);
|
|
109
|
-
buf[1] = Number((timestamp >> 32n) & 0xffn);
|
|
110
|
-
buf[2] = Number((timestamp >> 24n) & 0xffn);
|
|
111
|
-
buf[3] = Number((timestamp >> 16n) & 0xffn);
|
|
112
|
-
buf[4] = Number((timestamp >> 8n) & 0xffn);
|
|
113
|
-
buf[5] = Number(timestamp & 0xffn);
|
|
114
|
-
crypto.getRandomValues(buf.subarray(6, 16));
|
|
115
|
-
return buf;
|
|
116
|
-
}
|
|
117
|
-
function formatUlid(bytes) {
|
|
118
|
-
if (bytes.length !== 16)
|
|
119
|
-
return "";
|
|
120
|
-
const timestamp = toTimestamp(bytes);
|
|
121
|
-
const timePart = encodeUlidTime(timestamp);
|
|
122
|
-
const randomPart = toBase32(bytes.subarray(6, 16));
|
|
123
|
-
return `${timePart}${randomPart}`;
|
|
124
|
-
}
|
|
125
|
-
function encodeUlidTime(time) {
|
|
126
|
-
let value = BigInt(time);
|
|
127
|
-
const result = Array.from({ length: 10 });
|
|
128
|
-
for (let i = 9; i >= 0; i--) {
|
|
129
|
-
result[i] = ALPHABET_BASE32_CROCKFORD[Number(value & 31n)];
|
|
130
|
-
value >>= 5n;
|
|
131
|
-
}
|
|
132
|
-
return result.join("");
|
|
133
|
-
}
|
|
134
|
-
function toSafeTime(time) {
|
|
135
|
-
if (!Number.isFinite(time))
|
|
136
|
-
return 0;
|
|
137
|
-
return Math.max(0, Math.trunc(time));
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Generate a nanoid-style random string.
|
|
141
|
-
*
|
|
142
|
-
* FUN_FACT: Original nanoid implementation uses base64url alphabet
|
|
143
|
-
* with non-standard custom order where charater form common words found
|
|
144
|
-
* in source code (like use, random, strict) to make gzip/brotli more efficient.
|
|
145
|
-
* It's qt lil opt from the times where web developers
|
|
146
|
-
* were competing to have the smallest possible bundle size.
|
|
147
|
-
*/
|
|
148
|
-
export function nanoid(size = 21, alphabet = ALPHABET_BASE64_URL) {
|
|
149
|
-
if (size <= 0 || alphabet.length === 0)
|
|
150
|
-
return "";
|
|
151
|
-
const length = alphabet.length;
|
|
152
|
-
const mask = (2 << Math.floor(Math.log2(length - 1))) - 1;
|
|
153
|
-
const step = Math.ceil((1.6 * mask * size) / length);
|
|
154
|
-
let id = "";
|
|
155
|
-
while (id.length < size) {
|
|
156
|
-
const bytes = new Uint8Array(step);
|
|
157
|
-
crypto.getRandomValues(bytes);
|
|
158
|
-
for (let i = 0; i < step && id.length < size; i++) {
|
|
159
|
-
const index = bytes[i] & mask;
|
|
160
|
-
if (index < length)
|
|
161
|
-
id += alphabet[index];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return id;
|
|
165
|
-
}
|
|
166
|
-
function toBase32(bytes, alphabet = ALPHABET_BASE32_CROCKFORD) {
|
|
167
|
-
if (bytes.length === 0)
|
|
168
|
-
return "";
|
|
169
|
-
let result = "";
|
|
170
|
-
let buffer = 0;
|
|
171
|
-
let bits = 0;
|
|
172
|
-
for (const byte of bytes) {
|
|
173
|
-
buffer = (buffer << 8) | byte;
|
|
174
|
-
bits += 8;
|
|
175
|
-
while (bits >= 5) {
|
|
176
|
-
bits -= 5;
|
|
177
|
-
const index = (buffer >> bits) & 31;
|
|
178
|
-
result += alphabet[index];
|
|
179
|
-
buffer &= (1 << bits) - 1;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (bits > 0) {
|
|
183
|
-
const index = (buffer << (5 - bits)) & 31;
|
|
184
|
-
result += alphabet[index];
|
|
185
|
-
}
|
|
186
|
-
return result;
|
|
187
|
-
}
|
package/dist/Values.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
type JsonPrimitives = string | number | boolean | null;
|
|
2
|
-
export type JsonObject = {
|
|
3
|
-
[key: string]: Json | undefined;
|
|
4
|
-
};
|
|
5
|
-
export type Json = JsonPrimitives | Json[] | JsonObject;
|
|
6
|
-
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
7
|
-
/**
|
|
8
|
-
* Type helper that returns `true` if type T has any method properties,
|
|
9
|
-
* otherwise returns `never`.
|
|
10
|
-
*
|
|
11
|
-
* Used internally by IsPlainObject to distinguish plain objects from
|
|
12
|
-
* class instances or objects with methods.
|
|
13
|
-
*/
|
|
14
|
-
type HasMethod<T> = {
|
|
15
|
-
[K in keyof T]: T[K] extends (...args: Array<any>) => any ? true : never;
|
|
16
|
-
}[keyof T];
|
|
17
|
-
export type IsPlainObject<T> = T extends object ? T extends Function ? false : HasMethod<T> extends never ? true : false : false;
|
|
18
|
-
export type Simplify<T> = {
|
|
19
|
-
-readonly [K in keyof T]: IsPlainObject<T[K]> extends true ? {
|
|
20
|
-
-readonly [P in keyof T[K]]: T[K][P];
|
|
21
|
-
} : T[K];
|
|
22
|
-
} extends infer U ? {
|
|
23
|
-
[K in keyof U]: U[K];
|
|
24
|
-
} : never;
|
|
25
|
-
export declare const firstValue: <T>(record: Record<string, T>) => T | undefined;
|
|
26
|
-
export declare const concatBytes: (a: Uint8Array, b: Uint8Array) => Uint8Array;
|
|
27
|
-
export {};
|
package/dist/Values.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export function isPlainObject(value) {
|
|
2
|
-
if (value === null || typeof value !== "object") {
|
|
3
|
-
return false;
|
|
4
|
-
}
|
|
5
|
-
// Check for built-in types and web APIs
|
|
6
|
-
if (ArrayBuffer.isView(value) ||
|
|
7
|
-
value instanceof ArrayBuffer ||
|
|
8
|
-
value instanceof Blob ||
|
|
9
|
-
value instanceof FormData ||
|
|
10
|
-
value instanceof URLSearchParams ||
|
|
11
|
-
value instanceof ReadableStream ||
|
|
12
|
-
value instanceof Date ||
|
|
13
|
-
value instanceof Map ||
|
|
14
|
-
value instanceof Set ||
|
|
15
|
-
value instanceof RegExp ||
|
|
16
|
-
value instanceof Error ||
|
|
17
|
-
value instanceof Promise ||
|
|
18
|
-
Array.isArray(value)) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
// Check if it's a plain object (Object.prototype or null prototype)
|
|
22
|
-
const proto = Object.getPrototypeOf(value);
|
|
23
|
-
return proto === null || proto === Object.prototype;
|
|
24
|
-
}
|
|
25
|
-
export const firstValue = (record) => {
|
|
26
|
-
for (const key in record) {
|
|
27
|
-
return record[key];
|
|
28
|
-
}
|
|
29
|
-
return undefined;
|
|
30
|
-
};
|
|
31
|
-
export const concatBytes = (a, b) => {
|
|
32
|
-
const result = new Uint8Array(a.byteLength + b.byteLength);
|
|
33
|
-
result.set(a);
|
|
34
|
-
result.set(b, a.byteLength);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import * as Chunk from "effect/Chunk";
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as Layer from "effect/Layer";
|
|
4
|
-
import * as Option from "effect/Option";
|
|
5
|
-
import * as Stream from "effect/Stream";
|
|
6
|
-
import * as NFS from "node:fs";
|
|
7
|
-
import * as NPath from "node:path";
|
|
8
|
-
import { BlobStore as BlobStoreTag } from "../BlobStore.js";
|
|
9
|
-
import * as PlatformError from "../PlatformError.js";
|
|
10
|
-
import { handleErrnoException } from "../node/NodeFileSystem.js";
|
|
11
|
-
const handleBadArgument = (method) => (cause) => new PlatformError.BadArgument({
|
|
12
|
-
module: "BlobStore",
|
|
13
|
-
method,
|
|
14
|
-
cause,
|
|
15
|
-
});
|
|
16
|
-
const handleErrno = (method) => handleErrnoException("BlobStore", method);
|
|
17
|
-
const tryPromise = (method, path, promise) => Effect.tryPromise({
|
|
18
|
-
try: promise,
|
|
19
|
-
catch: (err) => {
|
|
20
|
-
if (err instanceof Error && "code" in err) {
|
|
21
|
-
return handleErrno(method)(err, [path]);
|
|
22
|
-
}
|
|
23
|
-
return handleBadArgument(method)(err);
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
const validatePath = (directory, key) => {
|
|
27
|
-
const resolved = NPath.resolve(directory, key);
|
|
28
|
-
const root = NPath.resolve(directory);
|
|
29
|
-
if (resolved !== root && !resolved.startsWith(root + NPath.sep)) {
|
|
30
|
-
return Effect.fail(new PlatformError.BadArgument({
|
|
31
|
-
module: "BlobStore",
|
|
32
|
-
method: "ref",
|
|
33
|
-
description: `Path traversal: key "${key}" escapes directory "${directory}"`,
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
return Effect.succeed(resolved);
|
|
37
|
-
};
|
|
38
|
-
const makeRef = (directory, path, key, begin, end) => {
|
|
39
|
-
const getFile = () => {
|
|
40
|
-
const f = Bun.file(path);
|
|
41
|
-
return begin !== undefined || end !== undefined ? f.slice(begin, end) : f;
|
|
42
|
-
};
|
|
43
|
-
return {
|
|
44
|
-
key,
|
|
45
|
-
bytes: tryPromise("bytes", path, () => getFile().bytes()),
|
|
46
|
-
text: tryPromise("text", path, () => getFile().text()),
|
|
47
|
-
json: tryPromise("json", path, () => getFile().json()),
|
|
48
|
-
stat: Effect.flatMap(tryPromise("stat", path, () => Bun.file(path).stat()), (s) => Effect.succeed({
|
|
49
|
-
size: s.size,
|
|
50
|
-
lastModified: Option.fromNullable(s.mtime),
|
|
51
|
-
etag: Option.none(),
|
|
52
|
-
type: Option.fromNullable(Bun.file(path).type || null),
|
|
53
|
-
})),
|
|
54
|
-
exists: tryPromise("exists", path, () => Bun.file(path).exists()),
|
|
55
|
-
delete: tryPromise("delete", path, () => NFS.promises.unlink(path)),
|
|
56
|
-
stream: Stream.fromReadableStream(() => getFile().stream(), (err) => {
|
|
57
|
-
if (err instanceof Error && "code" in err) {
|
|
58
|
-
return handleErrno("stream")(err, [path]);
|
|
59
|
-
}
|
|
60
|
-
return handleBadArgument("stream")(err);
|
|
61
|
-
}),
|
|
62
|
-
write: (data) => tryPromise("write", path, () => Bun.write(path, data, { createPath: true }).then(() => undefined)),
|
|
63
|
-
slice: (b, e) => makeRef(directory, path, key, b, e),
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
const listEntries = (directory, options) => {
|
|
67
|
-
const baseDir = options?.prefix
|
|
68
|
-
? NPath.join(directory, options.prefix)
|
|
69
|
-
: directory;
|
|
70
|
-
return Stream.fromEffect(Effect.tryPromise({
|
|
71
|
-
try: async () => {
|
|
72
|
-
try {
|
|
73
|
-
const entries = await NFS.promises.readdir(baseDir, {
|
|
74
|
-
recursive: true,
|
|
75
|
-
withFileTypes: true,
|
|
76
|
-
});
|
|
77
|
-
return entries
|
|
78
|
-
.filter((e) => e.isFile())
|
|
79
|
-
.map((e) => {
|
|
80
|
-
const rel = NPath.join(e.parentPath, e.name);
|
|
81
|
-
const key = NPath.relative(directory, rel);
|
|
82
|
-
return {
|
|
83
|
-
key,
|
|
84
|
-
size: Option.none(),
|
|
85
|
-
lastModified: Option.none(),
|
|
86
|
-
etag: Option.none(),
|
|
87
|
-
};
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
catch (err) {
|
|
91
|
-
if (err instanceof Error && "code" in err && err.code === "ENOENT") {
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
|
-
throw err;
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
catch: (err) => {
|
|
98
|
-
if (err instanceof Error && "code" in err) {
|
|
99
|
-
return handleErrno("list")(err, [baseDir]);
|
|
100
|
-
}
|
|
101
|
-
return handleBadArgument("list")(err);
|
|
102
|
-
},
|
|
103
|
-
})).pipe(Stream.flatMap((entries) => Stream.fromChunk(Chunk.fromIterable(entries))));
|
|
104
|
-
};
|
|
105
|
-
export const layer = (config) => {
|
|
106
|
-
const directory = config?.directory ?? "/";
|
|
107
|
-
return Layer.succeed(BlobStoreTag, {
|
|
108
|
-
ref: (key) => Effect.map(validatePath(directory, key), (path) => makeRef(directory, path, key)),
|
|
109
|
-
list: (options) => listEntries(directory, options),
|
|
110
|
-
presign: (_key, _options) => Effect.fail(new PlatformError.BadArgument({
|
|
111
|
-
module: "BlobStore",
|
|
112
|
-
method: "presign",
|
|
113
|
-
description: "Presigned URLs are not supported for disk storage",
|
|
114
|
-
})),
|
|
115
|
-
});
|
|
116
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as Layer from "effect/Layer";
|
|
2
|
-
import { BlobStore as BlobStoreTag } from "../BlobStore.ts";
|
|
3
|
-
export interface S3Config {
|
|
4
|
-
readonly bucket?: string;
|
|
5
|
-
readonly endpoint?: string;
|
|
6
|
-
readonly region?: string;
|
|
7
|
-
readonly accessKeyId?: string;
|
|
8
|
-
readonly secretAccessKey?: string;
|
|
9
|
-
readonly sessionToken?: string;
|
|
10
|
-
}
|
|
11
|
-
export declare const layer: (config?: S3Config) => Layer.Layer<BlobStoreTag>;
|