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/SqlIntrospect.js
DELETED
|
@@ -1,466 +0,0 @@
|
|
|
1
|
-
import * as Effect from "effect/Effect";
|
|
2
|
-
import * as Schema from "effect/Schema";
|
|
3
|
-
import * as Sql from "./Sql.js";
|
|
4
|
-
// ---------------------------------------------------------------------------
|
|
5
|
-
// SQLite
|
|
6
|
-
// ---------------------------------------------------------------------------
|
|
7
|
-
const sqliteColumns = `
|
|
8
|
-
SELECT
|
|
9
|
-
'' as tableSchema,
|
|
10
|
-
m.name as tableName,
|
|
11
|
-
p.name as columnName,
|
|
12
|
-
p.cid + 1 as ordinalPosition,
|
|
13
|
-
p.dflt_value as columnDefault,
|
|
14
|
-
CASE WHEN p."notnull" = 0 THEN 1 ELSE 0 END as isNullable,
|
|
15
|
-
p.type as dataType,
|
|
16
|
-
NULL as maxLength,
|
|
17
|
-
p.pk as isPrimaryKey,
|
|
18
|
-
CASE WHEN p.pk = 1 AND lower(p.type) = 'integer' THEN 1 ELSE 0 END as isAutoIncrement
|
|
19
|
-
FROM sqlite_master m
|
|
20
|
-
JOIN pragma_table_info(m.name) p
|
|
21
|
-
WHERE m.type = 'table'
|
|
22
|
-
AND m.name NOT LIKE 'sqlite_%'
|
|
23
|
-
ORDER BY m.name, p.cid
|
|
24
|
-
`;
|
|
25
|
-
const sqliteForeignKeys = `
|
|
26
|
-
SELECT
|
|
27
|
-
'' as constraintName,
|
|
28
|
-
'' as tableSchema,
|
|
29
|
-
m.name as tableName,
|
|
30
|
-
fk."from" as columnName,
|
|
31
|
-
'' as referencedSchema,
|
|
32
|
-
fk."table" as referencedTable,
|
|
33
|
-
fk."to" as referencedColumn,
|
|
34
|
-
fk.on_update as updateRule,
|
|
35
|
-
fk.on_delete as deleteRule
|
|
36
|
-
FROM sqlite_master m
|
|
37
|
-
JOIN pragma_foreign_key_list(m.name) fk
|
|
38
|
-
WHERE m.type = 'table'
|
|
39
|
-
AND m.name NOT LIKE 'sqlite_%'
|
|
40
|
-
ORDER BY m.name, fk.seq
|
|
41
|
-
`;
|
|
42
|
-
const sqliteIndexes = `
|
|
43
|
-
SELECT
|
|
44
|
-
'' as tableSchema,
|
|
45
|
-
m.name as tableName,
|
|
46
|
-
il.name as indexName,
|
|
47
|
-
ii.name as columnName,
|
|
48
|
-
il."unique" as isUnique,
|
|
49
|
-
ii.seqno + 1 as ordinalPosition
|
|
50
|
-
FROM sqlite_master m
|
|
51
|
-
JOIN pragma_index_list(m.name) il
|
|
52
|
-
JOIN pragma_index_info(il.name) ii
|
|
53
|
-
WHERE m.type = 'table'
|
|
54
|
-
AND m.name NOT LIKE 'sqlite_%'
|
|
55
|
-
ORDER BY m.name, il.name, ii.seqno
|
|
56
|
-
`;
|
|
57
|
-
// ---------------------------------------------------------------------------
|
|
58
|
-
// PostgreSQL
|
|
59
|
-
// ---------------------------------------------------------------------------
|
|
60
|
-
const postgresColumns = `
|
|
61
|
-
SELECT
|
|
62
|
-
c.table_schema as "tableSchema",
|
|
63
|
-
c.table_name as "tableName",
|
|
64
|
-
c.column_name as "columnName",
|
|
65
|
-
c.ordinal_position as "ordinalPosition",
|
|
66
|
-
c.column_default as "columnDefault",
|
|
67
|
-
CASE WHEN c.is_nullable = 'YES' THEN true ELSE false END as "isNullable",
|
|
68
|
-
c.data_type as "dataType",
|
|
69
|
-
c.character_maximum_length as "maxLength",
|
|
70
|
-
CASE WHEN pk.column_name IS NOT NULL THEN true ELSE false END as "isPrimaryKey",
|
|
71
|
-
CASE WHEN c.column_default LIKE 'nextval(%' THEN true ELSE false END as "isAutoIncrement"
|
|
72
|
-
FROM information_schema.columns c
|
|
73
|
-
LEFT JOIN (
|
|
74
|
-
SELECT kcu.table_schema, kcu.table_name, kcu.column_name
|
|
75
|
-
FROM information_schema.table_constraints tc
|
|
76
|
-
JOIN information_schema.key_column_usage kcu
|
|
77
|
-
ON tc.constraint_name = kcu.constraint_name
|
|
78
|
-
AND tc.table_schema = kcu.table_schema
|
|
79
|
-
WHERE tc.constraint_type = 'PRIMARY KEY'
|
|
80
|
-
) pk
|
|
81
|
-
ON c.table_schema = pk.table_schema
|
|
82
|
-
AND c.table_name = pk.table_name
|
|
83
|
-
AND c.column_name = pk.column_name
|
|
84
|
-
WHERE c.table_schema NOT IN ('information_schema', 'pg_catalog')
|
|
85
|
-
ORDER BY c.table_schema, c.table_name, c.ordinal_position
|
|
86
|
-
`;
|
|
87
|
-
const postgresForeignKeys = `
|
|
88
|
-
SELECT
|
|
89
|
-
tc.constraint_name as "constraintName",
|
|
90
|
-
tc.table_schema as "tableSchema",
|
|
91
|
-
tc.table_name as "tableName",
|
|
92
|
-
kcu.column_name as "columnName",
|
|
93
|
-
ccu.table_schema as "referencedSchema",
|
|
94
|
-
ccu.table_name as "referencedTable",
|
|
95
|
-
ccu.column_name as "referencedColumn",
|
|
96
|
-
rc.update_rule as "updateRule",
|
|
97
|
-
rc.delete_rule as "deleteRule"
|
|
98
|
-
FROM information_schema.table_constraints tc
|
|
99
|
-
JOIN information_schema.key_column_usage kcu
|
|
100
|
-
ON tc.constraint_name = kcu.constraint_name
|
|
101
|
-
AND tc.table_schema = kcu.table_schema
|
|
102
|
-
JOIN information_schema.constraint_column_usage ccu
|
|
103
|
-
ON tc.constraint_name = ccu.constraint_name
|
|
104
|
-
AND tc.table_schema = ccu.table_schema
|
|
105
|
-
JOIN information_schema.referential_constraints rc
|
|
106
|
-
ON tc.constraint_name = rc.constraint_name
|
|
107
|
-
AND tc.table_schema = rc.constraint_schema
|
|
108
|
-
WHERE tc.constraint_type = 'FOREIGN KEY'
|
|
109
|
-
AND tc.table_schema NOT IN ('information_schema', 'pg_catalog')
|
|
110
|
-
ORDER BY tc.table_schema, tc.table_name, kcu.ordinal_position
|
|
111
|
-
`;
|
|
112
|
-
const postgresIndexes = `
|
|
113
|
-
SELECT
|
|
114
|
-
n.nspname as "tableSchema",
|
|
115
|
-
t.relname as "tableName",
|
|
116
|
-
i.relname as "indexName",
|
|
117
|
-
a.attname as "columnName",
|
|
118
|
-
ix.indisunique as "isUnique",
|
|
119
|
-
array_position(ix.indkey, a.attnum) as "ordinalPosition"
|
|
120
|
-
FROM pg_index ix
|
|
121
|
-
JOIN pg_class t ON t.oid = ix.indrelid
|
|
122
|
-
JOIN pg_class i ON i.oid = ix.indexrelid
|
|
123
|
-
JOIN pg_namespace n ON n.oid = t.relnamespace
|
|
124
|
-
JOIN pg_attribute a ON a.attrelid = t.oid
|
|
125
|
-
AND a.attnum = ANY(ix.indkey)
|
|
126
|
-
WHERE n.nspname NOT IN ('information_schema', 'pg_catalog')
|
|
127
|
-
ORDER BY n.nspname, t.relname, i.relname, array_position(ix.indkey, a.attnum)
|
|
128
|
-
`;
|
|
129
|
-
// ---------------------------------------------------------------------------
|
|
130
|
-
// SQL Server (MSSQL)
|
|
131
|
-
// ---------------------------------------------------------------------------
|
|
132
|
-
const mssqlColumns = `
|
|
133
|
-
SELECT
|
|
134
|
-
s.name as tableSchema,
|
|
135
|
-
t.name as tableName,
|
|
136
|
-
c.name as columnName,
|
|
137
|
-
c.column_id as ordinalPosition,
|
|
138
|
-
dc.definition as columnDefault,
|
|
139
|
-
c.is_nullable as isNullable,
|
|
140
|
-
tp.name as dataType,
|
|
141
|
-
c.max_length as maxLength,
|
|
142
|
-
CASE WHEN pk.column_id IS NOT NULL THEN 1 ELSE 0 END as isPrimaryKey,
|
|
143
|
-
c.is_identity as isAutoIncrement
|
|
144
|
-
FROM sys.tables t
|
|
145
|
-
JOIN sys.schemas s ON t.schema_id = s.schema_id
|
|
146
|
-
JOIN sys.columns c ON t.object_id = c.object_id
|
|
147
|
-
JOIN sys.types tp ON c.user_type_id = tp.user_type_id
|
|
148
|
-
LEFT JOIN sys.default_constraints dc ON c.default_object_id = dc.object_id
|
|
149
|
-
LEFT JOIN (
|
|
150
|
-
SELECT ic.object_id, ic.column_id
|
|
151
|
-
FROM sys.index_columns ic
|
|
152
|
-
JOIN sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id
|
|
153
|
-
WHERE i.is_primary_key = 1
|
|
154
|
-
) pk ON c.object_id = pk.object_id AND c.column_id = pk.column_id
|
|
155
|
-
WHERE t.is_ms_shipped = 0
|
|
156
|
-
ORDER BY s.name, t.name, c.column_id
|
|
157
|
-
`;
|
|
158
|
-
const mssqlForeignKeys = `
|
|
159
|
-
SELECT
|
|
160
|
-
fk.name as constraintName,
|
|
161
|
-
s.name as tableSchema,
|
|
162
|
-
t.name as tableName,
|
|
163
|
-
c.name as columnName,
|
|
164
|
-
rs.name as referencedSchema,
|
|
165
|
-
rt.name as referencedTable,
|
|
166
|
-
rc.name as referencedColumn,
|
|
167
|
-
fk.update_referential_action_desc as updateRule,
|
|
168
|
-
fk.delete_referential_action_desc as deleteRule
|
|
169
|
-
FROM sys.foreign_keys fk
|
|
170
|
-
JOIN sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id
|
|
171
|
-
JOIN sys.tables t ON fkc.parent_object_id = t.object_id
|
|
172
|
-
JOIN sys.schemas s ON t.schema_id = s.schema_id
|
|
173
|
-
JOIN sys.columns c ON fkc.parent_object_id = c.object_id AND fkc.parent_column_id = c.column_id
|
|
174
|
-
JOIN sys.tables rt ON fkc.referenced_object_id = rt.object_id
|
|
175
|
-
JOIN sys.schemas rs ON rt.schema_id = rs.schema_id
|
|
176
|
-
JOIN sys.columns rc ON fkc.referenced_object_id = rc.object_id AND fkc.referenced_column_id = rc.column_id
|
|
177
|
-
WHERE t.is_ms_shipped = 0
|
|
178
|
-
ORDER BY s.name, t.name, fkc.constraint_column_id
|
|
179
|
-
`;
|
|
180
|
-
const mssqlIndexes = `
|
|
181
|
-
SELECT
|
|
182
|
-
s.name as tableSchema,
|
|
183
|
-
t.name as tableName,
|
|
184
|
-
i.name as indexName,
|
|
185
|
-
c.name as columnName,
|
|
186
|
-
i.is_unique as isUnique,
|
|
187
|
-
ic.key_ordinal as ordinalPosition
|
|
188
|
-
FROM sys.indexes i
|
|
189
|
-
JOIN sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id
|
|
190
|
-
JOIN sys.tables t ON i.object_id = t.object_id
|
|
191
|
-
JOIN sys.schemas s ON t.schema_id = s.schema_id
|
|
192
|
-
JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id
|
|
193
|
-
WHERE t.is_ms_shipped = 0
|
|
194
|
-
AND i.name IS NOT NULL
|
|
195
|
-
AND i.is_primary_key = 0
|
|
196
|
-
AND ic.is_included_column = 0
|
|
197
|
-
ORDER BY s.name, t.name, i.name, ic.key_ordinal
|
|
198
|
-
`;
|
|
199
|
-
const dialectQueries = {
|
|
200
|
-
sqlite: { columns: sqliteColumns, foreignKeys: sqliteForeignKeys, indexes: sqliteIndexes },
|
|
201
|
-
postgres: {
|
|
202
|
-
columns: postgresColumns,
|
|
203
|
-
foreignKeys: postgresForeignKeys,
|
|
204
|
-
indexes: postgresIndexes,
|
|
205
|
-
},
|
|
206
|
-
mssql: { columns: mssqlColumns, foreignKeys: mssqlForeignKeys, indexes: mssqlIndexes },
|
|
207
|
-
};
|
|
208
|
-
// ---------------------------------------------------------------------------
|
|
209
|
-
// Introspect
|
|
210
|
-
// ---------------------------------------------------------------------------
|
|
211
|
-
const singleColumnIndexes = (indexes) => {
|
|
212
|
-
const countByIndex = new Map();
|
|
213
|
-
for (const idx of indexes) {
|
|
214
|
-
const key = `${idx.tableSchema}.${idx.tableName}.${idx.indexName}`;
|
|
215
|
-
const existing = countByIndex.get(key);
|
|
216
|
-
if (existing) {
|
|
217
|
-
existing.count++;
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
countByIndex.set(key, { count: 1, columnName: idx.columnName });
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
const result = new Set();
|
|
224
|
-
for (const [key, entry] of countByIndex) {
|
|
225
|
-
if (entry.count === 1) {
|
|
226
|
-
const tableKey = key.substring(0, key.lastIndexOf("."));
|
|
227
|
-
result.add(`${tableKey}.${entry.columnName}`);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return result;
|
|
231
|
-
};
|
|
232
|
-
const groupByTable = (columns, foreignKeys, indexes) => {
|
|
233
|
-
const sortable = singleColumnIndexes(indexes);
|
|
234
|
-
const tableMap = new Map();
|
|
235
|
-
for (const col of columns) {
|
|
236
|
-
const key = `${col.tableSchema}.${col.tableName}`;
|
|
237
|
-
const fullCol = {
|
|
238
|
-
...col,
|
|
239
|
-
isSortable: col.isPrimaryKey || sortable.has(`${key}.${col.columnName}`),
|
|
240
|
-
};
|
|
241
|
-
const existing = tableMap.get(key);
|
|
242
|
-
if (existing) {
|
|
243
|
-
;
|
|
244
|
-
existing.columns.push(fullCol);
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
tableMap.set(key, {
|
|
248
|
-
tableSchema: col.tableSchema,
|
|
249
|
-
tableName: col.tableName,
|
|
250
|
-
columns: [fullCol],
|
|
251
|
-
foreignKeys: [],
|
|
252
|
-
indexes: [],
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
for (const fk of foreignKeys) {
|
|
257
|
-
const key = `${fk.tableSchema}.${fk.tableName}`;
|
|
258
|
-
const table = tableMap.get(key);
|
|
259
|
-
if (table) {
|
|
260
|
-
;
|
|
261
|
-
table.foreignKeys.push(fk);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
for (const idx of indexes) {
|
|
265
|
-
const key = `${idx.tableSchema}.${idx.tableName}`;
|
|
266
|
-
const table = tableMap.get(key);
|
|
267
|
-
if (table) {
|
|
268
|
-
;
|
|
269
|
-
table.indexes.push(idx);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return Array.from(tableMap.values());
|
|
273
|
-
};
|
|
274
|
-
const normalizeBooleans = (columns) => columns.map((c) => ({
|
|
275
|
-
...c,
|
|
276
|
-
isNullable: Boolean(c.isNullable),
|
|
277
|
-
isPrimaryKey: Boolean(c.isPrimaryKey),
|
|
278
|
-
isAutoIncrement: Boolean(c.isAutoIncrement),
|
|
279
|
-
}));
|
|
280
|
-
export const introspect = (dialect, options) => Effect.gen(function* () {
|
|
281
|
-
const sql = yield* Sql.SqlClient;
|
|
282
|
-
const q = dialectQueries[dialect];
|
|
283
|
-
const columns = normalizeBooleans(yield* sql.unsafe(q.columns));
|
|
284
|
-
const foreignKeys = options?.foreignKeys !== false ? yield* sql.unsafe(q.foreignKeys) : [];
|
|
285
|
-
const indexes = options?.indexes !== false
|
|
286
|
-
? (yield* sql.unsafe(q.indexes)).map((i) => ({
|
|
287
|
-
...i,
|
|
288
|
-
isUnique: Boolean(i.isUnique),
|
|
289
|
-
}))
|
|
290
|
-
: [];
|
|
291
|
-
return { tables: groupByTable(columns, foreignKeys, indexes) };
|
|
292
|
-
});
|
|
293
|
-
// ---------------------------------------------------------------------------
|
|
294
|
-
// Column → Schema mapping
|
|
295
|
-
// ---------------------------------------------------------------------------
|
|
296
|
-
const dataTypeToSchema = (dataType) => {
|
|
297
|
-
const t = dataType.toLowerCase();
|
|
298
|
-
if (t === "integer" ||
|
|
299
|
-
t === "int" ||
|
|
300
|
-
t === "int4" ||
|
|
301
|
-
t === "int8" ||
|
|
302
|
-
t === "smallint" ||
|
|
303
|
-
t === "tinyint" ||
|
|
304
|
-
t === "mediumint" ||
|
|
305
|
-
t === "bigint" ||
|
|
306
|
-
t === "int2")
|
|
307
|
-
return Schema.Number;
|
|
308
|
-
if (t === "real" ||
|
|
309
|
-
t === "double" ||
|
|
310
|
-
t === "double precision" ||
|
|
311
|
-
t === "float" ||
|
|
312
|
-
t === "float4" ||
|
|
313
|
-
t === "float8" ||
|
|
314
|
-
t === "numeric" ||
|
|
315
|
-
t === "decimal" ||
|
|
316
|
-
t === "money" ||
|
|
317
|
-
t === "smallmoney")
|
|
318
|
-
return Schema.Number;
|
|
319
|
-
if (t === "text" ||
|
|
320
|
-
t === "varchar" ||
|
|
321
|
-
t === "char" ||
|
|
322
|
-
t === "nchar" ||
|
|
323
|
-
t === "nvarchar" ||
|
|
324
|
-
t === "ntext" ||
|
|
325
|
-
t === "character varying" ||
|
|
326
|
-
t === "character" ||
|
|
327
|
-
t === "bpchar" ||
|
|
328
|
-
t === "uuid" ||
|
|
329
|
-
t === "citext" ||
|
|
330
|
-
t === "name" ||
|
|
331
|
-
t === "xml")
|
|
332
|
-
return Schema.String;
|
|
333
|
-
if (t === "boolean" || t === "bool" || t === "bit")
|
|
334
|
-
return Schema.Union(Schema.Boolean, Schema.Number);
|
|
335
|
-
if (t === "timestamp" ||
|
|
336
|
-
t === "timestamptz" ||
|
|
337
|
-
t === "timestamp with time zone" ||
|
|
338
|
-
t === "timestamp without time zone" ||
|
|
339
|
-
t === "date" ||
|
|
340
|
-
t === "datetime" ||
|
|
341
|
-
t === "datetime2" ||
|
|
342
|
-
t === "smalldatetime" ||
|
|
343
|
-
t === "datetimeoffset" ||
|
|
344
|
-
t === "time")
|
|
345
|
-
return Schema.String;
|
|
346
|
-
if (t === "json" || t === "jsonb")
|
|
347
|
-
return Schema.Unknown;
|
|
348
|
-
if (t === "blob" || t === "bytea" || t === "varbinary" || t === "binary" || t === "image")
|
|
349
|
-
return null;
|
|
350
|
-
return null;
|
|
351
|
-
};
|
|
352
|
-
const columnToSchema = (col) => {
|
|
353
|
-
const base = dataTypeToSchema(col.dataType);
|
|
354
|
-
if (base === null)
|
|
355
|
-
return null;
|
|
356
|
-
if (col.isNullable)
|
|
357
|
-
return Schema.NullOr(base);
|
|
358
|
-
return base;
|
|
359
|
-
};
|
|
360
|
-
export const tableToSchema = (table) => {
|
|
361
|
-
const fields = {};
|
|
362
|
-
let hasFields = false;
|
|
363
|
-
for (const col of table.columns) {
|
|
364
|
-
const s = columnToSchema(col);
|
|
365
|
-
if (s === null)
|
|
366
|
-
continue;
|
|
367
|
-
fields[col.columnName] = s;
|
|
368
|
-
hasFields = true;
|
|
369
|
-
}
|
|
370
|
-
if (!hasFields)
|
|
371
|
-
return null;
|
|
372
|
-
return {
|
|
373
|
-
tableName: table.tableName,
|
|
374
|
-
tableSchema: table.tableSchema,
|
|
375
|
-
schema: Schema.Struct(fields),
|
|
376
|
-
columns: table.columns.filter((c) => columnToSchema(c) !== null),
|
|
377
|
-
};
|
|
378
|
-
};
|
|
379
|
-
export const toSchemas = (db) => db.tables.flatMap((t) => {
|
|
380
|
-
const s = tableToSchema(t);
|
|
381
|
-
return s ? [s] : [];
|
|
382
|
-
});
|
|
383
|
-
const escapeIdentifier = (id) => `"${id.replace(/"/g, '""')}"`;
|
|
384
|
-
const buildWhereClause = (filters, columnSet, paramOffset) => {
|
|
385
|
-
const conditions = [];
|
|
386
|
-
const values = [];
|
|
387
|
-
for (const f of filters) {
|
|
388
|
-
if (!columnSet.has(f.column))
|
|
389
|
-
continue;
|
|
390
|
-
const col = escapeIdentifier(f.column);
|
|
391
|
-
const paramIndex = paramOffset + values.length + 1;
|
|
392
|
-
if (f.value === null) {
|
|
393
|
-
conditions.push(f.op === "eq" ? `${col} IS NULL` : `${col} IS NOT NULL`);
|
|
394
|
-
}
|
|
395
|
-
else {
|
|
396
|
-
conditions.push(`${col} ${f.op === "eq" ? "=" : "!="} $${paramIndex}`);
|
|
397
|
-
values.push(f.value);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
return {
|
|
401
|
-
clause: conditions.length > 0 ? ` WHERE ${conditions.join(" AND ")}` : "",
|
|
402
|
-
values,
|
|
403
|
-
};
|
|
404
|
-
};
|
|
405
|
-
const makeTableReader = (ts) => {
|
|
406
|
-
const qualifiedName = ts.tableSchema
|
|
407
|
-
? `${escapeIdentifier(ts.tableSchema)}.${escapeIdentifier(ts.tableName)}`
|
|
408
|
-
: escapeIdentifier(ts.tableName);
|
|
409
|
-
const primaryKey = ts.columns.find((c) => c.isPrimaryKey);
|
|
410
|
-
const selectCols = ts.columns.map((c) => escapeIdentifier(c.columnName)).join(", ");
|
|
411
|
-
const columnSet = new Set(ts.columns.map((c) => c.columnName));
|
|
412
|
-
const sortableSet = new Set(ts.columns.filter((c) => c.isSortable).map((c) => c.columnName));
|
|
413
|
-
return {
|
|
414
|
-
tableName: ts.tableName,
|
|
415
|
-
tableSchema: ts.tableSchema,
|
|
416
|
-
schema: ts.schema,
|
|
417
|
-
columns: ts.columns,
|
|
418
|
-
sortableColumns: Array.from(sortableSet),
|
|
419
|
-
findAll: (options) => Effect.gen(function* () {
|
|
420
|
-
const sql = yield* Sql.SqlClient;
|
|
421
|
-
let query = `SELECT ${selectCols} FROM ${qualifiedName}`;
|
|
422
|
-
const where = options?.filters
|
|
423
|
-
? buildWhereClause(options.filters, columnSet, 0)
|
|
424
|
-
: { clause: "", values: [] };
|
|
425
|
-
query += where.clause;
|
|
426
|
-
if (options?.sort && options.sort.length > 0) {
|
|
427
|
-
const sortClauses = options.sort
|
|
428
|
-
.filter((s) => sortableSet.has(s.column))
|
|
429
|
-
.map((s) => `${escapeIdentifier(s.column)} ${s.reverse ? "DESC" : "ASC"}`);
|
|
430
|
-
if (sortClauses.length > 0)
|
|
431
|
-
query += ` ORDER BY ${sortClauses.join(", ")}`;
|
|
432
|
-
}
|
|
433
|
-
if (options?.limit !== undefined)
|
|
434
|
-
query += ` LIMIT ${Number(options.limit)}`;
|
|
435
|
-
if (options?.offset !== undefined)
|
|
436
|
-
query += ` OFFSET ${Number(options.offset)}`;
|
|
437
|
-
return yield* sql.unsafe(query, where.values);
|
|
438
|
-
}),
|
|
439
|
-
findById: (id) => Effect.gen(function* () {
|
|
440
|
-
if (!primaryKey)
|
|
441
|
-
return null;
|
|
442
|
-
const sql = yield* Sql.SqlClient;
|
|
443
|
-
const query = `SELECT ${selectCols} FROM ${qualifiedName} WHERE ${escapeIdentifier(primaryKey.columnName)} = $1`;
|
|
444
|
-
const rows = yield* sql.unsafe(query, [id]);
|
|
445
|
-
return rows[0] ?? null;
|
|
446
|
-
}),
|
|
447
|
-
count: (options) => Effect.gen(function* () {
|
|
448
|
-
const sql = yield* Sql.SqlClient;
|
|
449
|
-
let query = `SELECT COUNT(*) as count FROM ${qualifiedName}`;
|
|
450
|
-
const where = options?.filters
|
|
451
|
-
? buildWhereClause(options.filters, columnSet, 0)
|
|
452
|
-
: { clause: "", values: [] };
|
|
453
|
-
query += where.clause;
|
|
454
|
-
const rows = yield* sql.unsafe(query, where.values);
|
|
455
|
-
return Number(rows[0].count);
|
|
456
|
-
}),
|
|
457
|
-
};
|
|
458
|
-
};
|
|
459
|
-
export const makeDatabaseReader = (db) => {
|
|
460
|
-
const schemas = toSchemas(db);
|
|
461
|
-
const readers = schemas.map(makeTableReader);
|
|
462
|
-
return {
|
|
463
|
-
tables: readers,
|
|
464
|
-
table: (name) => readers.find((r) => r.tableName === name),
|
|
465
|
-
};
|
|
466
|
-
};
|
package/dist/Start.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type * as FileSystem from "./FileSystem.ts";
|
|
2
|
-
import * as Layer from "effect/Layer";
|
|
3
|
-
import type * as ChildProcess from "./ChildProcess.ts";
|
|
4
|
-
import * as BunServer from "./bun/BunServer.ts";
|
|
5
|
-
export declare function layer<Layers extends [Layer.Layer<never, any, any>, ...Array<Layer.Layer<never, any, any>>]>(...layers: Layers): Layer.Layer<{
|
|
6
|
-
[k in keyof Layers]: Layer.Layer.Success<Layers[k]>;
|
|
7
|
-
}[number], {
|
|
8
|
-
[k in keyof Layers]: Layer.Layer.Error<Layers[k]>;
|
|
9
|
-
}[number], {
|
|
10
|
-
[k in keyof Layers]: Layer.Layer.Context<Layers[k]>;
|
|
11
|
-
}[number]>;
|
|
12
|
-
/**
|
|
13
|
-
* Bundles layers together, wiring their dependencies automatically.
|
|
14
|
-
*
|
|
15
|
-
* Equivalent to chaining `Layer.provide` calls, but more concise.
|
|
16
|
-
*
|
|
17
|
-
* **Ordering: dependents first, dependencies last.**
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* // UserRepo needs Database, Database needs Logger
|
|
22
|
-
* const AppLayer = Start.pack(
|
|
23
|
-
* UserRepoLive, // needs Database, Logger
|
|
24
|
-
* DatabaseLive, // needs Logger
|
|
25
|
-
* LoggerLive, // no deps
|
|
26
|
-
* )
|
|
27
|
-
* // Result: Layer<UserRepo | Database | Logger, never, never>
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @since 1.0.0
|
|
31
|
-
* @category constructors
|
|
32
|
-
*/
|
|
33
|
-
export declare function pack<const Layers extends readonly [Layer.Layer.Any, ...Array<Layer.Layer.Any>]>(...layers: Layers): Layer.Layer<{
|
|
34
|
-
[K in keyof Layers]: Layer.Layer.Success<Layers[K]>;
|
|
35
|
-
}[number], {
|
|
36
|
-
[K in keyof Layers]: Layer.Layer.Error<Layers[K]>;
|
|
37
|
-
}[number], Exclude<{
|
|
38
|
-
[K in keyof Layers]: Layer.Layer.Context<Layers[K]>;
|
|
39
|
-
}[number], {
|
|
40
|
-
[K in keyof Layers]: Layer.Layer.Success<Layers[K]>;
|
|
41
|
-
}[number]>>;
|
|
42
|
-
export declare function serve<ROut, E, RIn extends BunServer.BunServer | FileSystem.FileSystem | ChildProcess.ChildProcessSpawner>(load: () => Promise<{
|
|
43
|
-
default: Layer.Layer<ROut, E, RIn>;
|
|
44
|
-
}>): void;
|
package/dist/Start.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as Context from "effect/Context";
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as Function from "effect/Function";
|
|
4
|
-
import * as Layer from "effect/Layer";
|
|
5
|
-
import * as Option from "effect/Option";
|
|
6
|
-
import * as BunRuntime from "./bun/BunRuntime.js";
|
|
7
|
-
import * as BunServer from "./bun/BunServer.js";
|
|
8
|
-
import * as NodeFileSystem from "./node/NodeFileSystem.js";
|
|
9
|
-
import * as BunChildProcessSpawner from "./bun/BunChildProcessSpawner.js";
|
|
10
|
-
export function layer(...layers) {
|
|
11
|
-
return Layer.mergeAll(...layers);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Bundles layers together, wiring their dependencies automatically.
|
|
15
|
-
*
|
|
16
|
-
* Equivalent to chaining `Layer.provide` calls, but more concise.
|
|
17
|
-
*
|
|
18
|
-
* **Ordering: dependents first, dependencies last.**
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```ts
|
|
22
|
-
* // UserRepo needs Database, Database needs Logger
|
|
23
|
-
* const AppLayer = Start.pack(
|
|
24
|
-
* UserRepoLive, // needs Database, Logger
|
|
25
|
-
* DatabaseLive, // needs Logger
|
|
26
|
-
* LoggerLive, // no deps
|
|
27
|
-
* )
|
|
28
|
-
* // Result: Layer<UserRepo | Database | Logger, never, never>
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @since 1.0.0
|
|
32
|
-
* @category constructors
|
|
33
|
-
*/
|
|
34
|
-
export function pack(...layers) {
|
|
35
|
-
const layerArray = layers;
|
|
36
|
-
const result = layerArray.reduce((acc, layer) => Layer.provideMerge(acc, layer), Layer.succeedContext(Context.empty()));
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
export function serve(load) {
|
|
40
|
-
const appLayer = Function.pipe(Effect.tryPromise(load), Effect.map((v) => v.default), Effect.orDie, Layer.unwrapEffect);
|
|
41
|
-
const serverLayer = Layer.scoped(BunServer.BunServer, Effect.gen(function* () {
|
|
42
|
-
const existing = yield* Effect.serviceOption(BunServer.BunServer);
|
|
43
|
-
if (Option.isSome(existing))
|
|
44
|
-
return existing.value;
|
|
45
|
-
return yield* BunServer.make({});
|
|
46
|
-
}));
|
|
47
|
-
const composed = Function.pipe(serverLayer, BunServer.withLogAddress, Layer.provide(appLayer), Layer.provide(NodeFileSystem.layer), Layer.provide(BunChildProcessSpawner.layer));
|
|
48
|
-
return Function.pipe(composed, Layer.launch, BunRuntime.runMain);
|
|
49
|
-
}
|
package/dist/StartApp.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as HttpApp from "@effect/platform/HttpApp";
|
|
2
|
-
import * as Context from "effect/Context";
|
|
3
|
-
import * as Effect from "effect/Effect";
|
|
4
|
-
import * as Layer from "effect/Layer";
|
|
5
|
-
import * as PubSub from "effect/PubSub";
|
|
6
|
-
import * as Ref from "effect/Ref";
|
|
7
|
-
type StartMiddleware = <E, R>(self: HttpApp.Default<E, R>) => HttpApp.Default<never, never>;
|
|
8
|
-
declare const StartApp_base: Context.TagClass<StartApp, "effect-start/StartApp", {
|
|
9
|
-
readonly env: "development" | "production" | string;
|
|
10
|
-
readonly addMiddleware: (middleware: StartMiddleware) => Effect.Effect<void>;
|
|
11
|
-
readonly middleware: Ref.Ref<StartMiddleware>;
|
|
12
|
-
readonly events: PubSub.PubSub<any>;
|
|
13
|
-
}>;
|
|
14
|
-
export declare class StartApp extends StartApp_base {
|
|
15
|
-
}
|
|
16
|
-
export declare function layer(options?: {
|
|
17
|
-
env?: string;
|
|
18
|
-
}): Layer.Layer<StartApp, never, never>;
|
|
19
|
-
export {};
|
package/dist/StartApp.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as Context from "effect/Context";
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as Function from "effect/Function";
|
|
4
|
-
import * as Layer from "effect/Layer";
|
|
5
|
-
import * as PubSub from "effect/PubSub";
|
|
6
|
-
import * as Ref from "effect/Ref";
|
|
7
|
-
export class StartApp extends Context.Tag("effect-start/StartApp")() {
|
|
8
|
-
}
|
|
9
|
-
export function layer(options) {
|
|
10
|
-
return Layer.effect(StartApp, Effect.gen(function* () {
|
|
11
|
-
const env = options?.env ?? process.env.NODE_ENV ?? "development";
|
|
12
|
-
const middleware = yield* Ref.make(Function.identity);
|
|
13
|
-
const events = yield* PubSub.unbounded();
|
|
14
|
-
return StartApp.of({
|
|
15
|
-
env,
|
|
16
|
-
middleware,
|
|
17
|
-
addMiddleware: (f) => Ref.update(middleware, (prev) => (app) => f(prev(app))),
|
|
18
|
-
events,
|
|
19
|
-
});
|
|
20
|
-
}));
|
|
21
|
-
}
|
package/dist/StreamExtra.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import * as Runtime from "effect/Runtime";
|
|
2
|
-
import * as Stream from "effect/Stream";
|
|
3
|
-
export declare const isStream: (u: unknown) => u is Stream.Stream<unknown, unknown, unknown>;
|
|
4
|
-
export type IsStream<T> = T extends Stream.Stream<infer _A, infer _E, infer _R> ? true : false;
|
|
5
|
-
export type Chunk<T> = T extends Stream.Stream<infer A, infer _E, infer _R> ? A : never;
|
|
6
|
-
export type StreamError<T> = T extends Stream.Stream<infer _A, infer E, infer _R> ? E : never;
|
|
7
|
-
export type Context<T> = T extends Stream.Stream<infer _A, infer _E, infer R> ? R : never;
|
|
8
|
-
/**
|
|
9
|
-
* Patched version of original Stream.toReadableStreamRuntime (v3.14.4) to
|
|
10
|
-
* fix an issue in Bun when native stream controller stops working when request
|
|
11
|
-
* is terminated by the client:
|
|
12
|
-
*
|
|
13
|
-
* TypeError: Value of "this" must be of type ReadableStreamDefaultController
|
|
14
|
-
*
|
|
15
|
-
* See related issues:
|
|
16
|
-
* https://github.com/Effect-TS/effect/issues/4538
|
|
17
|
-
* https://github.com/oven-sh/bun/issues/17837
|
|
18
|
-
*/
|
|
19
|
-
export declare const toReadableStreamRuntimePatched: (<A, XR>(runtime: Runtime.Runtime<XR>, options?: {
|
|
20
|
-
readonly strategy?: QueuingStrategy<A> | undefined;
|
|
21
|
-
}) => <E, R extends XR>(self: Stream.Stream<A, E, R>) => ReadableStream<A>) & (<A, E, XR, R extends XR>(self: Stream.Stream<A, E, R>, runtime: Runtime.Runtime<XR>, options?: {
|
|
22
|
-
readonly strategy?: QueuingStrategy<A> | undefined;
|
|
23
|
-
}) => ReadableStream<A>);
|
|
24
|
-
export declare const toReadableStreamRuntimePatched2: (<A, XR>(runtime: Runtime.Runtime<XR>, options?: {
|
|
25
|
-
readonly strategy?: QueuingStrategy<A> | undefined;
|
|
26
|
-
}) => <E, R extends XR>(self: Stream.Stream<A, E, R>) => ReadableStream<A>) & (<A, E, XR, R extends XR>(self: Stream.Stream<A, E, R>, runtime: Runtime.Runtime<XR>, options?: {
|
|
27
|
-
readonly strategy?: QueuingStrategy<A> | undefined;
|
|
28
|
-
}) => ReadableStream<A>);
|