effect-start 0.18.0 → 0.20.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/README.md +3 -3
- package/dist/Development.d.ts +8 -3
- package/dist/Development.js +14 -7
- package/dist/Effectify.d.ts +212 -0
- package/dist/Effectify.js +19 -0
- package/dist/FilePathPattern.d.ts +29 -0
- package/dist/FilePathPattern.js +86 -0
- package/dist/FileRouter.d.ts +39 -41
- package/dist/FileRouter.js +104 -158
- package/dist/FileRouterCodegen.d.ts +7 -8
- package/dist/FileRouterCodegen.js +97 -66
- package/dist/PlatformError.d.ts +46 -0
- package/dist/PlatformError.js +43 -0
- package/dist/PlatformRuntime.d.ts +27 -0
- package/dist/PlatformRuntime.js +51 -0
- package/dist/Route.d.ts +6 -2
- package/dist/Route.js +22 -0
- package/dist/RouteBody.d.ts +1 -1
- package/dist/RouteHttp.d.ts +1 -1
- package/dist/RouteHttp.js +12 -19
- package/dist/RouteMount.d.ts +2 -1
- package/dist/Start.d.ts +33 -6
- package/dist/Start.js +31 -13
- package/dist/Unique.d.ts +50 -0
- package/dist/Unique.js +187 -0
- package/dist/bun/BunHttpServer.js +5 -6
- package/dist/bun/BunPlatformHttpServer.d.ts +10 -0
- package/dist/bun/BunPlatformHttpServer.js +53 -0
- package/dist/bun/BunRoute.d.ts +4 -6
- package/dist/bun/BunRoute.js +10 -18
- package/dist/bun/BunRuntime.d.ts +2 -1
- package/dist/bun/BunRuntime.js +10 -5
- package/dist/bun/BunServer.d.ts +33 -0
- package/dist/bun/BunServer.js +133 -0
- package/dist/bun/BunServerRequest.d.ts +60 -0
- package/dist/bun/BunServerRequest.js +252 -0
- package/dist/bun/index.d.ts +1 -1
- package/dist/bun/index.js +1 -1
- package/dist/datastar/actions/fetch.d.ts +30 -0
- package/dist/datastar/actions/fetch.js +411 -0
- package/dist/datastar/actions/peek.d.ts +1 -0
- package/dist/datastar/actions/peek.js +14 -0
- package/dist/datastar/actions/setAll.d.ts +1 -0
- package/dist/datastar/actions/setAll.js +13 -0
- package/dist/datastar/actions/toggleAll.d.ts +1 -0
- package/dist/datastar/actions/toggleAll.js +13 -0
- package/dist/datastar/attributes/attr.d.ts +1 -0
- package/dist/datastar/attributes/attr.js +49 -0
- package/dist/datastar/attributes/bind.d.ts +1 -0
- package/dist/datastar/attributes/bind.js +183 -0
- package/dist/datastar/attributes/class.d.ts +1 -0
- package/dist/datastar/attributes/class.js +50 -0
- package/dist/datastar/attributes/computed.d.ts +1 -0
- package/dist/datastar/attributes/computed.js +27 -0
- package/dist/datastar/attributes/effect.d.ts +1 -0
- package/dist/datastar/attributes/effect.js +10 -0
- package/dist/datastar/attributes/indicator.d.ts +1 -0
- package/dist/datastar/attributes/indicator.js +32 -0
- package/dist/datastar/attributes/init.d.ts +1 -0
- package/dist/datastar/attributes/init.js +27 -0
- package/dist/datastar/attributes/jsonSignals.d.ts +1 -0
- package/dist/datastar/attributes/jsonSignals.js +31 -0
- package/dist/datastar/attributes/on.d.ts +1 -0
- package/dist/datastar/attributes/on.js +59 -0
- package/dist/datastar/attributes/onIntersect.d.ts +1 -0
- package/dist/datastar/attributes/onIntersect.js +54 -0
- package/dist/datastar/attributes/onInterval.d.ts +1 -0
- package/dist/datastar/attributes/onInterval.js +31 -0
- package/dist/datastar/attributes/onSignalPatch.d.ts +1 -0
- package/dist/datastar/attributes/onSignalPatch.js +44 -0
- package/dist/datastar/attributes/ref.d.ts +1 -0
- package/dist/datastar/attributes/ref.js +11 -0
- package/dist/datastar/attributes/show.d.ts +1 -0
- package/dist/datastar/attributes/show.js +32 -0
- package/dist/datastar/attributes/signals.d.ts +1 -0
- package/dist/datastar/attributes/signals.js +18 -0
- package/dist/datastar/attributes/style.d.ts +1 -0
- package/dist/datastar/attributes/style.js +56 -0
- package/dist/datastar/attributes/text.d.ts +1 -0
- package/dist/datastar/attributes/text.js +27 -0
- package/dist/datastar/engine.d.ts +156 -0
- package/dist/datastar/engine.js +971 -0
- package/dist/datastar/index.d.ts +24 -0
- package/dist/datastar/index.js +24 -0
- package/dist/datastar/load.d.ts +24 -0
- package/dist/datastar/load.js +24 -0
- package/dist/datastar/utils.d.ts +51 -0
- package/dist/datastar/utils.js +205 -0
- package/dist/datastar/watchers/patchElements.d.ts +1 -0
- package/dist/datastar/watchers/patchElements.js +420 -0
- package/dist/datastar/watchers/patchSignals.d.ts +1 -0
- package/dist/datastar/watchers/patchSignals.js +15 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/node/Effectify.d.ts +209 -0
- package/dist/node/Effectify.js +19 -0
- package/dist/node/FileSystem.d.ts +3 -5
- package/dist/node/FileSystem.js +42 -62
- package/dist/node/NodeFileSystem.d.ts +7 -0
- package/dist/node/NodeFileSystem.js +420 -0
- package/dist/node/NodeUtils.d.ts +2 -0
- package/dist/node/NodeUtils.js +20 -0
- package/dist/node/PlatformError.d.ts +46 -0
- package/dist/node/PlatformError.js +43 -0
- package/dist/testing/TestLogger.js +1 -1
- package/dist/x/tailwind/plugin.js +1 -1
- package/package.json +18 -7
- package/src/Development.ts +36 -40
- package/src/Effectify.ts +269 -0
- package/src/FilePathPattern.ts +115 -0
- package/src/FileRouter.ts +178 -255
- package/src/FileRouterCodegen.ts +135 -92
- package/src/PlatformError.ts +117 -0
- package/src/PlatformRuntime.ts +108 -0
- package/src/Route.ts +31 -2
- package/src/RouteBody.ts +1 -1
- package/src/RouteHttp.ts +15 -29
- package/src/RouteMount.ts +1 -1
- package/src/Start.ts +61 -27
- package/src/Unique.ts +232 -0
- package/src/bun/BunPlatformHttpServer.ts +88 -0
- package/src/bun/BunRoute.ts +14 -24
- package/src/bun/BunRuntime.ts +21 -5
- package/src/bun/BunServer.ts +228 -0
- package/src/bun/index.ts +1 -1
- package/src/datastar/README.md +18 -0
- package/src/datastar/actions/fetch.ts +609 -0
- package/src/datastar/actions/peek.ts +17 -0
- package/src/datastar/actions/setAll.ts +20 -0
- package/src/datastar/actions/toggleAll.ts +20 -0
- package/src/datastar/attributes/attr.ts +50 -0
- package/src/datastar/attributes/bind.ts +220 -0
- package/src/datastar/attributes/class.ts +57 -0
- package/src/datastar/attributes/computed.ts +33 -0
- package/src/datastar/attributes/effect.ts +11 -0
- package/src/datastar/attributes/indicator.ts +39 -0
- package/src/datastar/attributes/init.ts +35 -0
- package/src/datastar/attributes/jsonSignals.ts +38 -0
- package/src/datastar/attributes/on.ts +71 -0
- package/src/datastar/attributes/onIntersect.ts +65 -0
- package/src/datastar/attributes/onInterval.ts +39 -0
- package/src/datastar/attributes/onSignalPatch.ts +63 -0
- package/src/datastar/attributes/ref.ts +12 -0
- package/src/datastar/attributes/show.ts +33 -0
- package/src/datastar/attributes/signals.ts +22 -0
- package/src/datastar/attributes/style.ts +63 -0
- package/src/datastar/attributes/text.ts +30 -0
- package/src/datastar/engine.ts +1341 -0
- package/src/datastar/index.ts +25 -0
- package/src/datastar/utils.ts +286 -0
- package/src/datastar/watchers/patchElements.ts +554 -0
- package/src/datastar/watchers/patchSignals.ts +15 -0
- package/src/index.ts +1 -0
- package/src/node/{FileSystem.ts → NodeFileSystem.ts} +59 -97
- package/src/node/{Utils.ts → NodeUtils.ts} +2 -0
- package/src/testing/TestLogger.ts +1 -1
- package/src/x/tailwind/plugin.ts +1 -1
- package/dist/Random.d.ts +0 -5
- package/dist/Random.js +0 -49
- package/src/Commander.test.ts +0 -1639
- package/src/ContentNegotiation.test.ts +0 -603
- package/src/Development.test.ts +0 -119
- package/src/Entity.test.ts +0 -592
- package/src/FileRouterCodegen.todo.ts +0 -1133
- package/src/FileRouterPattern.test.ts +0 -147
- package/src/FileRouterPattern.ts +0 -59
- package/src/FileRouter_files.test.ts +0 -64
- package/src/FileRouter_path.test.ts +0 -145
- package/src/FileRouter_tree.test.ts +0 -132
- package/src/Http.test.ts +0 -319
- package/src/HttpAppExtra.test.ts +0 -103
- package/src/HttpUtils.test.ts +0 -85
- package/src/PathPattern.test.ts +0 -648
- package/src/Random.ts +0 -59
- package/src/RouteBody.test.ts +0 -232
- package/src/RouteHook.test.ts +0 -40
- package/src/RouteHttp.test.ts +0 -2909
- package/src/RouteMount.test.ts +0 -481
- package/src/RouteSchema.test.ts +0 -427
- package/src/RouteSse.test.ts +0 -249
- package/src/RouteTree.test.ts +0 -494
- package/src/RouteTrie.test.ts +0 -322
- package/src/RouterPattern.test.ts +0 -676
- package/src/RouterPattern.ts +0 -416
- package/src/StartApp.ts +0 -47
- package/src/Values.test.ts +0 -263
- package/src/bun/BunBundle.test.ts +0 -268
- package/src/bun/BunBundle_imports.test.ts +0 -48
- package/src/bun/BunHttpServer.test.ts +0 -251
- package/src/bun/BunHttpServer.ts +0 -306
- package/src/bun/BunImportTrackerPlugin.test.ts +0 -77
- package/src/bun/BunRoute.test.ts +0 -162
- package/src/bundler/BundleHttp.test.ts +0 -132
- package/src/effect/HttpRouter.test.ts +0 -548
- package/src/experimental/EncryptedCookies.test.ts +0 -488
- package/src/hyper/HyperHtml.test.ts +0 -209
- package/src/hyper/HyperRoute.test.tsx +0 -197
- package/src/middlewares/BasicAuthMiddleware.test.ts +0 -84
- package/src/testing/TestHttpClient.test.ts +0 -83
- package/src/testing/TestLogger.test.ts +0 -51
- package/src/x/datastar/Datastar.test.ts +0 -266
- package/src/x/tailwind/TailwindPlugin.test.ts +0 -333
- /package/src/bun/{BunHttpServer_web.ts → BunServerRequest.ts} +0 -0
package/src/RouteBody.test.ts
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import * as test from "bun:test"
|
|
2
|
-
import * as Context from "effect/Context"
|
|
3
|
-
import * as Effect from "effect/Effect"
|
|
4
|
-
import * as ParseResult from "effect/ParseResult"
|
|
5
|
-
import * as Stream from "effect/Stream"
|
|
6
|
-
import * as Entity from "./Entity.ts"
|
|
7
|
-
import * as Route from "./Route.ts"
|
|
8
|
-
import * as RouteBody from "./RouteBody.ts"
|
|
9
|
-
import * as RouteMount from "./RouteMount.ts"
|
|
10
|
-
|
|
11
|
-
test.it("infers parent descriptions", () => {
|
|
12
|
-
RouteMount.get(
|
|
13
|
-
Route.text((ctx) =>
|
|
14
|
-
Effect.gen(function*() {
|
|
15
|
-
test
|
|
16
|
-
.expectTypeOf(ctx)
|
|
17
|
-
.toExtend<{
|
|
18
|
-
method: "GET"
|
|
19
|
-
format: "text"
|
|
20
|
-
}>()
|
|
21
|
-
|
|
22
|
-
return "Hello, world!"
|
|
23
|
-
})
|
|
24
|
-
),
|
|
25
|
-
)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
test.it("next is function returning Entity", () => {
|
|
29
|
-
Route.text((ctx, next) =>
|
|
30
|
-
Effect.gen(function*() {
|
|
31
|
-
test
|
|
32
|
-
.expectTypeOf(next)
|
|
33
|
-
.toExtend<() => Entity.Entity<string>>()
|
|
34
|
-
|
|
35
|
-
return "Hello, world!"
|
|
36
|
-
})
|
|
37
|
-
)
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
test.it("enforces result value", () => {
|
|
41
|
-
// @ts-expect-error must return string
|
|
42
|
-
Route.text((ctx, next) =>
|
|
43
|
-
Effect.gen(function*() {
|
|
44
|
-
return 1337
|
|
45
|
-
})
|
|
46
|
-
)
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
test.it("accepts text stream", () => {
|
|
50
|
-
RouteMount.get(
|
|
51
|
-
Route.text((ctx) =>
|
|
52
|
-
Effect.gen(function*() {
|
|
53
|
-
test
|
|
54
|
-
.expectTypeOf(ctx)
|
|
55
|
-
.toExtend<{
|
|
56
|
-
method: "GET"
|
|
57
|
-
format: "text"
|
|
58
|
-
}>()
|
|
59
|
-
|
|
60
|
-
return Stream.make("Hello", " ", "world!")
|
|
61
|
-
})
|
|
62
|
-
),
|
|
63
|
-
)
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
test.it("accepts Effect<Stream<string>> for html format", () => {
|
|
67
|
-
RouteMount.get(
|
|
68
|
-
Route.html(function*() {
|
|
69
|
-
return Stream.make("<div>", "content", "</div>")
|
|
70
|
-
}),
|
|
71
|
-
)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
test.it("accepts Effect<Stream<Uint8Array>> for bytes format", () => {
|
|
75
|
-
const encoder = new TextEncoder()
|
|
76
|
-
|
|
77
|
-
RouteMount.get(
|
|
78
|
-
Route.bytes(function*() {
|
|
79
|
-
return Stream.make(encoder.encode("chunk"))
|
|
80
|
-
}),
|
|
81
|
-
)
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
test.it("rejects Stream for json format", () => {
|
|
85
|
-
// @ts-expect-error Stream not allowed for json format
|
|
86
|
-
Route.json(function*() {
|
|
87
|
-
return Stream.make({ msg: "hello" })
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
test.it("accepts value directly", () => {
|
|
92
|
-
const value = "Hello, world!"
|
|
93
|
-
|
|
94
|
-
test
|
|
95
|
-
.expectTypeOf(Route.text)
|
|
96
|
-
.toBeCallableWith(value)
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
test.describe(`${RouteBody.handle.name}()`, () => {
|
|
100
|
-
const ctx = {}
|
|
101
|
-
const next = () => Entity.effect(Effect.succeed(Entity.make("next")))
|
|
102
|
-
|
|
103
|
-
test.it("accepts all HandlerInput variants", () => {
|
|
104
|
-
test
|
|
105
|
-
.expectTypeOf<
|
|
106
|
-
RouteBody.HandlerInput<{ foo: string }, string, Error, never>
|
|
107
|
-
>()
|
|
108
|
-
.toExtend<Parameters<typeof RouteBody.handle>[0]>()
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
test.it("handles plain value", async () => {
|
|
112
|
-
const handler = RouteBody.handle<{}, string, never, never>("hello")
|
|
113
|
-
const result = await Effect.runPromise(handler(ctx, next))
|
|
114
|
-
test.expect(result.body).toBe("hello")
|
|
115
|
-
test.expect(result.status).toBe(200)
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
test.it("handles Effect directly", async () => {
|
|
119
|
-
const handler = RouteBody.handle<{}, string, never, never>(
|
|
120
|
-
Effect.succeed("from effect"),
|
|
121
|
-
)
|
|
122
|
-
const result = await Effect.runPromise(handler(ctx, next))
|
|
123
|
-
test.expect(result.body).toBe("from effect")
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
test.it("handles Effect with error", async () => {
|
|
127
|
-
const handler = RouteBody.handle<{}, never, Error, never>(
|
|
128
|
-
Effect.fail(new Error("oops")),
|
|
129
|
-
)
|
|
130
|
-
|
|
131
|
-
test
|
|
132
|
-
.expectTypeOf(handler)
|
|
133
|
-
.returns
|
|
134
|
-
.toExtend<
|
|
135
|
-
Effect.Effect<Entity.Entity<never>, Error, never>
|
|
136
|
-
>()
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
test.it("handles function", async () => {
|
|
140
|
-
const handler = RouteBody.handle<{ id: number }, number, never, never>(
|
|
141
|
-
(ctx) => Effect.succeed(ctx.id),
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
test
|
|
145
|
-
.expectTypeOf(handler)
|
|
146
|
-
.parameters
|
|
147
|
-
.toEqualTypeOf<
|
|
148
|
-
[
|
|
149
|
-
{ id: number },
|
|
150
|
-
(
|
|
151
|
-
context?: Partial<{ id: number }> & Record<string, unknown>,
|
|
152
|
-
) => Entity.Entity<number>,
|
|
153
|
-
]
|
|
154
|
-
>()
|
|
155
|
-
test
|
|
156
|
-
.expectTypeOf(handler)
|
|
157
|
-
.returns
|
|
158
|
-
.toEqualTypeOf<
|
|
159
|
-
Effect.Effect<Entity.Entity<number>, never, never>
|
|
160
|
-
>()
|
|
161
|
-
|
|
162
|
-
const numNext = () => Entity.effect(Effect.succeed(Entity.make(23)))
|
|
163
|
-
const result = await Effect.runPromise(handler({ id: 42 }, numNext))
|
|
164
|
-
|
|
165
|
-
test.expect(result.body).toBe(42)
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
test.it("handles generator", async () => {
|
|
169
|
-
const handler = RouteBody.handle<{ id: number }, number, never, never>(
|
|
170
|
-
function*(ctx) {
|
|
171
|
-
const n = yield* Effect.succeed(ctx.id)
|
|
172
|
-
return n * 2
|
|
173
|
-
},
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
test
|
|
177
|
-
.expectTypeOf(handler)
|
|
178
|
-
.parameters
|
|
179
|
-
.toEqualTypeOf<
|
|
180
|
-
[
|
|
181
|
-
{ id: number },
|
|
182
|
-
(
|
|
183
|
-
context?: Partial<{ id: number }> & Record<string, unknown>,
|
|
184
|
-
) => Entity.Entity<number>,
|
|
185
|
-
]
|
|
186
|
-
>()
|
|
187
|
-
|
|
188
|
-
test
|
|
189
|
-
.expectTypeOf(handler)
|
|
190
|
-
.returns
|
|
191
|
-
.toEqualTypeOf<
|
|
192
|
-
Effect.Effect<Entity.Entity<number>, never, never>
|
|
193
|
-
>()
|
|
194
|
-
|
|
195
|
-
const numNext = () => Entity.effect(Effect.succeed(Entity.make(23)))
|
|
196
|
-
const result = await Effect.runPromise(handler({ id: 21 }, numNext))
|
|
197
|
-
|
|
198
|
-
test.expect(result.body).toBe(42)
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
test.it("generator can call next", async () => {
|
|
202
|
-
const handler = RouteBody.handle<{}, string, ParseResult.ParseError, never>(
|
|
203
|
-
function*(_ctx, next) {
|
|
204
|
-
const fromNext = yield* next().text
|
|
205
|
-
return `got: ${fromNext}`
|
|
206
|
-
},
|
|
207
|
-
)
|
|
208
|
-
|
|
209
|
-
const result = await Effect.runPromise(Effect.orDie(handler(ctx, next)))
|
|
210
|
-
|
|
211
|
-
test
|
|
212
|
-
.expect(result.body)
|
|
213
|
-
.toBe("got: next")
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
test.it("generator type checks missing services", async () => {
|
|
217
|
-
interface ServiceA {
|
|
218
|
-
readonly _: unique symbol
|
|
219
|
-
}
|
|
220
|
-
const ServiceA = Context.GenericTag<ServiceA>("ServiceA")
|
|
221
|
-
|
|
222
|
-
const handler = RouteBody.handle(function*() {
|
|
223
|
-
yield* ServiceA
|
|
224
|
-
return "ok"
|
|
225
|
-
})
|
|
226
|
-
|
|
227
|
-
// This should fail type checking because ServiceA is not provided
|
|
228
|
-
// @ts-expect-error ServiceA is missing
|
|
229
|
-
const promise = Effect.runPromise(handler(ctx, next))
|
|
230
|
-
test.expect(promise).rejects.toThrow(/Service not found: ServiceA/)
|
|
231
|
-
})
|
|
232
|
-
})
|
package/src/RouteHook.test.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as test from "bun:test"
|
|
2
|
-
import { Effect } from "effect"
|
|
3
|
-
import * as Route from "./Route.ts"
|
|
4
|
-
|
|
5
|
-
test.it("passes bindings", () => {
|
|
6
|
-
const headers = {
|
|
7
|
-
"origin": "nounder.org",
|
|
8
|
-
}
|
|
9
|
-
const filterResult = {
|
|
10
|
-
context: {
|
|
11
|
-
headers,
|
|
12
|
-
},
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const routes = Route.empty.pipe(
|
|
16
|
-
Route.filter(() => Effect.succeed(filterResult)),
|
|
17
|
-
Route.text(context => {
|
|
18
|
-
test
|
|
19
|
-
.expectTypeOf(context)
|
|
20
|
-
.toExtend<typeof filterResult.context>()
|
|
21
|
-
|
|
22
|
-
return Effect.succeed(
|
|
23
|
-
`Origin: ${context.headers.origin}`,
|
|
24
|
-
)
|
|
25
|
-
}),
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
test
|
|
29
|
-
.expectTypeOf(routes)
|
|
30
|
-
.toExtend<
|
|
31
|
-
Route.RouteSet.RouteSet<{}, {}, [
|
|
32
|
-
Route.Route.Route<{}, typeof filterResult.context, any>,
|
|
33
|
-
Route.Route.Route<{ format: "text" }, {}, string>,
|
|
34
|
-
]>
|
|
35
|
-
>()
|
|
36
|
-
|
|
37
|
-
test
|
|
38
|
-
.expect(Route.items(routes))
|
|
39
|
-
.toHaveLength(2)
|
|
40
|
-
})
|