@effect/platform 0.63.3 → 0.64.1

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.
Files changed (62) hide show
  1. package/README.md +2 -416
  2. package/dist/cjs/Command.js +3 -3
  3. package/dist/cjs/Command.js.map +1 -1
  4. package/dist/cjs/Etag.js +11 -1
  5. package/dist/cjs/Etag.js.map +1 -1
  6. package/dist/cjs/HttpApiBuilder.js +35 -1
  7. package/dist/cjs/HttpApiBuilder.js.map +1 -1
  8. package/dist/cjs/HttpPlatform.js +6 -1
  9. package/dist/cjs/HttpPlatform.js.map +1 -1
  10. package/dist/cjs/Socket.js +56 -16
  11. package/dist/cjs/Socket.js.map +1 -1
  12. package/dist/cjs/internal/command.js +2 -2
  13. package/dist/cjs/internal/command.js.map +1 -1
  14. package/dist/cjs/internal/etag.js +42 -1
  15. package/dist/cjs/internal/etag.js.map +1 -1
  16. package/dist/cjs/internal/httpPlatform.js +28 -4
  17. package/dist/cjs/internal/httpPlatform.js.map +1 -1
  18. package/dist/cjs/internal/httpServerResponse.js +5 -4
  19. package/dist/cjs/internal/httpServerResponse.js.map +1 -1
  20. package/dist/cjs/internal/multipart.js +1 -3
  21. package/dist/cjs/internal/multipart.js.map +1 -1
  22. package/dist/dts/Command.d.ts +4 -4
  23. package/dist/dts/Command.d.ts.map +1 -1
  24. package/dist/dts/Etag.d.ts +11 -0
  25. package/dist/dts/Etag.d.ts.map +1 -1
  26. package/dist/dts/HttpApiBuilder.d.ts +29 -1
  27. package/dist/dts/HttpApiBuilder.d.ts.map +1 -1
  28. package/dist/dts/HttpPlatform.d.ts +6 -0
  29. package/dist/dts/HttpPlatform.d.ts.map +1 -1
  30. package/dist/dts/Socket.d.ts +20 -3
  31. package/dist/dts/Socket.d.ts.map +1 -1
  32. package/dist/esm/Command.js +3 -3
  33. package/dist/esm/Command.js.map +1 -1
  34. package/dist/esm/Etag.js +10 -0
  35. package/dist/esm/Etag.js.map +1 -1
  36. package/dist/esm/HttpApiBuilder.js +33 -0
  37. package/dist/esm/HttpApiBuilder.js.map +1 -1
  38. package/dist/esm/HttpPlatform.js +5 -0
  39. package/dist/esm/HttpPlatform.js.map +1 -1
  40. package/dist/esm/Socket.js +53 -15
  41. package/dist/esm/Socket.js.map +1 -1
  42. package/dist/esm/internal/command.js +2 -2
  43. package/dist/esm/internal/command.js.map +1 -1
  44. package/dist/esm/internal/etag.js +41 -0
  45. package/dist/esm/internal/etag.js.map +1 -1
  46. package/dist/esm/internal/httpPlatform.js +28 -4
  47. package/dist/esm/internal/httpPlatform.js.map +1 -1
  48. package/dist/esm/internal/httpServerResponse.js +4 -3
  49. package/dist/esm/internal/httpServerResponse.js.map +1 -1
  50. package/dist/esm/internal/multipart.js +1 -3
  51. package/dist/esm/internal/multipart.js.map +1 -1
  52. package/package.json +3 -3
  53. package/src/Command.ts +7 -8
  54. package/src/Etag.ts +13 -0
  55. package/src/HttpApiBuilder.ts +46 -2
  56. package/src/HttpPlatform.ts +7 -0
  57. package/src/Socket.ts +97 -23
  58. package/src/internal/command.ts +4 -3
  59. package/src/internal/etag.ts +43 -0
  60. package/src/internal/httpPlatform.ts +32 -4
  61. package/src/internal/httpServerResponse.ts +6 -3
  62. package/src/internal/multipart.ts +1 -3
package/README.md CHANGED
@@ -2,23 +2,8 @@
2
2
 
3
3
  Welcome to the documentation for `@effect/platform`, a library designed for creating platform-independent abstractions (Node.js, Bun, browsers).
4
4
 
5
- With `@effect/platform`, you can incorporate abstract services like `Terminal` or `FileSystem` into your program. Later, during the assembly of the final application, you can provide specific layers for the target platform using the corresponding packages: `platform-node`, `platform-bun`, and `platform-browser`.
6
-
7
- This package empowers you to perform various operations, such as:
8
-
9
- | **Operation** | **Description** |
10
- | -------------- | ------------------------------------------------------------------------------------------------ |
11
- | HTTP API | Declarative HTTP API servers & clients |
12
- | HTTP Client | Sending HTTP requests and receiving responses |
13
- | HTTP Server | Creating HTTP servers to handle incoming requests |
14
- | HTTP Router | Routing HTTP requests to specific handlers |
15
- | Terminal | Reading and writing from/to standard input/output |
16
- | Command | Creating and running a command with the specified process name and an optional list of arguments |
17
- | FileSystem | Reading and writing from/to the file system |
18
- | KeyValueStore | Storing and retrieving key-value pairs |
19
- | PlatformLogger | Creating a logger that writes to a specified file from another string logger |
20
-
21
- By utilizing `@effect/platform`, you can write code that remains platform-agnostic, ensuring compatibility across different environments.
5
+ > [!WARNING]
6
+ > This documentation focuses on **unstable modules**. For stable modules, refer to the [official website documentation](https://effect.website/docs/guides/platform/introduction).
22
7
 
23
8
  # HTTP API
24
9
 
@@ -2345,402 +2330,3 @@ const handler = HttpApp.toWebHandler(router)
2345
2330
  const response = await handler(new Request("http://localhost:3000/foo"))
2346
2331
  console.log(await response.text()) // Output: content 2
2347
2332
  ```
2348
-
2349
- # Terminal
2350
-
2351
- The `@effect/platform/Terminal` module exports a single `Terminal` tag, which serves as the entry point to reading from and writing to standard input and standard output.
2352
-
2353
- ## Writing to standard output
2354
-
2355
- ```ts
2356
- import { Terminal } from "@effect/platform"
2357
- import { NodeRuntime, NodeTerminal } from "@effect/platform-node"
2358
- import { Effect } from "effect"
2359
-
2360
- // const displayMessage: Effect.Effect<void, PlatformError, Terminal.Terminal>
2361
- const displayMessage = Effect.gen(function* (_) {
2362
- const terminal = yield* _(Terminal.Terminal)
2363
- yield* _(terminal.display("a message\n"))
2364
- })
2365
-
2366
- NodeRuntime.runMain(displayMessage.pipe(Effect.provide(NodeTerminal.layer)))
2367
- // Output: "a message"
2368
- ```
2369
-
2370
- ## Reading from standard input
2371
-
2372
- ```ts
2373
- import { Terminal } from "@effect/platform"
2374
- import { NodeRuntime, NodeTerminal } from "@effect/platform-node"
2375
- import { Console, Effect } from "effect"
2376
-
2377
- // const readLine: Effect.Effect<void, Terminal.QuitException, Terminal.Terminal>
2378
- const readLine = Effect.gen(function* (_) {
2379
- const terminal = yield* _(Terminal.Terminal)
2380
- const input = yield* _(terminal.readLine)
2381
- yield* _(Console.log(`input: ${input}`))
2382
- })
2383
-
2384
- NodeRuntime.runMain(readLine.pipe(Effect.provide(NodeTerminal.layer)))
2385
- // Input: "hello"
2386
- // Output: "input: hello"
2387
- ```
2388
-
2389
- These simple examples illustrate how to utilize the `Terminal` module for handling standard input and output in your programs. Let's use this knowledge to build a number guessing game:
2390
-
2391
- ```ts
2392
- import { Terminal } from "@effect/platform"
2393
- import type { PlatformError } from "@effect/platform/Error"
2394
- import { Effect, Option, Random } from "effect"
2395
-
2396
- export const secret = Random.nextIntBetween(1, 100)
2397
-
2398
- const parseGuess = (input: string) => {
2399
- const n = parseInt(input, 10)
2400
- return isNaN(n) || n < 1 || n > 100 ? Option.none() : Option.some(n)
2401
- }
2402
-
2403
- const display = (message: string) =>
2404
- Effect.gen(function* (_) {
2405
- const terminal = yield* _(Terminal.Terminal)
2406
- yield* _(terminal.display(`${message}\n`))
2407
- })
2408
-
2409
- const prompt = Effect.gen(function* (_) {
2410
- const terminal = yield* _(Terminal.Terminal)
2411
- yield* _(terminal.display("Enter a guess: "))
2412
- return yield* _(terminal.readLine)
2413
- })
2414
-
2415
- const answer: Effect.Effect<
2416
- number,
2417
- Terminal.QuitException | PlatformError,
2418
- Terminal.Terminal
2419
- > = Effect.gen(function* (_) {
2420
- const input = yield* _(prompt)
2421
- const guess = parseGuess(input)
2422
- if (Option.isNone(guess)) {
2423
- yield* _(display("You must enter an integer from 1 to 100"))
2424
- return yield* _(answer)
2425
- }
2426
- return guess.value
2427
- })
2428
-
2429
- const check = <A, E, R>(
2430
- secret: number,
2431
- guess: number,
2432
- ok: Effect.Effect<A, E, R>,
2433
- ko: Effect.Effect<A, E, R>
2434
- ): Effect.Effect<A, E | PlatformError, R | Terminal.Terminal> =>
2435
- Effect.gen(function* (_) {
2436
- if (guess > secret) {
2437
- yield* _(display("Too high"))
2438
- return yield* _(ko)
2439
- } else if (guess < secret) {
2440
- yield* _(display("Too low"))
2441
- return yield* _(ko)
2442
- } else {
2443
- return yield* _(ok)
2444
- }
2445
- })
2446
-
2447
- const end = display("You guessed it!")
2448
-
2449
- const loop = (
2450
- secret: number
2451
- ): Effect.Effect<
2452
- void,
2453
- Terminal.QuitException | PlatformError,
2454
- Terminal.Terminal
2455
- > =>
2456
- Effect.gen(function* (_) {
2457
- const guess = yield* _(answer)
2458
- return yield* _(
2459
- check(
2460
- secret,
2461
- guess,
2462
- end,
2463
- Effect.suspend(() => loop(secret))
2464
- )
2465
- )
2466
- })
2467
-
2468
- export const game = Effect.gen(function* (_) {
2469
- yield* _(
2470
- display(
2471
- "We have selected a random number between 1 and 100. See if you can guess it in 10 turns or fewer. We'll tell you if your guess was too high or too low."
2472
- )
2473
- )
2474
- yield* _(loop(yield* _(secret)))
2475
- })
2476
- ```
2477
-
2478
- Let's run the game in Node.js:
2479
-
2480
- ```ts
2481
- import { NodeRuntime, NodeTerminal } from "@effect/platform-node"
2482
- import * as Effect from "effect/Effect"
2483
- import { game } from "./game.js"
2484
-
2485
- NodeRuntime.runMain(game.pipe(Effect.provide(NodeTerminal.layer)))
2486
- ```
2487
-
2488
- Let's run the game in Bun:
2489
-
2490
- ```ts
2491
- import { BunRuntime, BunTerminal } from "@effect/platform-bun"
2492
- import * as Effect from "effect/Effect"
2493
- import { game } from "./game.js"
2494
-
2495
- BunRuntime.runMain(game.pipe(Effect.provide(BunTerminal.layer)))
2496
- ```
2497
-
2498
- # Command
2499
-
2500
- As an example of using the `@effect/platform/Command` module, let's see how to run the TypeScript compiler `tsc`:
2501
-
2502
- ```ts
2503
- import { Command, CommandExecutor } from "@effect/platform"
2504
- import {
2505
- NodeCommandExecutor,
2506
- NodeFileSystem,
2507
- NodeRuntime
2508
- } from "@effect/platform-node"
2509
- import { Effect } from "effect"
2510
-
2511
- // const program: Effect.Effect<string, PlatformError, CommandExecutor.CommandExecutor>
2512
- const program = Effect.gen(function* (_) {
2513
- const executor = yield* _(CommandExecutor.CommandExecutor)
2514
-
2515
- // Creating a command to run the TypeScript compiler
2516
- const command = Command.make("tsc", "--noEmit")
2517
- console.log("Running tsc...")
2518
-
2519
- // Executing the command and capturing the output
2520
- const output = yield* _(executor.string(command))
2521
- console.log(output)
2522
- return output
2523
- })
2524
-
2525
- // Running the program with the necessary runtime and executor layers
2526
- NodeRuntime.runMain(
2527
- program.pipe(
2528
- Effect.provide(NodeCommandExecutor.layer),
2529
- Effect.provide(NodeFileSystem.layer)
2530
- )
2531
- )
2532
- ```
2533
-
2534
- ## Obtaining Information About the Running Process
2535
-
2536
- Here, we'll explore how to retrieve information about a running process.
2537
-
2538
- ```ts
2539
- import { Command, CommandExecutor } from "@effect/platform"
2540
- import {
2541
- NodeCommandExecutor,
2542
- NodeFileSystem,
2543
- NodeRuntime
2544
- } from "@effect/platform-node"
2545
- import { Effect, Stream, String } from "effect"
2546
-
2547
- const runString = <E, R>(
2548
- stream: Stream.Stream<Uint8Array, E, R>
2549
- ): Effect.Effect<string, E, R> =>
2550
- stream.pipe(Stream.decodeText(), Stream.runFold(String.empty, String.concat))
2551
-
2552
- const program = Effect.gen(function* (_) {
2553
- const executor = yield* _(CommandExecutor.CommandExecutor)
2554
-
2555
- const command = Command.make("ls")
2556
-
2557
- const [exitCode, stdout, stderr] = yield* _(
2558
- // Start running the command and return a handle to the running process.
2559
- executor.start(command),
2560
- Effect.flatMap((process) =>
2561
- Effect.all(
2562
- [
2563
- // Waits for the process to exit and returns the ExitCode of the command that was run.
2564
- process.exitCode,
2565
- // The standard output stream of the process.
2566
- runString(process.stdout),
2567
- // The standard error stream of the process.
2568
- runString(process.stderr)
2569
- ],
2570
- { concurrency: 3 }
2571
- )
2572
- )
2573
- )
2574
- console.log({ exitCode, stdout, stderr })
2575
- })
2576
-
2577
- NodeRuntime.runMain(
2578
- Effect.scoped(program).pipe(
2579
- Effect.provide(NodeCommandExecutor.layer),
2580
- Effect.provide(NodeFileSystem.layer)
2581
- )
2582
- )
2583
- ```
2584
-
2585
- ## Running a Platform Command with stdout Streamed to process.stdout
2586
-
2587
- To run a command (for example `cat`) and stream its `stdout` to `process.stdout` follow these steps:
2588
-
2589
- ```ts
2590
- import { Command } from "@effect/platform"
2591
- import { NodeContext, NodeRuntime } from "@effect/platform-node"
2592
- import { Effect } from "effect"
2593
-
2594
- // Create a command to run `cat` on a file and inherit stdout
2595
- const program = Command.make("cat", "./some-file.txt").pipe(
2596
- Command.stdout("inherit"),
2597
- Command.exitCode
2598
- )
2599
-
2600
- // Run the command using NodeRuntime with the NodeContext layer
2601
- NodeRuntime.runMain(program.pipe(Effect.provide(NodeContext.layer)))
2602
- ```
2603
-
2604
- # FileSystem
2605
-
2606
- The `@effect/platform/FileSystem` module provides a single `FileSystem` tag, which acts as the gateway for interacting with the filesystem.
2607
-
2608
- Here's a list of operations that can be performed using the `FileSystem` tag:
2609
-
2610
- | **Name** | **Arguments** | **Return** | **Description** |
2611
- | --------------------------- | ---------------------------------------------------------------- | ---------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2612
- | **access** | `path: string`, `options?: AccessFileOptions` | `Effect<void, PlatformError>` | Check if a file can be accessed. You can optionally specify the level of access to check for. |
2613
- | **copy** | `fromPath: string`, `toPath: string`, `options?: CopyOptions` | `Effect<void, PlatformError>` | Copy a file or directory from `fromPath` to `toPath`. Equivalent to `cp -r`. |
2614
- | **copyFile** | `fromPath: string`, `toPath: string` | `Effect<void, PlatformError>` | Copy a file from `fromPath` to `toPath`. |
2615
- | **chmod** | `path: string`, `mode: number` | `Effect<void, PlatformError>` | Change the permissions of a file. |
2616
- | **chown** | `path: string`, `uid: number`, `gid: number` | `Effect<void, PlatformError>` | Change the owner and group of a file. |
2617
- | **exists** | `path: string` | `Effect<boolean, PlatformError>` | Check if a path exists. |
2618
- | **link** | `fromPath: string`, `toPath: string` | `Effect<void, PlatformError>` | Create a hard link from `fromPath` to `toPath`. |
2619
- | **makeDirectory** | `path: string`, `options?: MakeDirectoryOptions` | `Effect<void, PlatformError>` | Create a directory at `path`. You can optionally specify the mode and whether to recursively create nested directories. |
2620
- | **makeTempDirectory** | `options?: MakeTempDirectoryOptions` | `Effect<string, PlatformError>` | Create a temporary directory. By default, the directory will be created inside the system's default temporary directory. |
2621
- | **makeTempDirectoryScoped** | `options?: MakeTempDirectoryOptions` | `Effect<string, PlatformError, Scope>` | Create a temporary directory inside a scope. Functionally equivalent to `makeTempDirectory`, but the directory will be automatically deleted when the scope is closed. |
2622
- | **makeTempFile** | `options?: MakeTempFileOptions` | `Effect<string, PlatformError>` | Create a temporary file. The directory creation is functionally equivalent to `makeTempDirectory`. The file name will be a randomly generated string. |
2623
- | **makeTempFileScoped** | `options?: MakeTempFileOptions` | `Effect<string, PlatformError, Scope>` | Create a temporary file inside a scope. Functionally equivalent to `makeTempFile`, but the file will be automatically deleted when the scope is closed. |
2624
- | **open** | `path: string`, `options?: OpenFileOptions` | `Effect<File, PlatformError, Scope>` | Open a file at `path` with the specified `options`. The file handle will be automatically closed when the scope is closed. |
2625
- | **readDirectory** | `path: string`, `options?: ReadDirectoryOptions` | `Effect<Array<string>, PlatformError>` | List the contents of a directory. You can recursively list the contents of nested directories by setting the `recursive` option. |
2626
- | **readFile** | `path: string` | `Effect<Uint8Array, PlatformError>` | Read the contents of a file. |
2627
- | **readFileString** | `path: string`, `encoding?: string` | `Effect<string, PlatformError>` | Read the contents of a file as a string. |
2628
- | **readLink** | `path: string` | `Effect<string, PlatformError>` | Read the destination of a symbolic link. |
2629
- | **realPath** | `path: string` | `Effect<string, PlatformError>` | Resolve a path to its canonicalized absolute pathname. |
2630
- | **remove** | `path: string`, `options?: RemoveOptions` | `Effect<void, PlatformError>` | Remove a file or directory. By setting the `recursive` option to `true`, you can recursively remove nested directories. |
2631
- | **rename** | `oldPath: string`, `newPath: string` | `Effect<void, PlatformError>` | Rename a file or directory. |
2632
- | **sink** | `path: string`, `options?: SinkOptions` | `Sink<void, Uint8Array, never, PlatformError>` | Create a writable `Sink` for the specified `path`. |
2633
- | **stat** | `path: string` | `Effect<File.Info, PlatformError>` | Get information about a file at `path`. |
2634
- | **stream** | `path: string`, `options?: StreamOptions` | `Stream<Uint8Array, PlatformError>` | Create a readable `Stream` for the specified `path`. |
2635
- | **symlink** | `fromPath: string`, `toPath: string` | `Effect<void, PlatformError>` | Create a symbolic link from `fromPath` to `toPath`. |
2636
- | **truncate** | `path: string`, `length?: SizeInput` | `Effect<void, PlatformError>` | Truncate a file to a specified length. If the `length` is not specified, the file will be truncated to length `0`. |
2637
- | **utimes** | `path: string`, `atime: Date \| number`, `mtime: Date \| number` | `Effect<void, PlatformError>` | Change the file system timestamps of the file at `path`. |
2638
- | **watch** | `path: string` | `Stream<WatchEvent, PlatformError>` | Watch a directory or file for changes. |
2639
-
2640
- Let's explore a simple example using `readFileString`:
2641
-
2642
- ```ts
2643
- import { FileSystem } from "@effect/platform"
2644
- import { NodeFileSystem, NodeRuntime } from "@effect/platform-node"
2645
- import { Effect } from "effect"
2646
-
2647
- // const readFileString: Effect.Effect<void, PlatformError, FileSystem.FileSystem>
2648
- const readFileString = Effect.gen(function* (_) {
2649
- const fs = yield* _(FileSystem.FileSystem)
2650
-
2651
- // Reading the content of the same file where this code is written
2652
- const content = yield* _(fs.readFileString("./index.ts", "utf8"))
2653
- console.log(content)
2654
- })
2655
-
2656
- NodeRuntime.runMain(readFileString.pipe(Effect.provide(NodeFileSystem.layer)))
2657
- ```
2658
-
2659
- # KeyValueStore
2660
-
2661
- ## Overview
2662
-
2663
- The `KeyValueStore` module provides a robust and effectful interface for managing key-value pairs. It supports asynchronous operations, ensuring data integrity and consistency, and includes built-in implementations for in-memory, file system-based, and schema-validated stores.
2664
-
2665
- ## Basic Usage
2666
-
2667
- The `KeyValueStore` interface includes the following operations:
2668
-
2669
- - **get**: Retrieve a value by key.
2670
- - **set**: Store a key-value pair.
2671
- - **remove**: Delete a key-value pair.
2672
- - **clear**: Remove all key-value pairs.
2673
- - **size**: Get the number of stored pairs.
2674
- - **modify**: Atomically modify a value.
2675
- - **has**: Check if a key exists.
2676
- - **isEmpty**: Check if the store is empty.
2677
-
2678
- **Example**
2679
-
2680
- ```ts
2681
- import { KeyValueStore, layerMemory } from "@effect/platform/KeyValueStore"
2682
- import { Effect } from "effect"
2683
-
2684
- const program = Effect.gen(function* () {
2685
- const store = yield* KeyValueStore
2686
- console.log(yield* store.size) // Outputs: 0
2687
-
2688
- yield* store.set("key", "value")
2689
- console.log(yield* store.size) // Outputs: 1
2690
-
2691
- const value = yield* store.get("key")
2692
- console.log(value) // Outputs: { _id: 'Option', _tag: 'Some', value: 'value' }
2693
-
2694
- yield* store.remove("key")
2695
- console.log(yield* store.size) // Outputs: 0
2696
- })
2697
-
2698
- Effect.runPromise(program.pipe(Effect.provide(layerMemory)))
2699
- ```
2700
-
2701
- ## Built-in Implementations
2702
-
2703
- The module provides several built-in implementations to suit different needs:
2704
-
2705
- - **In-Memory Store**: `layerMemory` provides a simple, in-memory key-value store, ideal for lightweight or testing scenarios.
2706
- - **File System Store**: `layerFileSystem` offers a file-based store for persistent storage needs.
2707
- - **Schema Store**: `layerSchema` enables schema-based validation for stored values, ensuring data integrity and type safety.
2708
-
2709
- ## Schema Store
2710
-
2711
- The `SchemaStore` implementation allows you to validate and parse values according to a defined schema. This ensures that all data stored in the key-value store adheres to the specified structure, enhancing data integrity and type safety.
2712
-
2713
- **Example**
2714
-
2715
- ```ts
2716
- import { KeyValueStore, layerMemory } from "@effect/platform/KeyValueStore"
2717
- import { Schema } from "@effect/schema"
2718
- import { Effect } from "effect"
2719
-
2720
- // Define a schema for the values
2721
- const Person = Schema.Struct({
2722
- name: Schema.String,
2723
- age: Schema.Number
2724
- })
2725
-
2726
- const program = Effect.gen(function* () {
2727
- const store = (yield* KeyValueStore).forSchema(Person)
2728
-
2729
- // Create a value that adheres to the schema
2730
- const value = { name: "Alice", age: 30 }
2731
- yield* store.set("user1", value)
2732
- console.log(yield* store.size) // Outputs: 1
2733
-
2734
- // Retrieve and validate the value
2735
- const retrievedValue = yield* store.get("user1")
2736
- console.log(retrievedValue) // Outputs: { _id: 'Option', _tag: 'Some', value: { name: 'Alice', age: 30 } }
2737
- })
2738
-
2739
- Effect.runPromise(program.pipe(Effect.provide(layerMemory)))
2740
- ```
2741
-
2742
- In this example:
2743
-
2744
- - **Person**: Defines the structure for the values stored in the key-value store.
2745
- - **store.set**: Stores a value adhering to `Person`.
2746
- - **store.get**: Retrieves and validates the stored value against `Person`.
@@ -44,9 +44,9 @@ const feed = exports.feed = internal.feed;
44
44
  /**
45
45
  * Flatten this command to a non-empty array of standard commands.
46
46
  *
47
- * * For a `StandardCommand`, this simply returns a `1` element array
48
- * * For a `PipedCommand`, all commands in the pipe will be extracted out into
49
- * a array from left to right
47
+ * For a `StandardCommand`, this simply returns a `1` element array
48
+ * For a `PipedCommand`, all commands in the pipe will be extracted out into
49
+ * a array from left to right
50
50
  *
51
51
  * @since 1.0.0
52
52
  * @category combinators
@@ -1 +1 @@
1
- {"version":3,"file":"Command.js","names":["internal","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","CommandTypeId","exports","isCommand","env","exitCode","feed","flatten","lines","make","pipeTo","runInShell","start","stream","streamLines","string","stderr","stdin","stdout","workingDirectory"],"sources":["../../src/Command.ts"],"sourcesContent":[null],"mappings":";;;;;;AAcA,IAAAA,QAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAiD,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAA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B,OAAO;AAElG;;;;;;;AAOO,MAAMC,KAAK,GAAAN,OAAA,CAAAM,KAAA,GAG2C9B,QAAQ,CAAC8B,KAAK;AAE3E;;;;;;;AAOO,MAAMC,IAAI,GAAAP,OAAA,CAAAO,IAAA,GAAyD/B,QAAQ,CAAC+B,IAAI;AAEvF;;;;;;;;;;;;AAYO,MAAMC,MAAM,GAAAR,OAAA,CAAAQ,MAAA,GAGfhC,QAAQ,CAACgC,MAAM;AAEnB;;;;;;;AAOO,MAAMC,UAAU,GAAAT,OAAA,CAAAS,UAAA,GAGnBjC,QAAQ,CAACiC,UAAU;AAEvB;;;;;;AAMO,MAAMC,KAAK,GAAAV,OAAA,CAAAU,KAAA,GAAkFlC,QAAQ,CAACkC,KAAK;AAElH;;;;;;AAMO,MAAMC,MAAM,GAAAX,OAAA,CAAAW,MAAA,GAA6EnC,QAAQ,CAACmC,MAAM;AAE/G;;;;;;;AAOO,MAAMC,WAAW,GAAAZ,OAAA,CAAAY,WAAA,GAAyEpC,QAAQ,CAACoC,WAAW;AAErH;;;;;;;;;AASO,MAAMC,MAAM,GAAAb,OAAA,CAAAa,MAAA,GAGfrC,QAAQ,CAACqC,MAAM;AAEnB;;;;;;AAMO,MAAMC,MAAM,GAAAd,OAAA,CAAAc,MAAA,GAGftC,QAAQ,CAACsC,MAAM;AAEnB;;;;;;AAMO,MAAMC,KAAK,GAAAf,OAAA,CAAAe,KAAA,GAGdvC,QAAQ,CAACuC,KAAK;AAElB;;;;;;AAMO,MAAMC,MAAM,GAAAhB,OAAA,CAAAgB,MAAA,GAGfxC,QAAQ,CAACwC,MAAM;AAEnB;;;;;;;;;AASO,MAAMC,gBAAgB,GAAAjB,OAAA,CAAAiB,gBAAA,GAGzBzC,QAAQ,CAACyC,gBAAgB","ignoreList":[]}
1
+ {"version":3,"file":"Command.js","names":["internal","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","CommandTypeId","exports","isCommand","env","exitCode","feed","flatten","lines","make","pipeTo","runInShell","start","stream","streamLines","string","stderr","stdin","stdout","workingDirectory"],"sources":["../../src/Command.ts"],"sourcesContent":[null],"mappings":";;;;;;AAcA,IAAAA,QAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAiD,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,C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;AAEtB;;;;;;;;;AASO,MAAMC,MAAM,GAAAb,OAAA,CAAAa,MAAA,GAGfrC,QAAQ,CAACqC,MAAM;AAEnB;;;;;;AAMO,MAAMC,MAAM,GAAAd,OAAA,CAAAc,MAAA,GAGftC,QAAQ,CAACsC,MAAM;AAEnB;;;;;;AAMO,MAAMC,KAAK,GAAAf,OAAA,CAAAe,KAAA,GAGdvC,QAAQ,CAACuC,KAAK;AAElB;;;;;;AAMO,MAAMC,MAAM,GAAAhB,OAAA,CAAAgB,MAAA,GAGfxC,QAAQ,CAACwC,MAAM;AAEnB;;;;;;;;;AASO,MAAMC,gBAAgB,GAAAjB,OAAA,CAAAiB,gBAAA,GAGzBzC,QAAQ,CAACyC,gBAAgB","ignoreList":[]}
package/dist/cjs/Etag.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.toString = exports.GeneratorTypeId = exports.Generator = void 0;
6
+ exports.toString = exports.layerWeak = exports.layer = exports.GeneratorTypeId = exports.Generator = void 0;
7
7
  var internal = _interopRequireWildcard(require("./internal/etag.js"));
8
8
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
9
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -22,4 +22,14 @@ const GeneratorTypeId = exports.GeneratorTypeId = internal.GeneratorTypeId;
22
22
  * @category tags
23
23
  */
24
24
  const Generator = exports.Generator = internal.tag;
25
+ /**
26
+ * @since 1.0.0
27
+ * @category layers
28
+ */
29
+ const layer = exports.layer = internal.layer;
30
+ /**
31
+ * @since 1.0.0
32
+ * @category layers
33
+ */
34
+ const layerWeak = exports.layerWeak = internal.layerWeak;
25
35
  //# sourceMappingURL=Etag.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Etag.js","names":["internal","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","toString","exports","GeneratorTypeId","Generator","tag"],"sources":["../../src/Etag.ts"],"sourcesContent":[null],"mappings":";;;;;;AAOA,IAAAA,QAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA8C,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AA0B9C;;;;AAIO,MAAMW,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAA2BvB,QAAQ,CAACuB,QAAQ;AAEjE;;;;AAIO,MAAME,eAAe,GAAAD,OAAA,CAAAC,eAAA,GAAkBzB,QAAQ,CAACyB,eAAe;AAkBtE;;;;AAIO,MAAMC,SAAS,GAAAF,OAAA,CAAAE,SAAA,GAAsC1B,QAAQ,CAAC2B,GAAG","ignoreList":[]}
1
+ {"version":3,"file":"Etag.js","names":["internal","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","toString","exports","GeneratorTypeId","Generator","tag","layer","layerWeak"],"sources":["../../src/Etag.ts"],"sourcesContent":[null],"mappings":";;;;;;AAQA,IAAAA,QAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA8C,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,O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4
4
  value: true
5
5
  });
6
- exports.serve = exports.securitySetCookie = exports.securityDecode = exports.middlewareSecurityVoid = exports.middlewareSecurity = exports.middlewareOpenApi = exports.middlewareLayerScoped = exports.middlewareLayer = exports.middlewareCors = exports.middleware = exports.httpApp = exports.handle = exports.group = exports.api = exports.Router = exports.Middleware = exports.HandlersTypeId = void 0;
6
+ exports.toWebHandler = exports.serve = exports.securitySetCookie = exports.securityDecode = exports.middlewareSecurityVoid = exports.middlewareSecurity = exports.middlewareOpenApi = exports.middlewareLayerScoped = exports.middlewareLayer = exports.middlewareCors = exports.middleware = exports.httpApp = exports.handle = exports.group = exports.api = exports.Router = exports.Middleware = exports.HandlersTypeId = void 0;
7
7
  var AST = _interopRequireWildcard(require("@effect/schema/AST"));
8
8
  var ParseResult = _interopRequireWildcard(require("@effect/schema/ParseResult"));
9
9
  var Schema = _interopRequireWildcard(require("@effect/schema/Schema"));
@@ -74,6 +74,39 @@ const httpApp = exports.httpApp = /*#__PURE__*/Effect.gen(function* () {
74
74
  onSuccess: Effect.succeed
75
75
  })));
76
76
  });
77
+ /**
78
+ * Construct an http web handler from an `HttpApi` instance.
79
+ *
80
+ * @since 1.0.0
81
+ * @category constructors
82
+ * @example
83
+ * import { HttpApi } from "@effect/platform"
84
+ * import { Etag, HttpApiBuilder, HttpMiddleware, HttpPlatform } from "@effect/platform"
85
+ * import { NodeContext } from "@effect/platform-node"
86
+ * import { Layer, ManagedRuntime } from "effect"
87
+ *
88
+ * const ApiLive = HttpApiBuilder.api(HttpApi.empty)
89
+ *
90
+ * const runtime = ManagedRuntime.make(
91
+ * Layer.mergeAll(
92
+ * ApiLive,
93
+ * HttpApiBuilder.Router.Live,
94
+ * HttpPlatform.layer,
95
+ * Etag.layerWeak
96
+ * ).pipe(
97
+ * Layer.provideMerge(NodeContext.layer)
98
+ * )
99
+ * )
100
+ *
101
+ * const handler = HttpApiBuilder.toWebHandler(runtime, HttpMiddleware.logger)
102
+ */
103
+ const toWebHandler = (runtime, middleware) => {
104
+ const handlerPromise = httpApp.pipe(Effect.bindTo("httpApp"), Effect.bind("runtime", () => runtime.runtimeEffect), Effect.map(({
105
+ httpApp,
106
+ runtime
107
+ }) => HttpApp.toWebHandlerRuntime(runtime)(middleware ? middleware(httpApp) : httpApp)), runtime.runPromise);
108
+ return request => handlerPromise.then(handler => handler(request));
109
+ };
77
110
  /**
78
111
  * Build a root level `Layer` from an `HttpApi` instance.
79
112
  *
@@ -85,6 +118,7 @@ const httpApp = exports.httpApp = /*#__PURE__*/Effect.gen(function* () {
85
118
  * @since 1.0.0
86
119
  * @category constructors
87
120
  */
121
+ exports.toWebHandler = toWebHandler;
88
122
  const api = self => Layer.succeed(HttpApi.HttpApi, self);
89
123
  /**
90
124
  * @since 1.0.0