diff --git a/packages/effect/package.json b/packages/effect/package.json index b3f8f806ef..579858e2bb 100644 --- a/packages/effect/package.json +++ b/packages/effect/package.json @@ -37,7 +37,6 @@ "./platform": "./src/platform/index.ts", "./schema": "./src/schema/index.ts", "./stm": "./src/stm/index.ts", - "./stream": "./src/stream/index.ts", "./testing": "./src/testing/index.ts", "./types": "./src/types/index.ts", "./unstable/ai": "./src/unstable/ai/index.ts", @@ -82,7 +81,6 @@ "./platform": "./dist/platform/index.js", "./schema": "./dist/schema/index.js", "./stm": "./dist/stm/index.js", - "./stream": "./dist/stream/index.js", "./testing": "./dist/testing/index.js", "./types": "./dist/types/index.js", "./unstable/ai": "./dist/unstable/ai/index.js", diff --git a/packages/effect/src/stream/Channel.ts b/packages/effect/src/Channel.ts similarity index 97% rename from packages/effect/src/stream/Channel.ts rename to packages/effect/src/Channel.ts index 4e14aa992a..be2161b6dd 100644 --- a/packages/effect/src/stream/Channel.ts +++ b/packages/effect/src/Channel.ts @@ -30,7 +30,7 @@ * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Effect } from "effect" * * // Simple channel that outputs numbers @@ -44,7 +44,7 @@ * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Effect } from "effect" * * // Channel from an array of values @@ -59,33 +59,33 @@ * @since 2.0.0 */ // @effect-diagnostics returnEffectInGen:off -import * as Cause from "../Cause.ts" -import * as Arr from "../collections/Array.ts" -import * as Chunk from "../collections/Chunk.ts" -import * as Iterable from "../collections/Iterable.ts" -import * as Filter from "../data/Filter.ts" -import * as Option from "../data/Option.ts" -import { hasProperty, isTagged } from "../data/Predicate.ts" -import * as Effect from "../Effect.ts" -import * as Exit from "../Exit.ts" -import * as Fiber from "../Fiber.ts" -import type { LazyArg } from "../Function.ts" -import { constant, constTrue, constVoid, dual, identity as identity_ } from "../Function.ts" -import type { Pipeable } from "../interfaces/Pipeable.ts" -import { pipeArguments } from "../interfaces/Pipeable.ts" -import { endSpan } from "../internal/effect.ts" -import { addSpanStackTrace } from "../internal/tracer.ts" -import * as Layer from "../Layer.ts" -import * as PubSub from "../PubSub.ts" -import * as Queue from "../Queue.ts" -import * as Schedule from "../Schedule.ts" -import * as Scope from "../Scope.ts" -import * as ServiceMap from "../ServiceMap.ts" -import * as Pull from "../stream/Pull.ts" -import { ParentSpan, type SpanOptions } from "../Tracer.ts" -import type * as Types from "../types/Types.ts" -import type * as Unify from "../types/Unify.ts" +import * as Cause from "./Cause.ts" +import * as Arr from "./collections/Array.ts" +import * as Chunk from "./collections/Chunk.ts" +import * as Iterable from "./collections/Iterable.ts" +import * as Filter from "./data/Filter.ts" +import * as Option from "./data/Option.ts" +import { hasProperty, isTagged } from "./data/Predicate.ts" +import * as Effect from "./Effect.ts" +import * as Exit from "./Exit.ts" +import * as Fiber from "./Fiber.ts" +import type { LazyArg } from "./Function.ts" +import { constant, constTrue, constVoid, dual, identity as identity_ } from "./Function.ts" +import type { Pipeable } from "./interfaces/Pipeable.ts" +import { pipeArguments } from "./interfaces/Pipeable.ts" +import { endSpan } from "./internal/effect.ts" +import { addSpanStackTrace } from "./internal/tracer.ts" +import * as Layer from "./Layer.ts" +import * as PubSub from "./PubSub.ts" +import * as Pull from "./Pull.ts" +import * as Queue from "./Queue.ts" +import * as Schedule from "./Schedule.ts" +import * as Scope from "./Scope.ts" +import * as ServiceMap from "./ServiceMap.ts" import * as Take from "./Take.ts" +import { ParentSpan, type SpanOptions } from "./Tracer.ts" +import type * as Types from "./types/Types.ts" +import type * as Unify from "./types/Unify.ts" const TypeId = "~effect/Channel" @@ -94,7 +94,7 @@ const TypeId = "~effect/Channel" * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * const channel = Channel.succeed(42) * console.log(Channel.isChannel(channel)) // true @@ -133,7 +133,7 @@ export const isChannel = ( * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * // A channel that outputs numbers and requires no environment * type NumberChannel = Channel.Channel @@ -248,7 +248,7 @@ const ChannelProto = { * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Effect } from "effect" * * const channel = Channel.fromTransform((upstream, scope) => @@ -284,7 +284,7 @@ export const fromTransform = ( * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Queue } from "effect" * * const channel = Channel.callback((queue) => { @@ -470,7 +470,7 @@ export const callback = ( * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Effect, Queue } from "effect" * * const channel = Channel.callbackArray(Effect.fn(function*(queue) { @@ -497,7 +497,7 @@ export const callbackArray = ( * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * const channel = Channel.suspend(() => Channel.succeed(42)) * // The inner channel is not created until the suspended channel is run @@ -517,7 +517,7 @@ export const suspend = ( * @example * ```ts * import { Effect, Exit } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * const channel = Channel.acquireUseRelease( * Effect.succeed("resource"), @@ -553,7 +553,7 @@ export const acquireUseRelease = numbers[Symbol.iterator]()) @@ -612,7 +612,7 @@ export const fromIterator = (iterator: LazyArg>): Channel(array: ReadonlyArray): Channel => * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Chunk } from "effect/collections" * * const chunk = Chunk.make(1, 2, 3) @@ -650,7 +650,7 @@ export const fromChunk = (chunk: Chunk.Chunk): Channel => fromArray(Chu * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Effect } from "effect" * * // Create a channel from a simple iterator @@ -672,7 +672,7 @@ export const fromChunk = (chunk: Chunk.Chunk): Channel => fromArray(Chu * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * // Create channel from a generator function * function* fibonacci(): Generator { @@ -722,7 +722,7 @@ export const fromIteratorArray = ( * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * const set = new Set([1, 2, 3]) * const channel = Channel.fromIterable(set) @@ -740,7 +740,7 @@ export const fromIterable = (iterable: Iterable): Channel( * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * const channel = Channel.succeed(42) * // Emits: 42 @@ -776,7 +776,7 @@ export const succeed = (value: A): Channel => fromEffect(Effect.succeed(va * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * const channel = Channel.end("done") * // Ends immediately with "done", emits nothing @@ -801,7 +801,7 @@ export const endSync = (evaluate: LazyArg): Channel => * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * const channel = Channel.sync(() => Math.random()) * // Emits a random number computed when the channel runs @@ -817,7 +817,7 @@ export const sync = (evaluate: LazyArg): Channel => fromEffect(Effect.s * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * // Create an empty channel * const emptyChannel = Channel.empty @@ -841,7 +841,7 @@ export const empty: Channel = fromPull(Effect.succeed(Pull.haltVoid)) * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Effect } from "effect" * * // Create a channel that never completes @@ -868,7 +868,7 @@ export const never: Channel = fromPull(Effect.succeed(Effec * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Effect } from "effect" * * // Create a channel that fails with a string error @@ -901,7 +901,7 @@ export const fail = (error: E): Channel => fromPull(Effect.s * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * // Create a channel that fails with a lazily computed error * const failedChannel = Channel.failSync(() => { @@ -932,7 +932,7 @@ export const failSync = (evaluate: LazyArg): Channel => f * @example * ```ts * import { Cause } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * // Create a channel that fails with a simple cause * const simpleCause = Cause.fail("Simple error") @@ -959,7 +959,7 @@ export const failCause = (cause: Cause.Cause): Channel => * @example * ```ts * import { Cause } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * // Create a channel that fails with a lazily computed cause * const failedChannel = Channel.failCauseSync(() => { @@ -986,7 +986,7 @@ export const failCauseSync = ( * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * // Create a channel that dies with a string defect * const diedChannel = Channel.die("Unrecoverable error") @@ -1012,7 +1012,7 @@ export const die = (defect: unknown): Channel => failCause( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class DatabaseError extends Data.TaggedError("DatabaseError")<{ @@ -1083,7 +1083,7 @@ export const fromEffectTake = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * import { Queue } from "effect" * @@ -1128,7 +1128,7 @@ export const fromQueue = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * import { Queue } from "effect" * @@ -1183,7 +1183,7 @@ export const identity = (): Channel( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * import { PubSub } from "effect" * @@ -1269,7 +1269,7 @@ export const fromSubscription = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * import { PubSub } from "effect" * @@ -1297,7 +1297,7 @@ export const fromSubscription = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * import { PubSub } from "effect" * @@ -1354,7 +1354,7 @@ export const fromSubscriptionArray = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * import { PubSub } from "effect" * @@ -1381,7 +1381,7 @@ export const fromSubscriptionArray = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * import { PubSub } from "effect" * @@ -1409,7 +1409,7 @@ export const fromSubscriptionArray = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * import { PubSub } from "effect" * @@ -1466,7 +1466,7 @@ export const fromPubSub = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * import { PubSub } from "effect" * @@ -1494,7 +1494,7 @@ export const fromPubSub = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * import { PubSub } from "effect" * @@ -1537,7 +1537,7 @@ export const fromPubSub = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * import { PubSub } from "effect" * @@ -1652,7 +1652,7 @@ export const fromAsyncIterableArray = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class TransformError extends Data.TaggedError("TransformError")<{ @@ -1776,7 +1776,7 @@ const concurrencyIsSequential = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class NetworkError extends Data.TaggedError("NetworkError")<{ @@ -2039,7 +2039,7 @@ export const mapInputError: { * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Console } from "effect" * import { Data } from "effect/data" * @@ -2100,7 +2100,7 @@ export const tap: { * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class ProcessError extends Data.TaggedError("ProcessError")<{ @@ -2305,7 +2305,7 @@ const flatMapConcurrent = < * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class ConcatError extends Data.TaggedError("ConcatError")<{ @@ -2421,7 +2421,7 @@ export const concatWith: { * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class ConcatError extends Data.TaggedError("ConcatError")<{ @@ -2728,7 +2728,7 @@ export const orElseIfEmpty: { * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class FlattenError extends Data.TaggedError("FlattenError")<{ @@ -2784,7 +2784,7 @@ export const flatten = < * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class FlattenError extends Data.TaggedError("FlattenError")<{ @@ -2871,7 +2871,7 @@ export const flattenTake = < * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Effect } from "effect" * * // Create a channel that outputs values @@ -3007,7 +3007,7 @@ export const schedule: { * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Effect } from "effect" * * // Create a channel with mixed numbers @@ -3064,7 +3064,7 @@ export const filter: { * ```ts * import { Array } from "effect/collections" * import { Filter } from "effect/data" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * const nonEmptyArrayFilter: Filter.Filter< * Array, @@ -3147,7 +3147,7 @@ export const filterArrayEffect: { * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Effect } from "effect" * * // Create a channel with numbers @@ -3288,7 +3288,7 @@ export const mapAccum: { * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Effect } from "effect" * * // Create a channel with numbers @@ -3345,7 +3345,7 @@ export const scan: { * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Effect } from "effect" * import { Data } from "effect/data" * @@ -3436,7 +3436,7 @@ export const scanEffect: { * @example * ```ts * import { Effect, Cause } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class ProcessError extends Data.TaggedError("ProcessError")<{ @@ -4107,7 +4107,7 @@ export const mapError: { * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class ValidationError extends Data.TaggedError("ValidationError")<{ @@ -4238,7 +4238,7 @@ export const retry: { * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class SwitchError extends Data.TaggedError("SwitchError")<{ @@ -4357,7 +4357,7 @@ export const switchMap: { * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class MergeAllError extends Data.TaggedError("MergeAllError")<{ @@ -4525,7 +4525,7 @@ export const mergeAll: { * * @example * ```ts - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * * // Different halt strategies for channel merging * const leftFirst: Channel.HaltStrategy = "left" // Stop when left channel halts @@ -4546,7 +4546,7 @@ export type HaltStrategy = "left" | "right" | "both" | "either" * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class MergeError extends Data.TaggedError("MergeError")<{ @@ -4864,7 +4864,7 @@ export const encodeText = (): Channel< * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class PipeError extends Data.TaggedError("PipeError")<{ @@ -4913,7 +4913,7 @@ export const pipeTo: { * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class SourceError extends Data.TaggedError("SourceError")<{ @@ -4976,7 +4976,7 @@ export const pipeToOrFail: { * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * import { Scope } from "effect" * @@ -5028,7 +5028,7 @@ export const scoped = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class EmbedError extends Data.TaggedError("EmbedError")<{ @@ -5262,7 +5262,7 @@ export const onError: { * @example * ```ts * import { Effect, Exit } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Console } from "effect" * import { Data } from "effect/data" * @@ -5385,7 +5385,7 @@ export const onEnd: { * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Console } from "effect" * import { Data } from "effect/data" * @@ -5854,7 +5854,7 @@ export const bindTo: { * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class CountError extends Data.TaggedError("CountError")<{ @@ -5883,7 +5883,7 @@ export const runCount = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class DrainError extends Data.TaggedError("DrainError")<{ @@ -5913,7 +5913,7 @@ export const runDrain = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Console } from "effect" * import { Data } from "effect/data" * @@ -5988,7 +5988,7 @@ export const runForEachWhile: { * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class CollectError extends Data.TaggedError("CollectError")<{ @@ -6074,7 +6074,7 @@ export const runLast = ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * * class FoldError extends Data.TaggedError("FoldError")<{ @@ -6172,7 +6172,7 @@ export const runFoldEffect: { * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * import { Scope } from "effect" * @@ -6223,7 +6223,7 @@ export const toPull: ( * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * import { Scope } from "effect" * @@ -6316,7 +6316,7 @@ export const runIntoQueueArray: { * @example * ```ts * import { Effect } from "effect" - * import { Channel } from "effect/stream" + * import { Channel } from "effect" * import { Data } from "effect/data" * import { Queue } from "effect" * diff --git a/packages/effect/src/stream/ChannelSchema.ts b/packages/effect/src/ChannelSchema.ts similarity index 96% rename from packages/effect/src/stream/ChannelSchema.ts rename to packages/effect/src/ChannelSchema.ts index 9b34465521..a7c86e265f 100644 --- a/packages/effect/src/stream/ChannelSchema.ts +++ b/packages/effect/src/ChannelSchema.ts @@ -1,11 +1,11 @@ /** * @since 4.0.0 */ -import type * as Arr from "../collections/Array.ts" -import * as Effect from "../Effect.ts" -import { dual } from "../Function.ts" -import * as Schema from "../schema/Schema.ts" import * as Channel from "./Channel.ts" +import type * as Arr from "./collections/Array.ts" +import * as Effect from "./Effect.ts" +import { dual } from "./Function.ts" +import * as Schema from "./schema/Schema.ts" /** * @since 4.0.0 diff --git a/packages/effect/src/stream/Pull.ts b/packages/effect/src/Pull.ts similarity index 91% rename from packages/effect/src/stream/Pull.ts rename to packages/effect/src/Pull.ts index a3a4b2e48b..85cc8403b7 100644 --- a/packages/effect/src/stream/Pull.ts +++ b/packages/effect/src/Pull.ts @@ -1,13 +1,13 @@ /** * @since 4.0.0 */ -import * as Cause from "../Cause.ts" -import * as Filter from "../data/Filter.ts" -import { hasProperty } from "../data/Predicate.ts" -import type { Effect } from "../Effect.ts" -import * as Exit from "../Exit.ts" -import { dual } from "../Function.ts" -import * as internalEffect from "../internal/effect.ts" +import * as Cause from "./Cause.ts" +import * as Filter from "./data/Filter.ts" +import { hasProperty } from "./data/Predicate.ts" +import type { Effect } from "./Effect.ts" +import * as Exit from "./Exit.ts" +import { dual } from "./Function.ts" +import * as internalEffect from "./internal/effect.ts" /** * A Pull is a specialized Effect that represents a pull-based stream operation. @@ -16,7 +16,7 @@ import * as internalEffect from "../internal/effect.ts" * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * import { Effect } from "effect" * * // A Pull that emits a single value @@ -39,7 +39,7 @@ export interface Pull exte * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * import { Effect } from "effect" * * type MyPull = Pull.Pull @@ -56,7 +56,7 @@ export type Success

= P extends Effect ? _A : n * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * import { Effect } from "effect" * * type MyPull = Pull.Pull @@ -74,7 +74,7 @@ export type Error

= P extends Effect ? _E exten * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * import { Effect } from "effect" * * type MyPull = Pull.Pull @@ -92,7 +92,7 @@ export type Leftover

= P extends Effect ? _E ex * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * import { Effect } from "effect" * import { ServiceMap } from "effect" * @@ -115,7 +115,7 @@ export type ServiceMap

= P extends Effect ? _R * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * * type ErrorUnion = string | Pull.Halt | Error * type WithoutHalt = Pull.ExcludeHalt // string | Error @@ -134,7 +134,7 @@ export type ExcludeHalt = Exclude> * @since 4.0.0 * @category Halt */ -export const HaltTypeId = "~effect/stream/Pull/Halt" +export const HaltTypeId = "~effect/Pull/Halt" /** * Represents a halt error that carries a leftover value. @@ -161,7 +161,7 @@ export class Halt { * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * * // Extract leftover type from halt * type MyHalt = Pull.Halt @@ -181,7 +181,7 @@ export declare namespace Halt { * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * * type MyHalt = Pull.Halt * type Leftover = Pull.Halt.Extract // string @@ -197,7 +197,7 @@ export declare namespace Halt { * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * * type ErrorUnion = string | Pull.Halt * type OnlyHalt = Pull.Halt.Only // Pull.Halt @@ -214,7 +214,7 @@ export declare namespace Halt { * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * import { Effect } from "effect" * * const pullWithHalt = Pull.halt("stream ended") @@ -245,7 +245,7 @@ export const catchHalt: { * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * * const halt = new Pull.Halt("completed") * const regularError = new Error("failed") @@ -264,7 +264,7 @@ export const isHalt = (u: unknown): u is Halt => hasProperty(u, HaltTyp * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * import { Cause } from "effect" * * const halt = new Pull.Halt("completed") @@ -285,7 +285,7 @@ export const isHaltCause = (cause: Cause.Cause): boolean => cause.failures * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * import { Cause } from "effect" * * const halt = new Pull.Halt("completed") @@ -332,7 +332,7 @@ export const filterNoHalt: ( * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * import { Cause } from "effect" * * const halt = new Pull.Halt("stream completed") @@ -357,7 +357,7 @@ export const filterHaltLeftover: ( * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * import { Effect } from "effect" * * // Create a halt with a string leftover @@ -377,7 +377,7 @@ export const halt = (leftover: L): Effect> => internalEffect.f * * @example * ```ts - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * import { Effect } from "effect" * * // Use the pre-defined halt with void @@ -398,7 +398,7 @@ export const haltVoid: Effect> = internalEffect.fail(new Halt( * @example * ```ts * import { Cause, Exit } from "effect" - * import { Pull } from "effect/stream" + * import { Pull } from "effect" * * const halt = new Pull.Halt("completed") * const causeWithHalt = Cause.fail(halt) @@ -421,7 +421,7 @@ export const haltExitFromCause = (cause: Cause.Cause): Exit.Exit` is used to consume elements produced by a `Stream`. @@ -30,8 +30,8 @@ const TypeId = "~effect/stream/Sink" * * @example * ```ts - * import * as Sink from "effect/stream/Sink" - * import * as Stream from "effect/stream/Stream" + * import * as Sink from "effect/Sink" + * import * as Stream from "effect/Stream" * import { Effect } from "effect" * * // Create a simple sink that always succeeds with a value @@ -76,7 +76,7 @@ const endVoid = Pull.halt([void 0] as End) * * @example * ```ts - * import type * as Sink from "effect/stream/Sink" + * import type * as Sink from "effect/Sink" * import type { Effect } from "effect" * import type * as Unify from "effect/types/Unify" * @@ -110,7 +110,7 @@ export interface SinkUnify extends Effec * * @example * ```ts - * import type * as Sink from "effect/stream/Sink" + * import type * as Sink from "effect/Sink" * * // Used internally by the type system * type IgnoreConfig = Sink.SinkUnifyIgnore @@ -128,7 +128,7 @@ export interface SinkUnifyIgnore extends Effect.EffectUnifyIgnore { * * @example * ```ts - * import type * as Sink from "effect/stream/Sink" + * import type * as Sink from "effect/Sink" * * // The Sink namespace contains internal type definitions * // These are used internally for type safety and variance @@ -145,7 +145,7 @@ export declare namespace Sink { * * @example * ```ts - * import type * as Sink from "effect/stream/Sink" + * import type * as Sink from "effect/Sink" * * // The variance interface is used internally * // It defines how type parameters behave in Sink @@ -164,7 +164,7 @@ export declare namespace Sink { * * @example * ```ts - * import type * as Sink from "effect/stream/Sink" + * import type * as Sink from "effect/Sink" * * // The variance structure is used internally by the type system * // It ensures proper type safety for Sink operations @@ -203,7 +203,7 @@ const SinkProto = { * * @example * ```ts - * import { Sink } from "effect/stream" + * import { Sink } from "effect" * * const sink = Sink.never * const notStream = { data: [1, 2, 3] } @@ -257,8 +257,8 @@ export const fromTransform = ( * * @example * ```ts - * import { Sink } from "effect/stream" - * import { Channel } from "effect/stream" + * import { Sink } from "effect" + * import { Channel } from "effect" * * // Create a sink and extract its channel * const sink = Sink.succeed(42) @@ -277,8 +277,8 @@ export const toChannel = ( * * @example * ```ts - * import { Sink } from "effect/stream" - * import { Stream } from "effect/stream" + * import { Sink } from "effect" + * import { Stream } from "effect" * import { Effect } from "effect" * * // Create a sink that always yields the same value @@ -320,8 +320,8 @@ export const suspend = (evaluate: LazyArg>) * * @example * ```ts - * import { Sink } from "effect/stream" - * import { Stream } from "effect/stream" + * import { Sink } from "effect" + * import { Stream } from "effect" * import { Effect } from "effect" * * // Create a sink that always fails @@ -345,8 +345,8 @@ export const fail = (e: E): Sink => fromChannel(Cha * * @example * ```ts - * import { Sink } from "effect/stream" - * import { Stream } from "effect/stream" + * import { Sink } from "effect" + * import { Stream } from "effect" * import { Effect } from "effect" * * // Create a sink that fails with a lazy error @@ -371,8 +371,8 @@ export const failSync = (evaluate: LazyArg): Sink(cause: Cause.Cause): Sink(evaluate: LazyArg>): Sink( * ```ts * import { Effect } from "effect" * import { Console } from "effect" - * import { Sink, Stream } from "effect/stream" + * import { Sink, Stream } from "effect" * * // Create a sink that logs each item * const sink = Sink.forEach((item: number) => Console.log(`Processing: ${item}`)) @@ -1078,7 +1078,7 @@ export const forEach = ( * ```ts * import { Effect } from "effect" * import { Console } from "effect" - * import { Sink, Stream } from "effect/stream" + * import { Sink, Stream } from "effect" * * // Create a sink that processes chunks * const sink = Sink.forEachArray((chunk: readonly number[]) => @@ -1116,7 +1116,7 @@ export const forEachArray = ( * ```ts * import { Effect } from "effect" * import { Console } from "effect" - * import { Sink, Stream } from "effect/stream" + * import { Sink, Stream } from "effect" * * // Create a sink from an effect that produces a sink * const sinkEffect = Effect.succeed(Sink.forEach((item: number) => Console.log(`Item: ${item}`))) diff --git a/packages/effect/src/stream/Stream.ts b/packages/effect/src/Stream.ts similarity index 97% rename from packages/effect/src/stream/Stream.ts rename to packages/effect/src/Stream.ts index 42ace46884..165d681b8a 100644 --- a/packages/effect/src/stream/Stream.ts +++ b/packages/effect/src/Stream.ts @@ -2,46 +2,46 @@ * @since 2.0.0 */ // @effect-diagnostics returnEffectInGen:off -import * as Cause from "../Cause.ts" -import { Clock } from "../Clock.ts" -import * as Arr from "../collections/Array.ts" -import * as Iterable from "../collections/Iterable.ts" -import * as MutableHashMap from "../collections/MutableHashMap.ts" -import * as MutableList from "../collections/MutableList.ts" -import * as Filter from "../data/Filter.ts" -import * as Option from "../data/Option.ts" -import { hasProperty, isTagged } from "../data/Predicate.ts" -import * as Result from "../data/Result.ts" -import * as Duration from "../Duration.ts" -import * as Effect from "../Effect.ts" -import * as ExecutionPlan from "../ExecutionPlan.ts" -import * as Exit from "../Exit.ts" -import * as Fiber from "../Fiber.ts" -import type { LazyArg } from "../Function.ts" -import { constant, constTrue, constVoid, dual, identity } from "../Function.ts" -import * as Equal from "../interfaces/Equal.ts" -import { type Pipeable, pipeArguments } from "../interfaces/Pipeable.ts" -import * as internalExecutionPlan from "../internal/executionPlan.ts" -import { addSpanStackTrace } from "../internal/tracer.ts" -import type * as Layer from "../Layer.ts" -import type * as PubSub from "../PubSub.ts" -import * as Queue from "../Queue.ts" -import * as RcMap from "../RcMap.ts" -import * as RcRef from "../RcRef.ts" -import * as Schedule from "../Schedule.ts" -import * as Scope from "../Scope.ts" -import * as ServiceMap from "../ServiceMap.ts" -import * as Channel from "../stream/Channel.ts" -import * as Pull from "../stream/Pull.ts" -import * as Sink from "../stream/Sink.ts" -import { isString } from "../String.ts" -import type { ParentSpan, SpanOptions } from "../Tracer.ts" -import type { TypeLambda } from "../types/HKT.ts" -import type { Covariant, ExcludeTag, ExtractTag, NoInfer, Tags } from "../types/Types.ts" -import type * as Unify from "../types/Unify.ts" +import * as Cause from "./Cause.ts" +import * as Channel from "./Channel.ts" +import { Clock } from "./Clock.ts" +import * as Arr from "./collections/Array.ts" +import * as Iterable from "./collections/Iterable.ts" +import * as MutableHashMap from "./collections/MutableHashMap.ts" +import * as MutableList from "./collections/MutableList.ts" +import * as Filter from "./data/Filter.ts" +import * as Option from "./data/Option.ts" +import { hasProperty, isTagged } from "./data/Predicate.ts" +import * as Result from "./data/Result.ts" +import * as Duration from "./Duration.ts" +import * as Effect from "./Effect.ts" +import * as ExecutionPlan from "./ExecutionPlan.ts" +import * as Exit from "./Exit.ts" +import * as Fiber from "./Fiber.ts" +import type { LazyArg } from "./Function.ts" +import { constant, constTrue, constVoid, dual, identity } from "./Function.ts" +import * as Equal from "./interfaces/Equal.ts" +import { type Pipeable, pipeArguments } from "./interfaces/Pipeable.ts" +import * as internalExecutionPlan from "./internal/executionPlan.ts" +import { addSpanStackTrace } from "./internal/tracer.ts" +import type * as Layer from "./Layer.ts" +import type * as PubSub from "./PubSub.ts" +import * as Pull from "./Pull.ts" +import * as Queue from "./Queue.ts" +import * as RcMap from "./RcMap.ts" +import * as RcRef from "./RcRef.ts" +import * as Schedule from "./Schedule.ts" +import * as Scope from "./Scope.ts" +import * as ServiceMap from "./ServiceMap.ts" +import * as Sink from "./Sink.ts" +import { isString } from "./String.ts" import type * as Take from "./Take.ts" +import type { ParentSpan, SpanOptions } from "./Tracer.ts" +import type { TypeLambda } from "./types/HKT.ts" +import type { Covariant, ExcludeTag, ExtractTag, NoInfer, Tags } from "./types/Types.ts" +import type * as Unify from "./types/Unify.ts" -const TypeId = "~effect/stream/Stream" +const TypeId = "~effect/Stream" /** * A `Stream` is a description of a program that, when evaluated, may @@ -62,7 +62,7 @@ const TypeId = "~effect/stream/Stream" * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * // Create a stream that emits numbers 1, 2, 3 @@ -93,7 +93,7 @@ export interface Stream extends Variance extends Eff * * @example * ```ts - * import type * as Stream from "effect/stream/Stream" + * import type * as Stream from "effect/Stream" * * // Used internally by the type system * // Users typically don't interact with this directly @@ -137,7 +137,7 @@ export interface StreamUnifyIgnore extends Effect.EffectUnifyIgnore { * @example * ```ts * import type { Kind } from "effect/types/HKT" - * import type { StreamTypeLambda } from "effect/stream/Stream" + * import type { StreamTypeLambda } from "effect/Stream" * * // Create a Stream type using the type lambda * type NumberStream = Kind @@ -178,7 +178,7 @@ export interface VarianceStruct { * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * type NumberStream = Stream.Stream * type SuccessType = Stream.Success @@ -195,7 +195,7 @@ export type Success> = [T] extends [Stream * type ErrorType = Stream.Error @@ -212,7 +212,7 @@ export type Error> = [T] extends [Stream unknown } * type NumberStream = Stream.Stream @@ -237,7 +237,7 @@ const streamVariance = { * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * const stream = Stream.make(1, 2, 3) * const notStream = { data: [1, 2, 3] } @@ -263,7 +263,7 @@ const StreamProto = { * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * console.log(Stream.DefaultChunkSize) // 4096 * ``` @@ -288,8 +288,8 @@ export type HaltStrategy = Channel.HaltStrategy * * @example * ```ts - * import { Stream } from "effect/stream" - * import { Channel } from "effect/stream" + * import { Stream } from "effect" + * import { Channel } from "effect" * * const myChannel = Channel.succeed([1, 2, 3] as const) * const stream = Stream.fromChannel(myChannel) @@ -389,7 +389,7 @@ export const tick = (interval: Duration.DurationInput): Stream => * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const pullEffect = Effect.succeed(Effect.succeed([1, 2, 3] as const)) @@ -408,7 +408,7 @@ export const fromPull = ( * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const originalStream = Stream.make(1, 2, 3) @@ -473,7 +473,7 @@ export const transformPullBracket = ( * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * const stream = Stream.make(1, 2, 3) * const channel = Stream.toChannel(stream) @@ -498,7 +498,7 @@ export const toChannel = ( * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * import { Queue } from "effect" * @@ -530,7 +530,7 @@ export const callback = ( * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const emptyStream = Stream.empty @@ -551,7 +551,7 @@ export const empty: Stream = fromChannel(Channel.empty) * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * // A Stream with a single number @@ -571,7 +571,7 @@ export const succeed = (value: A): Stream => fromChannel(Channel.succeed(A * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream = Stream.make(1, 2, 3) @@ -592,7 +592,7 @@ export const make = >(...values: As): Stream * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream = Stream.sync(() => Math.random()) @@ -613,7 +613,7 @@ export const sync = (evaluate: LazyArg): Stream => fromChannel(Channel. * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const lazyStream = Stream.suspend(() => { @@ -636,7 +636,7 @@ export const suspend = (stream: LazyArg>): Stream(error: E): Stream => fromChannel(Channel.fail( * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream = Stream.failSync(() => new Error("Something went wrong")) @@ -685,7 +685,7 @@ export const failSync = (evaluate: LazyArg): Stream => fromChann * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Cause } from "effect" * * const cause = Cause.fail("Database connection failed") @@ -712,7 +712,7 @@ export const die = (defect: unknown): Stream => fromChannel(Channel.die(d * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Cause } from "effect" * * const stream = Stream.failCauseSync(() => @@ -738,7 +738,7 @@ export const failCauseSync = (evaluate: LazyArg>): Stream(iterator: IterableIterator, maxChunkSi * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const numbers = [1, 2, 3] @@ -811,7 +811,7 @@ export const fromIterableEffectRepeat = ( * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const numbers = [1, 2, 3, 4, 5] @@ -857,7 +857,7 @@ export const fromArrays = >>( * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * import { Queue } from "effect" * @@ -885,7 +885,7 @@ export const fromQueue = (queue: Queue.Dequeue): Stream(pubsub: PubSub.PubSub>): St * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const readableStream = new ReadableStream({ @@ -994,7 +994,7 @@ export const fromSchedule = (schedule: Schedule.Schedule(pubsub: PubSub.Subscription): Stream = * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * // DOM element implementing EventListener * declare const button: HTMLButtonElement @@ -1057,7 +1057,7 @@ export interface EventListener { * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * // In a browser environment @@ -1098,7 +1098,7 @@ export const fromEventListener = ( * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * const stream = Stream.unfold(1, (n) => Effect.succeed([n, n + 1])) * @@ -1127,7 +1127,7 @@ export const unfold = ( * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * import * as Option from "effect/data/Option" * @@ -1177,7 +1177,7 @@ export const paginate = ( * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * // An infinite Stream of numbers starting from 1 and incrementing * const stream = Stream.iterate(1, (n) => n + 1) @@ -1201,7 +1201,7 @@ export const iterate = (value: A, next: (value: A) => A): Stream => * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream = Stream.range(1, 5) @@ -1239,7 +1239,7 @@ export const range = ( * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * // A stream that never emits values or completes @@ -1260,7 +1260,7 @@ export const never: Stream = fromChannel(Channel.never) * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const effectThatCreatesStream = Effect.succeed( @@ -1292,7 +1292,7 @@ export const scoped = ( * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream = Stream.fromArray([1, 2, 3]).pipe(Stream.map((n) => n + 1)) @@ -1363,7 +1363,7 @@ export const mapArray: { * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Console } from "effect" * * const stream = Stream.make(1, 2, 3) @@ -1482,7 +1482,7 @@ export const result = (self: Stream): Stream(self: Stream, E2, R>): * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream1 = Stream.make(1, 2, 3) @@ -2163,7 +2163,7 @@ export const crossWith: { * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * const stream1 = Stream.make(1, 2, 3, 4, 5, 6) * const stream2 = Stream.make("a", "b", "c") @@ -2304,7 +2304,7 @@ export const zipWithArray: { * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * const stream1 = Stream.make(1, 2, 3) * const stream2 = Stream.make("a", "b", "c") @@ -2338,7 +2338,7 @@ export const zip: { * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * const stream1 = Stream.make(1, 2, 3, 4) * const stream2 = Stream.make("a", "b") @@ -2380,7 +2380,7 @@ export const zipLeft: { * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * const stream1 = Stream.make(1, 2) * const stream2 = Stream.make("a", "b", "c", "d") @@ -2422,7 +2422,7 @@ export const zipRight: { * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * const stream1 = Stream.make([1, "a"] as const, [2, "b"] as const, [3, "c"] as const) * const stream2 = Stream.make("x", "y", "z") @@ -2458,7 +2458,7 @@ export const zipFlatten: { * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * const stream = Stream.make("a", "b", "c", "d") * @@ -2479,7 +2479,7 @@ export const zipWithIndex = (self: Stream): Stream<[A, number] * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * const stream = Stream.zipWithNext(Stream.make(1, 2, 3, 4)) * @@ -2522,7 +2522,7 @@ export const zipWithNext = (self: Stream): Stream<[A, Option.O * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * const stream = Stream.zipWithPrevious(Stream.make(1, 2, 3, 4)) * @@ -2555,7 +2555,7 @@ export const zipWithPrevious = (self: Stream): Stream<[Option. * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * const stream = Stream.zipWithPreviousAndNext(Stream.make(1, 2, 3, 4)) * @@ -2673,7 +2673,7 @@ export const zipLatestAll = >>( * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * const s1 = Stream.make(1, 2, 3) * const s2 = Stream.make("a", "b", "c", "d") @@ -2687,7 +2687,7 @@ export const zipLatestAll = >>( * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * // Combining sensor readings with timestamps * const temperatures = Stream.make(20.5, 21.0, 20.8, 22.1) @@ -2732,7 +2732,7 @@ export const zipLatest: { * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * const numbers = Stream.make(1, 2, 3) * const multipliers = Stream.make(10, 20, 30) @@ -2750,7 +2750,7 @@ export const zipLatest: { * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * // Combining first and last names * const firstNames = Stream.make("Alice", "Bob", "Charlie") @@ -3155,7 +3155,7 @@ export const bufferArray: { * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Cause } from "effect" * * const failingStream = Stream.make(1, 2).pipe( @@ -3406,7 +3406,7 @@ export const mapError: { * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Cause } from "effect" * * const failingStream = Stream.fail("NetworkError") @@ -3484,7 +3484,7 @@ export const orElseSucceed: { * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const failingStream = Stream.fail("This will become a defect") @@ -3650,7 +3650,7 @@ export const withExecutionPlan: { * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream = Stream.make(1, 2, 3, 4, 5) @@ -3680,7 +3680,7 @@ export const take: { * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * const stream = Stream.takeRight(Stream.make(1, 2, 3, 4, 5, 6), 3) * @@ -3716,7 +3716,7 @@ export const takeRight: { * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream = Stream.make(1, 2, 3, 4, 5, 6) @@ -3777,7 +3777,7 @@ export const takeUntil: { * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream = Stream.make(1, 2, 3, 4, 5) @@ -3836,7 +3836,7 @@ export const takeUntilEffect: { * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream = Stream.make(1, 2, 3, 4, 5, 6) @@ -3865,7 +3865,7 @@ export const takeWhile: { * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream = Stream.make(1, 2, 3, 4, 5) @@ -3902,7 +3902,7 @@ export const takeWhileEffect: { * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream = Stream.make(1, 2, 3, 4, 5) @@ -4076,7 +4076,7 @@ export const dropRight: { * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream = Stream.make(1, 2, 3, 4, 5) @@ -4221,7 +4221,7 @@ export const slidingSize: { * ```ts * import { pipe } from "effect" * import { Filter } from "effect/data" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * pipe( * Stream.range(1, 10), @@ -4720,7 +4720,7 @@ export const debounce: { * @example * ```ts * import { Effect, Schedule } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * // Using the "shape" strategy to delay elements * const stream = Stream.fromSchedule(Schedule.spaced("50 millis")).pipe( @@ -4878,7 +4878,7 @@ const throttleShapeEffect = ( * @example * ```ts * import { Effect, Schedule } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * * // Rate limiting a stream to 1 element per 100ms using array length as cost * const stream = Stream.fromSchedule(Schedule.spaced("50 millis")).pipe( @@ -5442,7 +5442,7 @@ export const share: { * @example * ```ts * import { Effect } from "effect" - * import { Stream, Channel } from "effect/stream" + * import { Stream, Channel } from "effect" * import { Console } from "effect" * * // Create a channel that processes chunks - this is a conceptual example @@ -5470,7 +5470,7 @@ export const share: { * @example * ```ts * import { Effect } from "effect" - * import { Stream, Channel } from "effect/stream" + * import { Stream, Channel } from "effect" * import { Console } from "effect" * * // Practical example: combining two channels with pipeTo @@ -5529,7 +5529,7 @@ export const pipeThroughChannel: { * @example * ```ts * import { Effect } from "effect" - * import { Stream, Channel } from "effect/stream" + * import { Stream, Channel } from "effect" * import { Console } from "effect" * * // Channel that might fail during processing @@ -5553,7 +5553,7 @@ export const pipeThroughChannel: { * @example * ```ts * import { Effect } from "effect" - * import { Stream, Channel } from "effect/stream" + * import { Stream, Channel } from "effect" * import { Console } from "effect" * * // Demonstrate error preservation: both stream and channel can fail @@ -5739,7 +5739,7 @@ export const changesWithEffect: { * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const encoder = new TextEncoder() @@ -5772,7 +5772,7 @@ export const decodeText: { * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream = Stream.make("Hello", " ", "World") @@ -5806,7 +5806,7 @@ export const splitLines = (self: Stream): Stream @@ -6430,7 +6430,7 @@ export const bindTo: { * @example * ```ts * import { Effect } from "effect" - * import { Stream, Sink } from "effect/stream" + * import { Stream, Sink } from "effect" * * const stream = Stream.make(1, 2, 3, 4, 5) * const collectSink = Sink.succeed(42) @@ -6466,7 +6466,7 @@ export const run: { * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream = Stream.make(1, 2, 3, 4, 5) @@ -6497,7 +6497,7 @@ export const runCollect = (self: Stream): Effect.Effect(self: Stream): Effect.Effect(self: Stream): Effect.Effect( * * @example * ```ts - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Effect } from "effect" * * const stream = Stream.make("Hello", " ", "World", "!") @@ -6806,7 +6806,7 @@ export const mkString = (self: Stream): Effect.Effect(value: A) => Effect.Effect> = Effect.f * @example * ```ts * import { Effect } from "effect" - * import { Stream, SubscriptionRef } from "effect/stream" + * import { Stream, SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(0) @@ -118,7 +118,7 @@ export const changes = (self: SubscriptionRef): Stream.Stream => * @example * ```ts * import { Effect } from "effect" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(42) @@ -139,7 +139,7 @@ export const getUnsafe = (self: SubscriptionRef): A => self.backing.ref.cu * @example * ```ts * import { Effect } from "effect" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(42) @@ -161,7 +161,7 @@ export const get = (self: SubscriptionRef): Effect.Effect => Effect.syn * @example * ```ts * import { Effect } from "effect" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -193,7 +193,7 @@ export const getAndSet: { * @example * ```ts * import { Effect } from "effect" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -227,7 +227,7 @@ export const getAndUpdate: { * @example * ```ts * import { Effect } from "effect" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -269,7 +269,7 @@ export const getAndUpdateEffect: { * ```ts * import { Effect } from "effect" * import { Option } from "effect/data" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -313,7 +313,7 @@ export const getAndUpdateSome: { * ```ts * import { Effect } from "effect" * import { Option } from "effect/data" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -362,7 +362,7 @@ export const getAndUpdateSomeEffect: { * @example * ```ts * import { Effect } from "effect" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -402,7 +402,7 @@ export const modify: { * @example * ```ts * import { Effect } from "effect" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -449,7 +449,7 @@ export const modifyEffect: { * ```ts * import { Effect } from "effect" * import { Option } from "effect/data" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -497,7 +497,7 @@ export const modifySome: { * ```ts * import { Effect } from "effect" * import { Option } from "effect/data" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -549,7 +549,7 @@ export const modifySomeEffect: { * @example * ```ts * import { Effect } from "effect" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(0) @@ -580,7 +580,7 @@ export const set: { * @example * ```ts * import { Effect } from "effect" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(0) @@ -609,7 +609,7 @@ export const setAndGet: { * @example * ```ts * import { Effect } from "effect" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -641,7 +641,7 @@ export const update: { * @example * ```ts * import { Effect } from "effect" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -680,7 +680,7 @@ export const updateEffect: { * @example * ```ts * import { Effect } from "effect" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -711,7 +711,7 @@ export const updateAndGet: { * @example * ```ts * import { Effect } from "effect" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -750,7 +750,7 @@ export const updateAndGetEffect: { * ```ts * import { Effect } from "effect" * import { Option } from "effect/data" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -792,7 +792,7 @@ export const updateSome: { * ```ts * import { Effect } from "effect" * import { Option } from "effect/data" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -841,7 +841,7 @@ export const updateSomeEffect: { * ```ts * import { Effect } from "effect" * import { Option } from "effect/data" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) @@ -882,7 +882,7 @@ export const updateSomeAndGet: { * ```ts * import { Effect } from "effect" * import { Option } from "effect/data" - * import { SubscriptionRef } from "effect/stream" + * import { SubscriptionRef } from "effect" * * const program = Effect.gen(function* () { * const ref = yield* SubscriptionRef.make(10) diff --git a/packages/effect/src/stream/Take.ts b/packages/effect/src/Take.ts similarity index 77% rename from packages/effect/src/stream/Take.ts rename to packages/effect/src/Take.ts index 3c0a5815b5..a6e06ef230 100644 --- a/packages/effect/src/stream/Take.ts +++ b/packages/effect/src/Take.ts @@ -1,9 +1,9 @@ /** * @since 2.0.0 */ -import type { NonEmptyReadonlyArray } from "../collections/Array.ts" -import * as Effect from "../Effect.ts" -import * as Exit from "../Exit.ts" +import type { NonEmptyReadonlyArray } from "./collections/Array.ts" +import * as Effect from "./Effect.ts" +import * as Exit from "./Exit.ts" import * as Pull from "./Pull.ts" /** diff --git a/packages/effect/src/index.ts b/packages/effect/src/index.ts index d708b39de0..95216ac44d 100644 --- a/packages/effect/src/index.ts +++ b/packages/effect/src/index.ts @@ -112,6 +112,73 @@ export * as Cache from "./Cache.ts" */ export * as Cause from "./Cause.ts" +/** + * The `Channel` module provides a powerful abstraction for bi-directional communication + * and streaming operations. A `Channel` is a nexus of I/O operations that supports both + * reading and writing, forming the foundation for Effect's Stream and Sink abstractions. + * + * ## What is a Channel? + * + * A `Channel` represents: + * - **OutElem**: The type of elements the channel outputs + * - **OutErr**: The type of errors the channel can produce + * - **OutDone**: The type of the final value when the channel completes + * - **InElem**: The type of elements the channel reads + * - **InErr**: The type of errors the channel can receive + * - **InDone**: The type of the final value from upstream + * - **Env**: The environment/context required by the channel + * + * ## Key Features + * + * - **Bi-directional**: Channels can both read and write + * - **Composable**: Channels can be piped, sequenced, and concatenated + * - **Resource-safe**: Automatic cleanup and resource management + * - **Error-handling**: Built-in error propagation and handling + * - **Concurrent**: Support for concurrent operations + * + * ## Composition Patterns + * + * 1. **Piping**: Connect channels where output of one becomes input of another + * 2. **Sequencing**: Use the result of one channel to create another + * 3. **Concatenating**: Combine multiple channels into a single channel + * + * @example + * ```ts + * import { Channel } from "effect" + * import { Effect } from "effect" + * + * // Simple channel that outputs numbers + * const numberChannel = Channel.succeed(42) + * + * // Transform channel that doubles values + * const doubleChannel = Channel.map(numberChannel, (n) => n * 2) + * + * // Running the channel would output: 84 + * ``` + * + * @example + * ```ts + * import { Channel } from "effect" + * import { Effect } from "effect" + * + * // Channel from an array of values + * const arrayChannel = Channel.fromArray([1, 2, 3, 4, 5]) + * + * // Transform the channel by mapping over values + * const transformedChannel = Channel.map(arrayChannel, (n) => n * 2) + * + * // This channel will output: 2, 4, 6, 8, 10 + * ``` + * + * @since 2.0.0 + */ +export * as Channel from "./Channel.ts" + +/** + * @since 4.0.0 + */ +export * as ChannelSchema from "./ChannelSchema.ts" + /** * The `Clock` module provides functionality for time-based operations in Effect applications. * It offers precise time measurements, scheduling capabilities, and controlled time management @@ -1044,6 +1111,11 @@ export * as Pool from "./Pool.ts" */ export * as PubSub from "./PubSub.ts" +/** + * @since 4.0.0 + */ +export * as Pull from "./Pull.ts" + /** * This module provides utilities for working with asynchronous queues that support various backpressure strategies. * @@ -1305,6 +1377,16 @@ export * as ScopedRef from "./ScopedRef.ts" */ export * as ServiceMap from "./ServiceMap.ts" +/** + * @since 2.0.0 + */ +export * as Sink from "./Sink.ts" + +/** + * @since 2.0.0 + */ +export * as Stream from "./Stream.ts" + /** * This module provides utility functions and type class instances for working with the `string` type in TypeScript. * It includes functions for basic string manipulation, as well as type class instances for @@ -1314,6 +1396,11 @@ export * as ServiceMap from "./ServiceMap.ts" */ export * as String from "./String.ts" +/** + * @since 2.0.0 + */ +export * as SubscriptionRef from "./SubscriptionRef.ts" + /** * @since 2.0.0 */ @@ -1324,6 +1411,11 @@ export * as Symbol from "./Symbol.ts" */ export * as SynchronizedRef from "./SynchronizedRef.ts" +/** + * @since 2.0.0 + */ +export * as Take from "./Take.ts" + /** * @since 2.0.0 */ diff --git a/packages/effect/src/internal/schedule.ts b/packages/effect/src/internal/schedule.ts index 459cf6e01b..f965a907a7 100644 --- a/packages/effect/src/internal/schedule.ts +++ b/packages/effect/src/internal/schedule.ts @@ -1,8 +1,8 @@ import * as Option from "../data/Option.ts" import type { Effect, Repeat, Retry } from "../Effect.ts" import { constant, constTrue, dual } from "../Function.ts" +import * as Pull from "../Pull.ts" import * as Schedule from "../Schedule.ts" -import * as Pull from "../stream/Pull.ts" import type { NoInfer } from "../types/Types.ts" import { internalCall } from "../Utils.ts" import * as effect from "./effect.ts" diff --git a/packages/effect/src/platform/FileSystem.ts b/packages/effect/src/platform/FileSystem.ts index 71c2755c22..11f8cbbee4 100644 --- a/packages/effect/src/platform/FileSystem.ts +++ b/packages/effect/src/platform/FileSystem.ts @@ -43,11 +43,11 @@ import * as UndefinedOr from "../data/UndefinedOr.ts" import * as Effect from "../Effect.ts" import { pipe } from "../Function.ts" import * as Layer from "../Layer.ts" +import * as Pull from "../Pull.ts" import type { Scope } from "../Scope.ts" import * as ServiceMap from "../ServiceMap.ts" -import * as Pull from "../stream/Pull.ts" -import * as Sink from "../stream/Sink.ts" -import * as Stream from "../stream/Stream.ts" +import * as Sink from "../Sink.ts" +import * as Stream from "../Stream.ts" import type { PlatformError } from "./PlatformError.ts" import { BadArgument, SystemError } from "./PlatformError.ts" @@ -1238,7 +1238,7 @@ export declare namespace WatchEvent { * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { FileSystem } from "effect/platform" * * // Custom watch backend implementation diff --git a/packages/effect/src/stream/index.ts b/packages/effect/src/stream/index.ts deleted file mode 100644 index b466c4fc09..0000000000 --- a/packages/effect/src/stream/index.ts +++ /dev/null @@ -1,95 +0,0 @@ -/** - * @since 4.0.0 - */ - -/** - * The `Channel` module provides a powerful abstraction for bi-directional communication - * and streaming operations. A `Channel` is a nexus of I/O operations that supports both - * reading and writing, forming the foundation for Effect's Stream and Sink abstractions. - * - * ## What is a Channel? - * - * A `Channel` represents: - * - **OutElem**: The type of elements the channel outputs - * - **OutErr**: The type of errors the channel can produce - * - **OutDone**: The type of the final value when the channel completes - * - **InElem**: The type of elements the channel reads - * - **InErr**: The type of errors the channel can receive - * - **InDone**: The type of the final value from upstream - * - **Env**: The environment/context required by the channel - * - * ## Key Features - * - * - **Bi-directional**: Channels can both read and write - * - **Composable**: Channels can be piped, sequenced, and concatenated - * - **Resource-safe**: Automatic cleanup and resource management - * - **Error-handling**: Built-in error propagation and handling - * - **Concurrent**: Support for concurrent operations - * - * ## Composition Patterns - * - * 1. **Piping**: Connect channels where output of one becomes input of another - * 2. **Sequencing**: Use the result of one channel to create another - * 3. **Concatenating**: Combine multiple channels into a single channel - * - * @example - * ```ts - * import { Channel } from "effect/stream" - * import { Effect } from "effect" - * - * // Simple channel that outputs numbers - * const numberChannel = Channel.succeed(42) - * - * // Transform channel that doubles values - * const doubleChannel = Channel.map(numberChannel, (n) => n * 2) - * - * // Running the channel would output: 84 - * ``` - * - * @example - * ```ts - * import { Channel } from "effect/stream" - * import { Effect } from "effect" - * - * // Channel from an array of values - * const arrayChannel = Channel.fromArray([1, 2, 3, 4, 5]) - * - * // Transform the channel by mapping over values - * const transformedChannel = Channel.map(arrayChannel, (n) => n * 2) - * - * // This channel will output: 2, 4, 6, 8, 10 - * ``` - * - * @since 2.0.0 - */ -export * as Channel from "./Channel.ts" - -/** - * @since 4.0.0 - */ -export * as ChannelSchema from "./ChannelSchema.ts" - -/** - * @since 4.0.0 - */ -export * as Pull from "./Pull.ts" - -/** - * @since 2.0.0 - */ -export * as Sink from "./Sink.ts" - -/** - * @since 2.0.0 - */ -export * as Stream from "./Stream.ts" - -/** - * @since 2.0.0 - */ -export * as SubscriptionRef from "./SubscriptionRef.ts" - -/** - * @since 2.0.0 - */ -export * as Take from "./Take.ts" diff --git a/packages/effect/src/stream/index.ts.tpl b/packages/effect/src/stream/index.ts.tpl deleted file mode 100644 index c2aac82f76..0000000000 --- a/packages/effect/src/stream/index.ts.tpl +++ /dev/null @@ -1,3 +0,0 @@ -/** - * @since 4.0.0 - */ diff --git a/packages/effect/src/unstable/ai/Chat.ts b/packages/effect/src/unstable/ai/Chat.ts index c9b1d02929..c9dc09d575 100644 --- a/packages/effect/src/unstable/ai/Chat.ts +++ b/packages/effect/src/unstable/ai/Chat.ts @@ -30,7 +30,7 @@ * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Chat, LanguageModel } from "effect/unstable/ai" * * // Streaming chat with tool support @@ -47,6 +47,7 @@ * * @since 4.0.0 */ +import * as Channel from "../../Channel.ts" import * as Option from "../../data/Option.ts" import * as Predicate from "../../data/Predicate.ts" import * as Duration from "../../Duration.ts" @@ -55,8 +56,7 @@ import * as Layer from "../../Layer.ts" import * as Ref from "../../Ref.ts" import * as Schema from "../../schema/Schema.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Channel from "../../stream/Channel.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import type { NoExcessProperties } from "../../types/Types.ts" import type { PersistenceError } from "../persistence/Persistence.ts" import { BackingPersistence } from "../persistence/Persistence.ts" @@ -220,7 +220,7 @@ export interface Service { * @example * ```ts * import { Console, Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Chat } from "effect/unstable/ai" * * const streamingChat = Effect.gen(function* () { diff --git a/packages/effect/src/unstable/ai/LanguageModel.ts b/packages/effect/src/unstable/ai/LanguageModel.ts index e79c8e6bed..3addd3aa25 100644 --- a/packages/effect/src/unstable/ai/LanguageModel.ts +++ b/packages/effect/src/unstable/ai/LanguageModel.ts @@ -56,7 +56,7 @@ import * as Queue from "../../Queue.ts" import * as SchemaAnnotations from "../../schema/Annotations.ts" import * as Schema from "../../schema/Schema.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import type { Span } from "../../Tracer.ts" import type { Concurrency, Mutable, NoExcessProperties } from "../../types/Types.ts" import * as AiError from "./AiError.ts" @@ -982,7 +982,7 @@ export const generateObject = < * @example * ```ts * import { Console, Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { LanguageModel } from "effect/unstable/ai" * * const program = LanguageModel.streamText({ diff --git a/packages/effect/src/unstable/ai/McpServer.ts b/packages/effect/src/unstable/ai/McpServer.ts index 82565ffeb9..1de312ea2c 100644 --- a/packages/effect/src/unstable/ai/McpServer.ts +++ b/packages/effect/src/unstable/ai/McpServer.ts @@ -13,8 +13,8 @@ import * as SchemaAnnotations from "../../schema/Annotations.ts" import * as AST from "../../schema/AST.ts" import * as Schema from "../../schema/Schema.ts" import * as ServiceMap from "../../ServiceMap.ts" -import type { Sink } from "../../stream/Sink.ts" -import type { Stream } from "../../stream/Stream.ts" +import type { Sink } from "../../Sink.ts" +import type { Stream } from "../../Stream.ts" import type * as Types from "../../types/Types.ts" import * as FindMyWay from "../http/FindMyWay.ts" import * as Headers from "../http/Headers.ts" diff --git a/packages/effect/src/unstable/ai/index.ts b/packages/effect/src/unstable/ai/index.ts index f07aa19e4a..0c6ecd1152 100644 --- a/packages/effect/src/unstable/ai/index.ts +++ b/packages/effect/src/unstable/ai/index.ts @@ -107,7 +107,7 @@ export * as AiError from "./AiError.ts" * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { Chat, LanguageModel } from "effect/unstable/ai" * * // Streaming chat with tool support diff --git a/packages/effect/src/unstable/cli/index.ts b/packages/effect/src/unstable/cli/index.ts index f663248241..a8010bb738 100644 --- a/packages/effect/src/unstable/cli/index.ts +++ b/packages/effect/src/unstable/cli/index.ts @@ -12,6 +12,11 @@ export * as Argument from "./Argument.ts" */ export * as CliError from "./CliError.ts" +/** + * @since 4.0.0 + */ +export * as CliOutput from "./CliOutput.ts" + /** * @since 4.0.0 */ @@ -28,11 +33,30 @@ export * as Flag from "./Flag.ts" export * as HelpDoc from "./HelpDoc.ts" /** + * @internal + * + * Param is the polymorphic implementation shared by Argument.ts and Flag.ts. + * The `Kind` type parameter ("argument" | "flag") enables type-safe separation + * while sharing parsing logic and combinators. + * + * Users should import from `Argument` and `Flag` modules, not this module directly. + * This module is not exported from the public API. + * * @since 4.0.0 */ -export * as CliOutput from "./CliOutput.ts" +export * as Param from "./Param.ts" /** + * Primitive types for CLI parameter parsing. + * + * Primitives handle the low-level parsing of string input into typed values. + * Most users should use the higher-level `Argument` and `Flag` modules instead. + * + * This module is primarily useful for: + * - Creating custom primitive types + * - Understanding how CLI parsing works internally + * - Advanced customization of parsing behavior + * * @since 4.0.0 */ export * as Primitive from "./Primitive.ts" diff --git a/packages/effect/src/unstable/cluster/Entity.ts b/packages/effect/src/unstable/cluster/Entity.ts index 1862d9aa8a..a5123e0f0e 100644 --- a/packages/effect/src/unstable/cluster/Entity.ts +++ b/packages/effect/src/unstable/cluster/Entity.ts @@ -17,7 +17,7 @@ import * as Queue from "../../Queue.ts" import type * as Schedule from "../../Schedule.ts" import { Scope } from "../../Scope.ts" import * as ServiceMap from "../../ServiceMap.ts" -import type * as Stream from "../../stream/Stream.ts" +import type * as Stream from "../../Stream.ts" import * as Headers from "../http/Headers.ts" import * as Rpc from "../rpc/Rpc.ts" import * as RpcClient from "../rpc/RpcClient.ts" diff --git a/packages/effect/src/unstable/cluster/Sharding.ts b/packages/effect/src/unstable/cluster/Sharding.ts index 2e338677dd..8150a7b840 100644 --- a/packages/effect/src/unstable/cluster/Sharding.ts +++ b/packages/effect/src/unstable/cluster/Sharding.ts @@ -24,7 +24,7 @@ import { CurrentLogAnnotations } from "../../References.ts" import * as Schedule from "../../Schedule.ts" import * as Scope from "../../Scope.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import type * as Rpc from "../rpc/Rpc.ts" import * as RpcClient from "../rpc/RpcClient.ts" import { type FromServer, RequestId } from "../rpc/RpcMessage.ts" diff --git a/packages/effect/src/unstable/encoding/Msgpack.ts b/packages/effect/src/unstable/encoding/Msgpack.ts index 84923f96ce..2f58d37998 100644 --- a/packages/effect/src/unstable/encoding/Msgpack.ts +++ b/packages/effect/src/unstable/encoding/Msgpack.ts @@ -3,18 +3,18 @@ */ import { Packr, Unpackr } from "msgpackr" import * as Msgpackr from "msgpackr" +import * as Channel from "../../Channel.ts" +import * as ChannelSchema from "../../ChannelSchema.ts" import * as Arr from "../../collections/Array.ts" import * as Data from "../../data/Data.ts" import * as Option from "../../data/Option.ts" import * as Predicate from "../../data/Predicate.ts" import * as Effect from "../../Effect.ts" import { dual } from "../../Function.ts" +import type * as Pull from "../../Pull.ts" import * as Issue from "../../schema/Issue.ts" import * as Schema from "../../schema/Schema.ts" import * as Transformation from "../../schema/Transformation.ts" -import * as Channel from "../../stream/Channel.ts" -import * as ChannelSchema from "../../stream/ChannelSchema.ts" -import type * as Pull from "../../stream/Pull.ts" const MsgPackErrorTypeId = "~effect/encoding/MsgPack/MsgPackError" diff --git a/packages/effect/src/unstable/encoding/Ndjson.ts b/packages/effect/src/unstable/encoding/Ndjson.ts index f8888bc749..38e5d76e0d 100644 --- a/packages/effect/src/unstable/encoding/Ndjson.ts +++ b/packages/effect/src/unstable/encoding/Ndjson.ts @@ -1,14 +1,14 @@ /** * @since 4.0.0 */ +import * as Channel from "../../Channel.ts" +import * as ChannelSchema from "../../ChannelSchema.ts" import * as Arr from "../../collections/Array.ts" import * as Data from "../../data/Data.ts" import * as Filter from "../../data/Filter.ts" import * as Effect from "../../Effect.ts" import { dual, identity } from "../../Function.ts" import type * as Schema from "../../schema/Schema.ts" -import * as Channel from "../../stream/Channel.ts" -import * as ChannelSchema from "../../stream/ChannelSchema.ts" const NdjsonErrorTypeId = "~effect/encoding/Ndjson/NdjsonError" diff --git a/packages/effect/src/unstable/encoding/Sse.ts b/packages/effect/src/unstable/encoding/Sse.ts index 94ae4ee406..5754226bf8 100644 --- a/packages/effect/src/unstable/encoding/Sse.ts +++ b/packages/effect/src/unstable/encoding/Sse.ts @@ -1,6 +1,8 @@ /** * @since 4.0.0 */ +import * as Channel from "../../Channel.ts" +import * as ChannelSchema from "../../ChannelSchema.ts" import type { NonEmptyReadonlyArray } from "../../collections/Array.ts" import * as Arr from "../../collections/Array.ts" import * as Data from "../../data/Data.ts" @@ -8,11 +10,9 @@ import * as Filter from "../../data/Filter.ts" import { hasProperty } from "../../data/Predicate.ts" import * as Duration from "../../Duration.ts" import * as Effect from "../../Effect.ts" +import * as Pull from "../../Pull.ts" import * as Schema from "../../schema/Schema.ts" import * as Transformation from "../../schema/Transformation.ts" -import * as Channel from "../../stream/Channel.ts" -import * as ChannelSchema from "../../stream/ChannelSchema.ts" -import * as Pull from "../../stream/Pull.ts" /** * @since 4.0.0 diff --git a/packages/effect/src/unstable/http/FetchHttpClient.ts b/packages/effect/src/unstable/http/FetchHttpClient.ts index 3ea73f0a36..5eb3a1f4d3 100644 --- a/packages/effect/src/unstable/http/FetchHttpClient.ts +++ b/packages/effect/src/unstable/http/FetchHttpClient.ts @@ -4,7 +4,7 @@ import * as Effect from "../../Effect.ts" import type * as Layer from "../../Layer.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import * as Headers from "./Headers.ts" import * as HttpClient from "./HttpClient.ts" import { RequestError } from "./HttpClientError.ts" diff --git a/packages/effect/src/unstable/http/HttpBody.ts b/packages/effect/src/unstable/http/HttpBody.ts index dfe6c2760f..8015b6a09e 100644 --- a/packages/effect/src/unstable/http/HttpBody.ts +++ b/packages/effect/src/unstable/http/HttpBody.ts @@ -12,7 +12,7 @@ import type { ParseOptions } from "../../schema/AST.ts" import type { Issue } from "../../schema/Issue.ts" import * as Parser from "../../schema/Parser.ts" import * as Schema from "../../schema/Schema.ts" -import type * as Stream_ from "../../stream/Stream.ts" +import type * as Stream_ from "../../Stream.ts" import * as UrlParams from "./UrlParams.ts" const TypeId = "~effect/http/HttpBody" diff --git a/packages/effect/src/unstable/http/HttpClient.ts b/packages/effect/src/unstable/http/HttpClient.ts index 099d82eacd..8ea2f314e9 100644 --- a/packages/effect/src/unstable/http/HttpClient.ts +++ b/packages/effect/src/unstable/http/HttpClient.ts @@ -17,7 +17,7 @@ import * as Ref from "../../Ref.ts" import * as Schedule from "../../Schedule.ts" import type * as Scope from "../../Scope.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import * as Tracer from "../../Tracer.ts" import type { ExcludeTag, ExtractTag, NoExcessProperties, NoInfer, Tags } from "../../types/Types.ts" import * as Cookies from "./Cookies.ts" diff --git a/packages/effect/src/unstable/http/HttpClientRequest.ts b/packages/effect/src/unstable/http/HttpClientRequest.ts index 459c8fdfad..e08419d93c 100644 --- a/packages/effect/src/unstable/http/HttpClientRequest.ts +++ b/packages/effect/src/unstable/http/HttpClientRequest.ts @@ -13,7 +13,7 @@ import type * as FileSystem from "../../platform/FileSystem.ts" import type * as PlatformError from "../../platform/PlatformError.ts" import type { ParseOptions } from "../../schema/AST.ts" import type * as Schema from "../../schema/Schema.ts" -import type * as Stream from "../../stream/Stream.ts" +import type * as Stream from "../../Stream.ts" import * as Headers from "./Headers.ts" import * as HttpBody from "./HttpBody.ts" import type { HttpMethod } from "./HttpMethod.ts" diff --git a/packages/effect/src/unstable/http/HttpClientResponse.ts b/packages/effect/src/unstable/http/HttpClientResponse.ts index 83d2b2fa18..50362cfe26 100644 --- a/packages/effect/src/unstable/http/HttpClientResponse.ts +++ b/packages/effect/src/unstable/http/HttpClientResponse.ts @@ -6,7 +6,7 @@ import { dual } from "../../Function.ts" import * as Inspectable from "../../interfaces/Inspectable.ts" import type { ParseOptions } from "../../schema/AST.ts" import * as Schema from "../../schema/Schema.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import type { Unify } from "../../types/Unify.ts" import * as Cookies from "./Cookies.ts" import * as Headers from "./Headers.ts" diff --git a/packages/effect/src/unstable/http/HttpEffect.ts b/packages/effect/src/unstable/http/HttpEffect.ts index a40cf3806d..2002682961 100644 --- a/packages/effect/src/unstable/http/HttpEffect.ts +++ b/packages/effect/src/unstable/http/HttpEffect.ts @@ -11,7 +11,7 @@ import { effectIsExit } from "../../internal/effect.ts" import * as Layer from "../../Layer.ts" import * as Scope from "../../Scope.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import * as HttpBody from "./HttpBody.ts" import { type HttpMiddleware, tracer } from "./HttpMiddleware.ts" import { causeResponse, clientAbortFiberId, RequestError } from "./HttpServerError.ts" diff --git a/packages/effect/src/unstable/http/HttpIncomingMessage.ts b/packages/effect/src/unstable/http/HttpIncomingMessage.ts index f2880e0c7e..1235ab517a 100644 --- a/packages/effect/src/unstable/http/HttpIncomingMessage.ts +++ b/packages/effect/src/unstable/http/HttpIncomingMessage.ts @@ -9,7 +9,7 @@ import type * as FileSystem from "../../platform/FileSystem.ts" import type { ParseOptions } from "../../schema/AST.ts" import * as Schema from "../../schema/Schema.ts" import * as ServiceMap from "../../ServiceMap.ts" -import type * as Stream from "../../stream/Stream.ts" +import type * as Stream from "../../Stream.ts" import type * as Headers from "./Headers.ts" import * as UrlParams from "./UrlParams.ts" diff --git a/packages/effect/src/unstable/http/HttpPlatform.ts b/packages/effect/src/unstable/http/HttpPlatform.ts index 40fba3ff77..f826172de0 100644 --- a/packages/effect/src/unstable/http/HttpPlatform.ts +++ b/packages/effect/src/unstable/http/HttpPlatform.ts @@ -7,7 +7,7 @@ import * as Layer from "../../Layer.ts" import * as FileSystem from "../../platform/FileSystem.ts" import type { PlatformError } from "../../platform/PlatformError.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import * as Etag from "./Etag.ts" import * as Headers from "./Headers.ts" import type * as Body from "./HttpBody.ts" diff --git a/packages/effect/src/unstable/http/HttpServerRequest.ts b/packages/effect/src/unstable/http/HttpServerRequest.ts index 958d67c761..7f03e26323 100644 --- a/packages/effect/src/unstable/http/HttpServerRequest.ts +++ b/packages/effect/src/unstable/http/HttpServerRequest.ts @@ -1,6 +1,7 @@ /** * @since 4.0.0 */ +import * as Channel from "../../Channel.ts" import type * as Arr from "../../collections/Array.ts" import type { ReadonlyRecord } from "../../data/Record.ts" import * as Result from "../../data/Result.ts" @@ -12,8 +13,7 @@ import type { ParseOptions } from "../../schema/AST.ts" import * as Schema from "../../schema/Schema.ts" import type * as Scope from "../../Scope.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Channel from "../../stream/Channel.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import * as Socket from "../socket/Socket.ts" import * as Cookies from "./Cookies.ts" import * as Headers from "./Headers.ts" diff --git a/packages/effect/src/unstable/http/HttpServerResponse.ts b/packages/effect/src/unstable/http/HttpServerResponse.ts index b2bb28874b..56b06e08cc 100644 --- a/packages/effect/src/unstable/http/HttpServerResponse.ts +++ b/packages/effect/src/unstable/http/HttpServerResponse.ts @@ -13,7 +13,7 @@ import type { PlatformError } from "../../platform/PlatformError.ts" import type { ParseOptions } from "../../schema/AST.ts" import type * as Schema from "../../schema/Schema.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import type { Mutable } from "../../types/Types.ts" import * as Cookies from "./Cookies.ts" import * as Headers from "./Headers.ts" diff --git a/packages/effect/src/unstable/http/Multipart.ts b/packages/effect/src/unstable/http/Multipart.ts index 44c1b8939d..5e6d603f51 100644 --- a/packages/effect/src/unstable/http/Multipart.ts +++ b/packages/effect/src/unstable/http/Multipart.ts @@ -1,6 +1,7 @@ /** * @since 4.0.0 */ +import * as Channel from "../../Channel.ts" import * as Arr from "../../collections/Array.ts" import * as Option from "../../data/Option.ts" import * as Predicate from "../../data/Predicate.ts" @@ -11,14 +12,13 @@ import { constant, dual } from "../../Function.ts" import * as Inspectable from "../../interfaces/Inspectable.ts" import * as FileSystem from "../../platform/FileSystem.ts" import * as Path from "../../platform/Path.ts" +import * as Pull from "../../Pull.ts" import type { ParseOptions } from "../../schema/AST.ts" import * as Schema from "../../schema/Schema.ts" import * as Transformation from "../../schema/Transformation.ts" import type * as Scope from "../../Scope.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Channel from "../../stream/Channel.ts" -import * as Pull from "../../stream/Pull.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import * as IncomingMessage from "./HttpIncomingMessage.ts" import * as MP from "./Multipasta.ts" diff --git a/packages/effect/src/unstable/http/Template.ts b/packages/effect/src/unstable/http/Template.ts index db391b4451..8f6bfed882 100644 --- a/packages/effect/src/unstable/http/Template.ts +++ b/packages/effect/src/unstable/http/Template.ts @@ -4,7 +4,7 @@ import * as Option from "../../data/Option.ts" import * as Effect from "../../Effect.ts" import * as Exit from "../../Exit.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" /** * @category models diff --git a/packages/effect/src/unstable/httpapi/HttpApiBuilder.ts b/packages/effect/src/unstable/httpapi/HttpApiBuilder.ts index 0a4f377132..3aecf68ddf 100644 --- a/packages/effect/src/unstable/httpapi/HttpApiBuilder.ts +++ b/packages/effect/src/unstable/httpapi/HttpApiBuilder.ts @@ -22,7 +22,7 @@ import * as Schema from "../../schema/Schema.ts" import * as Transformation from "../../schema/Transformation.ts" import type * as Scope from "../../Scope.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import type { Covariant } from "../../types/Types.ts" import type * as Etag from "../http/Etag.ts" import * as HttpMethod from "../http/HttpMethod.ts" diff --git a/packages/effect/src/unstable/httpapi/HttpApiEndpoint.ts b/packages/effect/src/unstable/httpapi/HttpApiEndpoint.ts index 68b0576818..018f5a9e63 100644 --- a/packages/effect/src/unstable/httpapi/HttpApiEndpoint.ts +++ b/packages/effect/src/unstable/httpapi/HttpApiEndpoint.ts @@ -10,7 +10,7 @@ import type { Effect } from "../../Effect.ts" import { type Pipeable, pipeArguments } from "../../interfaces/Pipeable.ts" import * as Schema from "../../schema/Schema.ts" import * as ServiceMap from "../../ServiceMap.ts" -import type * as Stream from "../../stream/Stream.ts" +import type * as Stream from "../../Stream.ts" import type * as Types from "../../types/Types.ts" import type { HttpMethod } from "../http/HttpMethod.ts" import * as HttpRouter from "../http/HttpRouter.ts" diff --git a/packages/effect/src/unstable/process/ChildProcess.ts b/packages/effect/src/unstable/process/ChildProcess.ts index 5892cbb53b..a5403b6954 100644 --- a/packages/effect/src/unstable/process/ChildProcess.ts +++ b/packages/effect/src/unstable/process/ChildProcess.ts @@ -7,7 +7,7 @@ * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { ChildProcess } from "effect/unstable/process" * import { NodeServices } from "@effect/platform-node" * @@ -49,8 +49,8 @@ import type { Pipeable } from "../../interfaces/Pipeable.ts" import { PipeInspectableProto, YieldableProto } from "../../internal/core.ts" import type * as PlatformError from "../../platform/PlatformError.ts" import type * as Scope from "../../Scope.ts" -import type * as Sink from "../../stream/Sink.ts" -import type * as Stream from "../../stream/Stream.ts" +import type * as Sink from "../../Sink.ts" +import type * as Stream from "../../Stream.ts" import type { ChildProcessHandle } from "./ChildProcessSpawner.ts" import { ChildProcessSpawner } from "./ChildProcessSpawner.ts" @@ -741,7 +741,7 @@ export const pipeTo: { * @example * ```ts * import { Console, Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { ChildProcess } from "effect/unstable/process" * import { NodeServices } from "@effect/platform-node" * diff --git a/packages/effect/src/unstable/process/ChildProcessSpawner.ts b/packages/effect/src/unstable/process/ChildProcessSpawner.ts index c04d160c12..bd3f70c1e5 100644 --- a/packages/effect/src/unstable/process/ChildProcessSpawner.ts +++ b/packages/effect/src/unstable/process/ChildProcessSpawner.ts @@ -12,8 +12,8 @@ import * as Inspectable from "../../interfaces/Inspectable.ts" import type * as PlatformError from "../../platform/PlatformError.ts" import type * as Scope from "../../Scope.ts" import * as ServiceMap from "../../ServiceMap.ts" -import type * as Sink from "../../stream/Sink.ts" -import type * as Stream from "../../stream/Stream.ts" +import type * as Sink from "../../Sink.ts" +import type * as Stream from "../../Stream.ts" import type { Command, KillOptions } from "./ChildProcess.ts" /** diff --git a/packages/effect/src/unstable/process/index.ts b/packages/effect/src/unstable/process/index.ts index 8882149ac3..f118f79c7b 100644 --- a/packages/effect/src/unstable/process/index.ts +++ b/packages/effect/src/unstable/process/index.ts @@ -11,7 +11,7 @@ * @example * ```ts * import { Effect } from "effect" - * import { Stream } from "effect/stream" + * import { Stream } from "effect" * import { ChildProcess } from "effect/unstable/process" * import { NodeServices } from "@effect/platform-node" * diff --git a/packages/effect/src/unstable/reactivity/Reactivity.ts b/packages/effect/src/unstable/reactivity/Reactivity.ts index 2c6b2be0d1..38e275270f 100644 --- a/packages/effect/src/unstable/reactivity/Reactivity.ts +++ b/packages/effect/src/unstable/reactivity/Reactivity.ts @@ -11,7 +11,7 @@ import * as Layer from "../../Layer.ts" import * as Queue from "../../Queue.ts" import * as Scope from "../../Scope.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" /** * @since 4.0.0 diff --git a/packages/effect/src/unstable/rpc/Rpc.ts b/packages/effect/src/unstable/rpc/Rpc.ts index 834125afef..1f4d3bb898 100644 --- a/packages/effect/src/unstable/rpc/Rpc.ts +++ b/packages/effect/src/unstable/rpc/Rpc.ts @@ -10,7 +10,7 @@ import * as PrimaryKey from "../../interfaces/PrimaryKey.ts" import type * as Queue from "../../Queue.ts" import * as Schema from "../../schema/Schema.ts" import * as ServiceMap from "../../ServiceMap.ts" -import type { Stream } from "../../stream/Stream.ts" +import type { Stream } from "../../Stream.ts" import type { Headers } from "../http/Headers.ts" import type { RequestId } from "./RpcMessage.ts" import type * as RpcMiddleware from "./RpcMiddleware.ts" diff --git a/packages/effect/src/unstable/rpc/RpcClient.ts b/packages/effect/src/unstable/rpc/RpcClient.ts index f89ab4b3c8..b1adbd3823 100644 --- a/packages/effect/src/unstable/rpc/RpcClient.ts +++ b/packages/effect/src/unstable/rpc/RpcClient.ts @@ -18,7 +18,7 @@ import * as Schedule from "../../Schedule.ts" import * as Schema from "../../schema/Schema.ts" import * as Scope from "../../Scope.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import type { Span } from "../../Tracer.ts" import type { Mutable } from "../../types/Types.ts" import * as Headers from "../http/Headers.ts" diff --git a/packages/effect/src/unstable/rpc/RpcGroup.ts b/packages/effect/src/unstable/rpc/RpcGroup.ts index 1df5132155..5b972add58 100644 --- a/packages/effect/src/unstable/rpc/RpcGroup.ts +++ b/packages/effect/src/unstable/rpc/RpcGroup.ts @@ -9,7 +9,7 @@ import * as Layer from "../../Layer.ts" import type * as Queue from "../../Queue.ts" import type { Scope } from "../../Scope.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import type { Headers } from "../http/Headers.ts" import * as Rpc from "./Rpc.ts" import type { RequestId } from "./RpcMessage.ts" diff --git a/packages/effect/src/unstable/rpc/RpcSchema.ts b/packages/effect/src/unstable/rpc/RpcSchema.ts index 84092350ff..bfe4a42f6f 100644 --- a/packages/effect/src/unstable/rpc/RpcSchema.ts +++ b/packages/effect/src/unstable/rpc/RpcSchema.ts @@ -4,7 +4,7 @@ import * as Predicate from "../../data/Predicate.ts" import type * as AST from "../../schema/AST.ts" import * as Schema from "../../schema/Schema.ts" -import * as Stream_ from "../../stream/Stream.ts" +import * as Stream_ from "../../Stream.ts" const StreamSchemaTypeId = "~effect/rpc/RpcSchema/StreamSchema" diff --git a/packages/effect/src/unstable/rpc/RpcServer.ts b/packages/effect/src/unstable/rpc/RpcServer.ts index b6fe91c5a5..2c503433cc 100644 --- a/packages/effect/src/unstable/rpc/RpcServer.ts +++ b/packages/effect/src/unstable/rpc/RpcServer.ts @@ -12,14 +12,14 @@ import * as Exit from "../../Exit.ts" import * as Fiber from "../../Fiber.ts" import { constant, constTrue, constVoid, identity } from "../../Function.ts" import * as Layer from "../../Layer.ts" +import * as Pull from "../../Pull.ts" import * as Queue from "../../Queue.ts" import * as Schedule from "../../Schedule.ts" import * as Schema from "../../schema/Schema.ts" import * as Scope from "../../Scope.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Pull from "../../stream/Pull.ts" -import type * as Sink from "../../stream/Sink.ts" -import * as Stream from "../../stream/Stream.ts" +import type * as Sink from "../../Sink.ts" +import * as Stream from "../../Stream.ts" import * as Tracer from "../../Tracer.ts" import type * as Types from "../../types/Types.ts" import * as Headers from "../http/Headers.ts" diff --git a/packages/effect/src/unstable/socket/Socket.ts b/packages/effect/src/unstable/socket/Socket.ts index 21b6ea4a21..122c335ce0 100644 --- a/packages/effect/src/unstable/socket/Socket.ts +++ b/packages/effect/src/unstable/socket/Socket.ts @@ -1,6 +1,7 @@ /** * @since 4.0.0 */ +import * as Channel from "../../Channel.ts" import type { NonEmptyReadonlyArray } from "../../collections/Array.ts" import * as Data from "../../data/Data.ts" import * as Filter from "../../data/Filter.ts" @@ -12,11 +13,10 @@ import * as Exit from "../../Exit.ts" import * as FiberSet from "../../FiberSet.ts" import { constVoid, dual } from "../../Function.ts" import * as Layer from "../../Layer.ts" +import * as Pull from "../../Pull.ts" import * as Queue from "../../Queue.ts" import * as Scope from "../../Scope.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Channel from "../../stream/Channel.ts" -import * as Pull from "../../stream/Pull.ts" /** * @since 4.0.0 diff --git a/packages/effect/src/unstable/sql/SqlClient.ts b/packages/effect/src/unstable/sql/SqlClient.ts index 0f02e40cb4..73dfb3ee63 100644 --- a/packages/effect/src/unstable/sql/SqlClient.ts +++ b/packages/effect/src/unstable/sql/SqlClient.ts @@ -9,7 +9,7 @@ import * as Exit from "../../Exit.ts" import type * as Queue from "../../Queue.ts" import * as Scope from "../../Scope.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import * as Tracer from "../../Tracer.ts" import type { NoInfer } from "../../types/Types.ts" import { Reactivity } from "../reactivity/Reactivity.ts" diff --git a/packages/effect/src/unstable/sql/SqlConnection.ts b/packages/effect/src/unstable/sql/SqlConnection.ts index 8bda9eb9b9..e99fbd13a4 100644 --- a/packages/effect/src/unstable/sql/SqlConnection.ts +++ b/packages/effect/src/unstable/sql/SqlConnection.ts @@ -4,7 +4,7 @@ import type { Effect } from "../../Effect.ts" import type { Scope } from "../../Scope.ts" import * as ServiceMap from "../../ServiceMap.ts" -import type { Stream } from "../../stream/Stream.ts" +import type { Stream } from "../../Stream.ts" import type { SqlError } from "./SqlError.ts" /** diff --git a/packages/effect/src/unstable/sql/SqlStream.ts b/packages/effect/src/unstable/sql/SqlStream.ts index d45b9bc3b7..f4b4e831c2 100644 --- a/packages/effect/src/unstable/sql/SqlStream.ts +++ b/packages/effect/src/unstable/sql/SqlStream.ts @@ -5,7 +5,7 @@ import * as Effect from "../../Effect.ts" import * as Exit from "../../Exit.ts" import * as Queue from "../../Queue.ts" import type * as Scope from "../../Scope.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" /** * @since 4.0.0 diff --git a/packages/effect/src/unstable/sql/Statement.ts b/packages/effect/src/unstable/sql/Statement.ts index 4478ac6b58..988cc7dde5 100644 --- a/packages/effect/src/unstable/sql/Statement.ts +++ b/packages/effect/src/unstable/sql/Statement.ts @@ -11,7 +11,7 @@ import type { Pipeable } from "../../interfaces/Pipeable.ts" import * as core from "../../internal/core.ts" import * as internalEffect from "../../internal/effect.ts" import * as ServiceMap from "../../ServiceMap.ts" -import * as Stream from "../../stream/Stream.ts" +import * as Stream from "../../Stream.ts" import type * as Tracer from "../../Tracer.ts" import type { Acquirer, Connection, Row } from "./SqlConnection.ts" import type { SqlError } from "./SqlError.ts" diff --git a/packages/effect/test/ExecutionPlan.test.ts b/packages/effect/test/ExecutionPlan.test.ts index ce54d67b50..c48e1a4e82 100644 --- a/packages/effect/test/ExecutionPlan.test.ts +++ b/packages/effect/test/ExecutionPlan.test.ts @@ -1,8 +1,7 @@ import { describe, it } from "@effect/vitest" import { assertTrue, deepStrictEqual } from "@effect/vitest/utils" -import { Effect, ExecutionPlan, Exit, Layer, ServiceMap } from "effect" +import { Effect, ExecutionPlan, Exit, Layer, ServiceMap, Stream } from "effect" import { Array } from "effect/collections" -import { Stream } from "effect/stream" describe("ExecutionPlan", () => { class Service extends ServiceMap.Service()("Service", { diff --git a/packages/effect/test/HttpClient.test.ts b/packages/effect/test/HttpClient.test.ts index 9ddcd8c3d7..6c52483bef 100644 --- a/packages/effect/test/HttpClient.test.ts +++ b/packages/effect/test/HttpClient.test.ts @@ -1,8 +1,7 @@ import { expect, it } from "@effect/vitest" -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, ServiceMap, Stream } from "effect" import { Struct } from "effect/data" import { Schema } from "effect/schema" -import { Stream } from "effect/stream" import { TestClock } from "effect/testing" import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "effect/unstable/http" diff --git a/packages/effect/test/Queue.test.ts b/packages/effect/test/Queue.test.ts index e34ed9135e..8cfabc9416 100644 --- a/packages/effect/test/Queue.test.ts +++ b/packages/effect/test/Queue.test.ts @@ -1,6 +1,5 @@ import { assert, describe, it } from "@effect/vitest" -import { Effect, Exit, Fiber, Queue } from "effect" -import { Stream } from "effect/stream" +import { Effect, Exit, Fiber, Queue, Stream } from "effect" describe("Queue", () => { it.effect("offerAll with capacity", () => diff --git a/packages/effect/test/Schedule.test.ts b/packages/effect/test/Schedule.test.ts index 958a1708b7..ec949cd39c 100644 --- a/packages/effect/test/Schedule.test.ts +++ b/packages/effect/test/Schedule.test.ts @@ -1,8 +1,7 @@ import { describe, expect, it } from "@effect/vitest" -import { Duration, Effect, Fiber, Schedule } from "effect" +import { Duration, Effect, Fiber, Pull, Schedule } from "effect" import { Array } from "effect/collections" import { constant, constUndefined } from "effect/Function" -import { Pull } from "effect/stream" import { TestClock } from "effect/testing" describe("Schedule", () => { diff --git a/packages/effect/test/cluster/Sharding.test.ts b/packages/effect/test/cluster/Sharding.test.ts index 12a0557ec3..436684d39b 100644 --- a/packages/effect/test/cluster/Sharding.test.ts +++ b/packages/effect/test/cluster/Sharding.test.ts @@ -1,8 +1,7 @@ import { assert, describe, expect, it } from "@effect/vitest" -import { Cause, Clock, Effect, Exit, Fiber, Layer, MutableRef, Queue } from "effect" +import { Cause, Clock, Effect, Exit, Fiber, Layer, MutableRef, Queue, Stream } from "effect" import { Array } from "effect/collections" import { Option } from "effect/data" -import { Stream } from "effect/stream" import { TestClock } from "effect/testing" import { MessageStorage, diff --git a/packages/effect/test/cluster/TestEntity.ts b/packages/effect/test/cluster/TestEntity.ts index d7813b6fec..4664e21f02 100644 --- a/packages/effect/test/cluster/TestEntity.ts +++ b/packages/effect/test/cluster/TestEntity.ts @@ -1,6 +1,5 @@ -import { Effect, Layer, MutableRef, Queue, Schedule, ServiceMap } from "effect" +import { Effect, Layer, MutableRef, Queue, Schedule, ServiceMap, Stream } from "effect" import { Schema } from "effect/schema" -import { Stream } from "effect/stream" import type { Envelope } from "effect/unstable/cluster" import { ClusterSchema, Entity } from "effect/unstable/cluster" import type { RpcGroup } from "effect/unstable/rpc" diff --git a/packages/effect/test/http/HttpEffect.test.ts b/packages/effect/test/http/HttpEffect.test.ts index f2b7881b82..4c5d704dfa 100644 --- a/packages/effect/test/http/HttpEffect.test.ts +++ b/packages/effect/test/http/HttpEffect.test.ts @@ -1,8 +1,7 @@ import { describe, test } from "@effect/vitest" import { deepStrictEqual, strictEqual } from "@effect/vitest/utils" -import { Effect, References, ServiceMap } from "effect" +import { Effect, References, ServiceMap, Stream } from "effect" import * as Layer from "effect/Layer" -import { Stream } from "effect/stream" import { HttpEffect, HttpServerResponse } from "effect/unstable/http" describe("Http/App", () => { diff --git a/packages/effect/test/http/Multipart.test.ts b/packages/effect/test/http/Multipart.test.ts index 86d2f1a9cb..6d2f8c7be8 100644 --- a/packages/effect/test/http/Multipart.test.ts +++ b/packages/effect/test/http/Multipart.test.ts @@ -1,7 +1,6 @@ import { describe, it } from "@effect/vitest" import { deepStrictEqual } from "@effect/vitest/utils" -import { Effect, identity } from "effect" -import { Stream } from "effect/stream" +import { Effect, identity, Stream } from "effect" import { Unify } from "effect/types" import * as Multipart from "effect/unstable/http/Multipart" diff --git a/packages/effect/test/stream/Channel.test.ts b/packages/effect/test/stream/Channel.test.ts index 2b8b88cfd4..7cceaca554 100644 --- a/packages/effect/test/stream/Channel.test.ts +++ b/packages/effect/test/stream/Channel.test.ts @@ -1,12 +1,12 @@ import { assert, describe, it } from "@effect/vitest" import { assertFailure, assertTrue } from "@effect/vitest/utils" import { Deferred, pipe, Ref } from "effect" +import * as Channel from "effect/Channel" import * as Chunk from "effect/collections/Chunk" import * as Effect from "effect/Effect" import * as Exit from "effect/Exit" import * as Fiber from "effect/Fiber" import * as Queue from "effect/Queue" -import * as Channel from "effect/stream/Channel" describe("Channel", () => { describe("constructors", () => { diff --git a/packages/effect/test/stream/Sink.test.ts b/packages/effect/test/stream/Sink.test.ts index eaaefd81a7..0815e90459 100644 --- a/packages/effect/test/stream/Sink.test.ts +++ b/packages/effect/test/stream/Sink.test.ts @@ -1,9 +1,8 @@ import { describe, it } from "@effect/vitest" import { assertExitFailure, assertExitSuccess, deepStrictEqual, strictEqual } from "@effect/vitest/utils" -import { Cause, Effect, Ref } from "effect" +import { Cause, Effect, Ref, Sink, Stream } from "effect" import { Array } from "effect/collections" import { constTrue, pipe } from "effect/Function" -import { Sink, Stream } from "effect/stream" describe("Sink", () => { describe("reduceWhile", () => { diff --git a/packages/effect/test/stream/Stream.test.ts b/packages/effect/test/stream/Stream.test.ts index 1db327c483..755025c7f0 100644 --- a/packages/effect/test/stream/Stream.test.ts +++ b/packages/effect/test/stream/Stream.test.ts @@ -1,12 +1,11 @@ /* eslint-disable no-restricted-syntax */ import { assert, describe, it } from "@effect/vitest" import { assertExitFailure, assertSuccess, assertTrue, deepStrictEqual, strictEqual } from "@effect/vitest/utils" -import { Cause, Clock, Deferred, Duration, Effect, Exit, Fiber, Queue, Ref, Schedule } from "effect" +import { Cause, Clock, Deferred, Duration, Effect, Exit, Fiber, Queue, Ref, Schedule, Sink, Stream } from "effect" import { Array } from "effect/collections" import { isReadonlyArrayNonEmpty, type NonEmptyArray } from "effect/collections/Array" import { Filter, Option } from "effect/data" import { constFalse, constTrue, constVoid, pipe } from "effect/Function" -import { Sink, Stream } from "effect/stream" import { TestClock } from "effect/testing" import * as fc from "effect/testing/FastCheck" import { assertFailure } from "../utils/assert.ts" diff --git a/packages/effect/test/stream/SubscriptionRef.test.ts b/packages/effect/test/stream/SubscriptionRef.test.ts index 1bb8c13158..0dd494109e 100644 --- a/packages/effect/test/stream/SubscriptionRef.test.ts +++ b/packages/effect/test/stream/SubscriptionRef.test.ts @@ -1,7 +1,6 @@ import { assert, describe, it } from "@effect/vitest" -import { Effect, Exit, Fiber, Number, Random } from "effect" +import { Effect, Exit, Fiber, Number, Pull, Random, Stream, SubscriptionRef } from "effect" import { Array } from "effect/collections" -import { Pull, Stream, SubscriptionRef } from "effect/stream" describe("SubscriptionRef", () => { it.effect("multiple subscribers can receive changes", () => diff --git a/packages/effect/test/unstable/ai/LanguageModel.test.ts b/packages/effect/test/unstable/ai/LanguageModel.test.ts index 8a6180f27b..6a7ece2dd6 100644 --- a/packages/effect/test/unstable/ai/LanguageModel.test.ts +++ b/packages/effect/test/unstable/ai/LanguageModel.test.ts @@ -1,7 +1,6 @@ import { assert, describe, it } from "@effect/vitest" -import { Effect } from "effect" +import { Effect, Stream } from "effect" import { Schema } from "effect/schema" -import { Stream } from "effect/stream" import { TestClock } from "effect/testing" import { LanguageModel, Response, Tool, Toolkit } from "effect/unstable/ai" import * as TestUtils from "./utils.ts" diff --git a/packages/effect/test/unstable/ai/utils.ts b/packages/effect/test/unstable/ai/utils.ts index 1db8d96b99..80b9dd8613 100644 --- a/packages/effect/test/unstable/ai/utils.ts +++ b/packages/effect/test/unstable/ai/utils.ts @@ -1,7 +1,6 @@ -import { Effect } from "effect" +import { Effect, Stream } from "effect" import { Predicate } from "effect/data" import { dual } from "effect/Function" -import { Stream } from "effect/stream" import type { Response } from "effect/unstable/ai" import { LanguageModel } from "effect/unstable/ai" diff --git a/packages/effect/test/unstable/process/ChildProcess.test.ts b/packages/effect/test/unstable/process/ChildProcess.test.ts index 15bff3cf1a..6f9e3d185f 100644 --- a/packages/effect/test/unstable/process/ChildProcess.test.ts +++ b/packages/effect/test/unstable/process/ChildProcess.test.ts @@ -2,8 +2,8 @@ import { assert, describe, it } from "@effect/vitest" import * as Effect from "effect/Effect" import * as Layer from "effect/Layer" import type * as PlatformError from "effect/platform/PlatformError" -import * as Sink from "effect/stream/Sink" -import * as Stream from "effect/stream/Stream" +import * as Sink from "effect/Sink" +import * as Stream from "effect/Stream" import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process" const MockExecutorLayer = Layer.succeed(ChildProcessSpawner.ChildProcessSpawner, { diff --git a/packages/effect/test/utils/chunkCoordination.ts b/packages/effect/test/utils/chunkCoordination.ts index 189393c261..cd7f9590c0 100644 --- a/packages/effect/test/utils/chunkCoordination.ts +++ b/packages/effect/test/utils/chunkCoordination.ts @@ -1,7 +1,7 @@ import type * as Arr from "effect/collections/Array" import * as Effect from "effect/Effect" import * as Queue from "effect/Queue" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" export interface ChunkCoordination { readonly queue: Queue.Queue, Queue.Done> diff --git a/packages/platform-browser/src/BrowserHttpClient.ts b/packages/platform-browser/src/BrowserHttpClient.ts index d39c319b9d..4d13b6bbb1 100644 --- a/packages/platform-browser/src/BrowserHttpClient.ts +++ b/packages/platform-browser/src/BrowserHttpClient.ts @@ -8,7 +8,7 @@ import * as Inspectable from "effect/interfaces/Inspectable" import type * as Layer from "effect/Layer" import * as Queue from "effect/Queue" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Cookies from "effect/unstable/http/Cookies" import * as Headers from "effect/unstable/http/Headers" import * as HttpClient from "effect/unstable/http/HttpClient" diff --git a/packages/platform-browser/src/BrowserStream.ts b/packages/platform-browser/src/BrowserStream.ts index 2af86b624d..93398ecec2 100644 --- a/packages/platform-browser/src/BrowserStream.ts +++ b/packages/platform-browser/src/BrowserStream.ts @@ -2,7 +2,7 @@ * @since 1.0.0 */ -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" /** * Creates a `Stream` from `window.addEventListener`. diff --git a/packages/platform-browser/src/Geolocation.ts b/packages/platform-browser/src/Geolocation.ts index 41f059154a..bd88b403cc 100644 --- a/packages/platform-browser/src/Geolocation.ts +++ b/packages/platform-browser/src/Geolocation.ts @@ -7,7 +7,7 @@ import * as Exit from "effect/Exit" import * as Layer from "effect/Layer" import * as Queue from "effect/Queue" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" const TypeId = "~@effect/platform-browser/Geolocation" const ErrorTypeId = "~@effect/platform-browser/Geolocation/GeolocationError" diff --git a/packages/platform-browser/test/BrowserHttpClient.test.ts b/packages/platform-browser/test/BrowserHttpClient.test.ts index 555e3606f7..74fb349911 100644 --- a/packages/platform-browser/test/BrowserHttpClient.test.ts +++ b/packages/platform-browser/test/BrowserHttpClient.test.ts @@ -2,7 +2,7 @@ import * as BrowserHttpClient from "@effect/platform-browser/BrowserHttpClient" import { assert, describe, it } from "@effect/vitest" import * as Effect from "effect/Effect" import * as Layer from "effect/Layer" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Cookies from "effect/unstable/http/Cookies" import * as HttpClient from "effect/unstable/http/HttpClient" import * as MXHR from "mock-xmlhttprequest" diff --git a/packages/platform-browser/test/fixtures/rpc-e2e.ts b/packages/platform-browser/test/fixtures/rpc-e2e.ts deleted file mode 120000 index 6e09e756d1..0000000000 --- a/packages/platform-browser/test/fixtures/rpc-e2e.ts +++ /dev/null @@ -1 +0,0 @@ -../../../platform-node/test/fixtures/rpc-e2e.ts \ No newline at end of file diff --git a/packages/platform-browser/test/fixtures/rpc-e2e.ts b/packages/platform-browser/test/fixtures/rpc-e2e.ts new file mode 100644 index 0000000000..fe506e26f7 --- /dev/null +++ b/packages/platform-browser/test/fixtures/rpc-e2e.ts @@ -0,0 +1,142 @@ +import { assert, describe, it } from "@effect/vitest" +import { Cause, Effect, Fiber, ServiceMap, Stream } from "effect" +import { Option } from "effect/data" +// @ts-ignore +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { NodeInspectSymbol } from "effect/interfaces/Inspectable" +import * as Layer from "effect/Layer" +import * as RpcClient from "effect/unstable/rpc/RpcClient" +import type { RpcClientError } from "effect/unstable/rpc/RpcClientError" +import type * as RpcGroup from "effect/unstable/rpc/RpcGroup" +import * as RpcServer from "effect/unstable/rpc/RpcServer" +import * as RpcTest from "effect/unstable/rpc/RpcTest" +import { AuthClient, AuthLive, TimingLive, User, UserRpcs, UsersLive } from "./rpc-schemas.ts" + +export class UsersClient extends ServiceMap.Service< + UsersClient, + RpcClient.RpcClient, RpcClientError> +>()("UsersClient") { + static layer = Layer.effect(UsersClient)(RpcClient.make(UserRpcs)).pipe( + Layer.provide(AuthClient) + ) + static layerTest = Layer.effect(UsersClient)(RpcTest.makeClient(UserRpcs)).pipe( + Layer.provide([UsersLive, AuthLive, TimingLive, AuthClient]) + ) +} + +export const e2eSuite = ( + name: string, + layer: Layer.Layer, + concurrent = true +) => { + describe(name, { concurrent, timeout: 30_000 }, () => { + it.effect("should get user", () => + Effect.gen(function*() { + const client = yield* UsersClient + const user = yield* client.GetUser({ id: "1" }) + assert.instanceOf(user, User) + assert.deepStrictEqual(user, new User({ id: "1", name: "Logged in user" })) + }).pipe(Effect.provide(layer))) + + it.effect("nested method", () => + Effect.gen(function*() { + const client = yield* UsersClient + yield* client.nested.test() + }).pipe(Effect.provide(layer))) + + it.effect("should not flatten Option", () => + Effect.gen(function*() { + const client = yield* UsersClient + const user = yield* client.GetUserOption({ id: "1" }) + assert.deepStrictEqual(user, Option.some(new User({ id: "1", name: "John" }))) + }).pipe(Effect.provide(layer))) + + it.effect("headers", () => + Effect.gen(function*() { + const client = yield* UsersClient + const user = yield* client.GetUser({ id: "1" }) + assert.instanceOf(user, User) + assert.deepStrictEqual(user, new User({ id: "123", name: "Logged in user" })) + }).pipe( + RpcClient.withHeaders({ userId: "123" }), + Effect.provide(layer) + )) + + it.live("Stream", () => + Effect.gen(function*() { + const client = yield* UsersClient + const users: Array = [] + yield* client.StreamUsers({ id: "1" }).pipe( + Stream.take(5), + Stream.runForEach((user) => + Effect.sync(() => { + users.push(user) + }) + ), + Effect.forkChild + ) + + yield* Effect.sleep(2000) + assert.lengthOf(users, 5) + + // test interrupts + const interrupts = yield* client.GetInterrupts() + assert.equal(interrupts, 1) + + const { supportsAck } = yield* RpcServer.Protocol + + // test backpressure + if (supportsAck) { + const emits = yield* client.GetEmits() + assert.equal(emits, 5) + } + }).pipe(Effect.provide(layer)), { timeout: 20000 }) + + it.effect("defect", () => + Effect.gen(function*() { + const client = yield* UsersClient + const cause = yield* client.ProduceDefect().pipe( + Effect.sandbox, + Effect.flip + ) + assert.deepStrictEqual(cause, Cause.die("boom")) + }).pipe( + RpcClient.withHeaders({ userId: "123" }), + Effect.provide(layer) + )) + + it.live("never", () => + Effect.gen(function*() { + const client = yield* UsersClient + const fiber = yield* client.Never().pipe( + Effect.forkChild + ) + yield* Effect.sleep(500) + assert.isUndefined(fiber.pollUnsafe()) + + yield* Fiber.interrupt(fiber) + yield* Effect.sleep(100) + + const { supportsAck } = yield* RpcServer.Protocol + if (supportsAck) { + const interrupts = yield* client.GetInterrupts() + assert.equal(interrupts, 1) + } + }).pipe( + RpcClient.withHeaders({ userId: "123" }), + Effect.provide(layer) + )) + + it.effect("timing middleware", () => + Effect.gen(function*() { + const client = yield* UsersClient + const result = yield* client.TimedMethod({ shouldFail: false }) + assert.equal(result, 1) + yield* client.TimedMethod({ shouldFail: true }).pipe(Effect.exit) + const { count, defect, success } = yield* client.GetTimingMiddlewareMetrics() + assert.notEqual(count, 0) + assert.notEqual(defect, 0) + assert.notEqual(success, 0) + }).pipe(Effect.provide(layer))) + }) +} diff --git a/packages/platform-browser/test/fixtures/rpc-schemas.ts b/packages/platform-browser/test/fixtures/rpc-schemas.ts deleted file mode 120000 index ff01864630..0000000000 --- a/packages/platform-browser/test/fixtures/rpc-schemas.ts +++ /dev/null @@ -1 +0,0 @@ -../../../platform-node/test/fixtures/rpc-schemas.ts \ No newline at end of file diff --git a/packages/platform-browser/test/fixtures/rpc-schemas.ts b/packages/platform-browser/test/fixtures/rpc-schemas.ts new file mode 100644 index 0000000000..b4cd3beede --- /dev/null +++ b/packages/platform-browser/test/fixtures/rpc-schemas.ts @@ -0,0 +1,157 @@ +import { Effect, Layer, Metric, Queue, ServiceMap } from "effect" +import { Option } from "effect/data" +import { Schema } from "effect/schema" +import { Headers } from "effect/unstable/http" +import * as Rpc from "effect/unstable/rpc/Rpc" +import * as RpcGroup from "effect/unstable/rpc/RpcGroup" +import * as RpcMiddleware from "effect/unstable/rpc/RpcMiddleware" +import * as RpcServer from "effect/unstable/rpc/RpcServer" + +export class User extends Schema.Class("User")({ + id: Schema.String, + name: Schema.String +}) {} + +class StreamUsers extends Rpc.make("StreamUsers", { + success: User, + payload: { + id: Schema.String + }, + stream: true +}) {} + +class CurrentUser extends ServiceMap.Service()("CurrentUser") {} + +class Unauthorized extends Schema.ErrorClass("Unauthorized")({ + _tag: Schema.tag("Unauthorized") +}) {} + +class AuthMiddleware extends RpcMiddleware.Service()("AuthMiddleware", { + error: Unauthorized, + requiredForClient: true +}) {} + +class TimingMiddleware extends RpcMiddleware.Service()("TimingMiddleware") {} + +class GetUser extends Rpc.make("GetUser", { + success: User, + payload: { id: Schema.String } +}) {} + +export const UserRpcs = RpcGroup.make( + GetUser, + Rpc.make("GetUserOption", { + success: Schema.Option(User), + payload: { id: Schema.String } + }), + StreamUsers, + Rpc.make("GetInterrupts", { + success: Schema.Number + }), + Rpc.make("GetEmits", { + success: Schema.Number + }), + Rpc.make("ProduceDefect"), + Rpc.make("Never"), + Rpc.make("nested.test"), + Rpc.make("TimedMethod", { + payload: { + shouldFail: Schema.Boolean + }, + success: Schema.Number + }).middleware(TimingMiddleware), + Rpc.make("GetTimingMiddlewareMetrics", { + success: Schema.Struct({ + success: Schema.Number, + defect: Schema.Number, + count: Schema.Number + }) + }) +).middleware(AuthMiddleware) + +export const AuthLive = Layer.succeed(AuthMiddleware)( + AuthMiddleware.of((effect, options) => + Effect.provideService( + effect, + CurrentUser, + new User({ id: options.headers.userid ?? "1", name: options.headers.name ?? "Fallback name" }) + ) + ) +) + +const rpcSuccesses = Metric.counter("rpc_middleware_success") +const rpcDefects = Metric.counter("rpc_middleware_defects") +const rpcCount = Metric.counter("rpc_middleware_count") +export const TimingLive = Layer.succeed(TimingMiddleware)( + TimingMiddleware.of((effect) => + effect.pipe( + Effect.tap(Metric.update(rpcSuccesses, 1)), + Effect.tapDefect(() => Metric.update(rpcDefects, 1)), + Effect.ensuring(Metric.update(rpcCount, 1)) + ) + ) +) + +export const UsersLive = UserRpcs.toLayer(Effect.gen(function*() { + let interrupts = 0 + let emits = 0 + return UserRpcs.of({ + GetUser: (_) => + CurrentUser.asEffect().pipe( + Rpc.fork + ), + GetUserOption: Effect.fnUntraced(function*(req) { + return Option.some(new User({ id: req.id, name: "John" })) + }), + StreamUsers: Effect.fnUntraced(function*(req, _) { + const mailbox = yield* Queue.bounded(0) + + yield* Effect.addFinalizer(() => + Effect.sync(() => { + interrupts++ + }) + ) + + yield* Queue.offer(mailbox, new User({ id: req.id, name: "John" })).pipe( + Effect.tap(() => { + emits++ + }), + Effect.delay(100), + Effect.forever, + Effect.forkScoped + ) + + return mailbox + }), + GetInterrupts: () => Effect.sync(() => interrupts), + GetEmits: () => Effect.sync(() => emits), + ProduceDefect: () => Effect.die("boom"), + Never: () => Effect.never.pipe(Effect.onInterrupt(() => Effect.sync(() => interrupts++))), + "nested.test": () => Effect.void, + TimedMethod: (_) => _.shouldFail ? Effect.die("boom") : Effect.succeed(1), + GetTimingMiddlewareMetrics: () => + Effect.all({ + defect: Metric.value(rpcDefects).pipe(Effect.map((_) => _.count)), + success: Metric.value(rpcSuccesses).pipe(Effect.map((_) => _.count)), + count: Metric.value(rpcCount).pipe(Effect.map((_) => _.count)) + }) + }) +})) + +export const RpcLive = RpcServer.layer(UserRpcs, { + disableFatalDefects: true +}).pipe( + Layer.provide([ + UsersLive, + AuthLive, + TimingLive + ]) +) + +export const AuthClient = RpcMiddleware.layerClient(AuthMiddleware, ({ next, request }) => + next({ + ...request, + headers: Headers.set(request.headers, "name", "Logged in user") + })) diff --git a/packages/platform-bun/src/BunHttpServer.ts b/packages/platform-bun/src/BunHttpServer.ts index fff804b4f2..67b9b08036 100644 --- a/packages/platform-bun/src/BunHttpServer.ts +++ b/packages/platform-bun/src/BunHttpServer.ts @@ -16,7 +16,7 @@ import type * as FileSystem from "effect/platform/FileSystem" import type * as Path from "effect/platform/Path" import type * as Scope from "effect/Scope" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Cookies from "effect/unstable/http/Cookies" import * as Etag from "effect/unstable/http/Etag" import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient" diff --git a/packages/platform-bun/src/BunMultipart.ts b/packages/platform-bun/src/BunMultipart.ts index 0a8ebd1cc3..e13e9e5ea9 100644 --- a/packages/platform-bun/src/BunMultipart.ts +++ b/packages/platform-bun/src/BunMultipart.ts @@ -5,7 +5,7 @@ import type * as Effect from "effect/Effect" import type { FileSystem } from "effect/platform/FileSystem" import type { Path } from "effect/platform/Path" import type * as Scope from "effect/Scope" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Multipart from "effect/unstable/http/Multipart" import * as BunStream from "./BunStream.ts" diff --git a/packages/platform-bun/src/BunStream.ts b/packages/platform-bun/src/BunStream.ts index dd4ed4333b..f8d9ef2b96 100644 --- a/packages/platform-bun/src/BunStream.ts +++ b/packages/platform-bun/src/BunStream.ts @@ -1,13 +1,13 @@ /** * @since 1.0.0 */ +import * as Channel from "effect/Channel" import * as Arr from "effect/collections/Array" import * as Effect from "effect/Effect" import type { LazyArg } from "effect/Function" +import * as Pull from "effect/Pull" import * as Scope from "effect/Scope" -import * as Channel from "effect/stream/Channel" -import * as Pull from "effect/stream/Pull" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" /** * @since 1.0.0 diff --git a/packages/platform-node-shared/src/NodeChildProcessSpawner.ts b/packages/platform-node-shared/src/NodeChildProcessSpawner.ts index e97a962597..2bd987f451 100644 --- a/packages/platform-node-shared/src/NodeChildProcessSpawner.ts +++ b/packages/platform-node-shared/src/NodeChildProcessSpawner.ts @@ -14,8 +14,8 @@ import * as FileSystem from "effect/platform/FileSystem" import * as Path from "effect/platform/Path" import type * as PlatformError from "effect/platform/PlatformError" import type * as Scope from "effect/Scope" -import * as Sink from "effect/stream/Sink" -import * as Stream from "effect/stream/Stream" +import * as Sink from "effect/Sink" +import * as Stream from "effect/Stream" import * as ChildProcess from "effect/unstable/process/ChildProcess" import type { ChildProcessHandle } from "effect/unstable/process/ChildProcessSpawner" import { ChildProcessSpawner, ExitCode, makeHandle, ProcessId } from "effect/unstable/process/ChildProcessSpawner" diff --git a/packages/platform-node-shared/src/NodeFileSystem.ts b/packages/platform-node-shared/src/NodeFileSystem.ts index 950ab3c404..9084b0a616 100644 --- a/packages/platform-node-shared/src/NodeFileSystem.ts +++ b/packages/platform-node-shared/src/NodeFileSystem.ts @@ -10,7 +10,7 @@ import * as Layer from "effect/Layer" import * as FileSystem from "effect/platform/FileSystem" import * as Error from "effect/platform/PlatformError" import * as Queue from "effect/Queue" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Crypto from "node:crypto" import * as NFS from "node:fs" import * as OS from "node:os" diff --git a/packages/platform-node-shared/src/NodeSink.ts b/packages/platform-node-shared/src/NodeSink.ts index 93c2f13e58..dfd05b188b 100644 --- a/packages/platform-node-shared/src/NodeSink.ts +++ b/packages/platform-node-shared/src/NodeSink.ts @@ -1,14 +1,14 @@ /** * @since 1.0.0 */ +import * as Channel from "effect/Channel" import type { NonEmptyReadonlyArray } from "effect/collections/Array" import * as Effect from "effect/Effect" import { identity, type LazyArg } from "effect/Function" import type { PlatformError } from "effect/platform/PlatformError" import { SystemError } from "effect/platform/PlatformError" -import * as Channel from "effect/stream/Channel" -import * as Pull from "effect/stream/Pull" -import * as Sink from "effect/stream/Sink" +import * as Pull from "effect/Pull" +import * as Sink from "effect/Sink" import type { Writable } from "node:stream" /** diff --git a/packages/platform-node-shared/src/NodeSocket.ts b/packages/platform-node-shared/src/NodeSocket.ts index b5a107b5b5..b7b6f845b9 100644 --- a/packages/platform-node-shared/src/NodeSocket.ts +++ b/packages/platform-node-shared/src/NodeSocket.ts @@ -1,6 +1,7 @@ /** * @since 1.0.0 */ +import * as Channel from "effect/Channel" import type { Array } from "effect/collections" import * as Deferred from "effect/Deferred" import type * as Duration from "effect/Duration" @@ -10,7 +11,6 @@ import { identity } from "effect/Function" import * as Layer from "effect/Layer" import * as Scope from "effect/Scope" import * as ServiceMap from "effect/ServiceMap" -import * as Channel from "effect/stream/Channel" import * as Socket from "effect/unstable/socket/Socket" import * as Net from "node:net" import type { Duplex } from "node:stream" diff --git a/packages/platform-node-shared/src/NodeStream.ts b/packages/platform-node-shared/src/NodeStream.ts index 1bab37f1af..ad54d2f599 100644 --- a/packages/platform-node-shared/src/NodeStream.ts +++ b/packages/platform-node-shared/src/NodeStream.ts @@ -2,6 +2,7 @@ * @since 1.0.0 */ import * as Cause from "effect/Cause" +import * as Channel from "effect/Channel" import * as Arr from "effect/collections/Array" import * as Effect from "effect/Effect" import * as Exit from "effect/Exit" @@ -9,11 +10,10 @@ import * as Fiber from "effect/Fiber" import { dual, type LazyArg } from "effect/Function" import * as MutableRef from "effect/MutableRef" import type { SizeInput } from "effect/platform/FileSystem" +import * as Pull from "effect/Pull" import * as Scope from "effect/Scope" import * as ServiceMap from "effect/ServiceMap" -import * as Channel from "effect/stream/Channel" -import * as Pull from "effect/stream/Pull" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import type { Duplex } from "node:stream" import { Readable } from "node:stream" import { pullIntoWritable } from "./NodeSink.ts" diff --git a/packages/platform-node-shared/test/NodeChildProcessSpawner.test.ts b/packages/platform-node-shared/test/NodeChildProcessSpawner.test.ts index d2d6d7bf69..d7e610795f 100644 --- a/packages/platform-node-shared/test/NodeChildProcessSpawner.test.ts +++ b/packages/platform-node-shared/test/NodeChildProcessSpawner.test.ts @@ -6,7 +6,7 @@ import * as Effect from "effect/Effect" import * as Layer from "effect/Layer" import * as Path from "effect/platform/Path" import * as PlatformError from "effect/platform/PlatformError" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as TestClock from "effect/testing/TestClock" import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process" diff --git a/packages/platform-node-shared/test/NodeFileSystem.test.ts b/packages/platform-node-shared/test/NodeFileSystem.test.ts index 9fe9639b8e..4eb762db14 100644 --- a/packages/platform-node-shared/test/NodeFileSystem.test.ts +++ b/packages/platform-node-shared/test/NodeFileSystem.test.ts @@ -4,7 +4,7 @@ import { Array } from "effect/collections" import { Option } from "effect/data" import * as Effect from "effect/Effect" import * as Fs from "effect/platform/FileSystem" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" const runPromise = (self: Effect.Effect) => Effect.runPromise( diff --git a/packages/platform-node-shared/test/NodeSink.test.ts b/packages/platform-node-shared/test/NodeSink.test.ts index de98f212ba..ef3158eca4 100644 --- a/packages/platform-node-shared/test/NodeSink.test.ts +++ b/packages/platform-node-shared/test/NodeSink.test.ts @@ -4,7 +4,7 @@ import { assert, describe, it } from "@effect/vitest" import { Effect } from "effect" import * as Data from "effect/data/Data" import * as Queue from "effect/Queue" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import { createReadStream } from "fs" import { join } from "path" import { Writable } from "stream" diff --git a/packages/platform-node-shared/test/NodeStream.test.ts b/packages/platform-node-shared/test/NodeStream.test.ts index bda09929a7..9cfd7582a7 100644 --- a/packages/platform-node-shared/test/NodeStream.test.ts +++ b/packages/platform-node-shared/test/NodeStream.test.ts @@ -1,10 +1,10 @@ import * as NodeStream from "@effect/platform-node-shared/NodeStream" import { assert, describe, it } from "@effect/vitest" import { Effect } from "effect" +import * as Channel from "effect/Channel" import * as Array from "effect/collections/Array" import * as Console from "effect/Console" -import * as Channel from "effect/stream/Channel" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import { Duplex, Readable, Transform } from "node:stream" import * as Zlib from "node:zlib" diff --git a/packages/platform-node/src/NodeHttpClient.ts b/packages/platform-node/src/NodeHttpClient.ts index 2889453ec6..bb9564e5ed 100644 --- a/packages/platform-node/src/NodeHttpClient.ts +++ b/packages/platform-node/src/NodeHttpClient.ts @@ -6,7 +6,7 @@ import * as Inspectable from "effect/interfaces/Inspectable" import * as Layer from "effect/Layer" import type * as Scope from "effect/Scope" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Cookies from "effect/unstable/http/Cookies" import * as Headers from "effect/unstable/http/Headers" import type * as Body from "effect/unstable/http/HttpBody" diff --git a/packages/platform-node/src/NodeHttpIncomingMessage.ts b/packages/platform-node/src/NodeHttpIncomingMessage.ts index 9d55e4a837..9498100970 100644 --- a/packages/platform-node/src/NodeHttpIncomingMessage.ts +++ b/packages/platform-node/src/NodeHttpIncomingMessage.ts @@ -3,7 +3,7 @@ */ import * as Effect from "effect/Effect" import * as Inspectable from "effect/interfaces/Inspectable" -import type * as Stream from "effect/stream/Stream" +import type * as Stream from "effect/Stream" import * as Headers from "effect/unstable/http/Headers" import * as IncomingMessage from "effect/unstable/http/HttpIncomingMessage" import * as UrlParams from "effect/unstable/http/UrlParams" diff --git a/packages/platform-node/src/NodeHttpServer.ts b/packages/platform-node/src/NodeHttpServer.ts index a05f849bd6..0028343a24 100644 --- a/packages/platform-node/src/NodeHttpServer.ts +++ b/packages/platform-node/src/NodeHttpServer.ts @@ -12,7 +12,7 @@ import type * as FileSystem from "effect/platform/FileSystem" import type * as Path from "effect/platform/Path" import * as Scope from "effect/Scope" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Cookies from "effect/unstable/http/Cookies" import * as Etag from "effect/unstable/http/Etag" import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient" diff --git a/packages/platform-node/src/NodeMultipart.ts b/packages/platform-node/src/NodeMultipart.ts index cfd32a005b..7502d2a85a 100644 --- a/packages/platform-node/src/NodeMultipart.ts +++ b/packages/platform-node/src/NodeMultipart.ts @@ -6,7 +6,7 @@ import * as Inspectable from "effect/interfaces/Inspectable" import type * as FileSystem from "effect/platform/FileSystem" import type * as Path from "effect/platform/Path" import type * as Scope from "effect/Scope" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Multipart from "effect/unstable/http/Multipart" import * as MP from "effect/unstable/http/Multipasta/Node" import * as NFS from "node:fs" diff --git a/packages/platform-node/test/HttpApi.test.ts b/packages/platform-node/test/HttpApi.test.ts index 5a43af8e25..ee8a2d5d99 100644 --- a/packages/platform-node/test/HttpApi.test.ts +++ b/packages/platform-node/test/HttpApi.test.ts @@ -1,11 +1,10 @@ import { NodeHttpServer } from "@effect/platform-node" import { assert, describe, it } from "@effect/vitest" -import { DateTime, Effect, Layer, Ref, ServiceMap } from "effect" +import { DateTime, Effect, Layer, Ref, ServiceMap, Stream } from "effect" import { Array } from "effect/collections" import { Filter, Redacted, Struct } from "effect/data" import { FileSystem } from "effect/platform" import { Getter, Schema, Transformation } from "effect/schema" -import { Stream } from "effect/stream" import { Cookies, HttpClient, diff --git a/packages/platform-node/test/NodeHttpClient.test.ts b/packages/platform-node/test/NodeHttpClient.test.ts index 5db8f13a27..7d05989392 100644 --- a/packages/platform-node/test/NodeHttpClient.test.ts +++ b/packages/platform-node/test/NodeHttpClient.test.ts @@ -5,7 +5,7 @@ import * as Effect from "effect/Effect" import * as Layer from "effect/Layer" import * as Schema from "effect/schema/Schema" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/unstable/http" const Todo = Schema.Struct({ diff --git a/packages/platform-node/test/NodeHttpServer.test.ts b/packages/platform-node/test/NodeHttpServer.test.ts index 2cedc2d7c0..32b3279418 100644 --- a/packages/platform-node/test/NodeHttpServer.test.ts +++ b/packages/platform-node/test/NodeHttpServer.test.ts @@ -5,7 +5,7 @@ import * as Duration from "effect/Duration" import * as Fiber from "effect/Fiber" import * as Layer from "effect/Layer" import * as Schema from "effect/schema/Schema" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Tracer from "effect/Tracer" import { Cookies, diff --git a/packages/platform-node/test/NodeSocket.test.ts b/packages/platform-node/test/NodeSocket.test.ts index 80adddbf7e..4262c309d4 100644 --- a/packages/platform-node/test/NodeSocket.test.ts +++ b/packages/platform-node/test/NodeSocket.test.ts @@ -2,7 +2,7 @@ import { NodeSocket, NodeSocketServer } from "@effect/platform-node" import { assert, describe, expect, it } from "@effect/vitest" import { Effect, Queue } from "effect" import * as Fiber from "effect/Fiber" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import { Socket, type SocketServer } from "effect/unstable/socket" import { WS } from "vitest-websocket-mock" diff --git a/packages/platform-node/test/cluster/MessageStorageTest.ts b/packages/platform-node/test/cluster/MessageStorageTest.ts deleted file mode 120000 index 199cc74c29..0000000000 --- a/packages/platform-node/test/cluster/MessageStorageTest.ts +++ /dev/null @@ -1 +0,0 @@ -../../../effect/test/cluster/MessageStorage.test.ts \ No newline at end of file diff --git a/packages/platform-node/test/cluster/MessageStorageTest.ts b/packages/platform-node/test/cluster/MessageStorageTest.ts new file mode 100644 index 0000000000..16b38ae95f --- /dev/null +++ b/packages/platform-node/test/cluster/MessageStorageTest.ts @@ -0,0 +1,196 @@ +import { describe, expect, it } from "@effect/vitest" +import { Effect, Exit, Fiber, Layer, ServiceMap } from "effect" +import { Schema } from "effect/schema" +import { TestClock } from "effect/testing" +import { + EntityAddress, + EntityId, + EntityType, + Envelope, + Message, + MessageStorage, + Reply, + ShardId, + ShardingConfig, + Snowflake +} from "effect/unstable/cluster" +import { Headers } from "effect/unstable/http" +import { Rpc, RpcSchema } from "effect/unstable/rpc" + +const MemoryLive = MessageStorage.layerMemory.pipe( + Layer.provideMerge(Snowflake.layerGenerator), + Layer.provide(ShardingConfig.layerDefaults) +) + +describe("MessageStorage", () => { + describe("memory", () => { + it.effect("saves a request", () => + Effect.gen(function*() { + const storage = yield* MessageStorage.MessageStorage + const request = yield* makeRequest() + const result = yield* storage.saveRequest(request) + expect(result._tag).toEqual("Success") + const messages = yield* storage.unprocessedMessages([request.envelope.address.shardId]) + expect(messages).toHaveLength(1) + }).pipe(Effect.provide(MemoryLive))) + + it.effect("detects duplicates", () => + Effect.gen(function*() { + const storage = yield* MessageStorage.MessageStorage + yield* storage.saveRequest( + yield* makeRequest({ + rpc: PrimaryKeyTest, + payload: PrimaryKeyTest.payloadSchema.makeUnsafe({ id: 123 }) + }) + ) + const result = yield* storage.saveRequest( + yield* makeRequest({ + rpc: PrimaryKeyTest, + payload: PrimaryKeyTest.payloadSchema.makeUnsafe({ id: 123 }) + }) + ) + expect(result._tag).toEqual("Duplicate") + }).pipe(Effect.provide(MemoryLive))) + + it.effect("unprocessedMessages excludes complete requests", () => + Effect.gen(function*() { + const storage = yield* MessageStorage.MessageStorage + const request = yield* makeRequest() + yield* storage.saveRequest(request) + yield* storage.saveReply(yield* makeReply(request)) + const messages = yield* storage.unprocessedMessages([request.envelope.address.shardId]) + expect(messages).toHaveLength(0) + }).pipe(Effect.provide(MemoryLive))) + + it.effect("repliesFor", () => + Effect.gen(function*() { + const storage = yield* MessageStorage.MessageStorage + const request = yield* makeRequest() + yield* storage.saveRequest(request) + let replies = yield* storage.repliesFor([request]) + expect(replies).toHaveLength(0) + yield* storage.saveReply(yield* makeReply(request)) + replies = yield* storage.repliesFor([request]) + expect(replies).toHaveLength(1) + expect(replies[0].requestId).toEqual(request.envelope.requestId) + }).pipe(Effect.provide(MemoryLive))) + + it.effect("registerReplyHandler", () => + Effect.gen(function*() { + const storage = yield* MessageStorage.MessageStorage + const latch = yield* Effect.makeLatch() + const request = yield* makeRequest() + yield* storage.saveRequest(request) + const fiber = yield* storage.registerReplyHandler( + new Message.OutgoingRequest({ + ...request, + respond: () => latch.open + }) + ).pipe(Effect.forkChild) + yield* TestClock.adjust(1) + yield* storage.saveReply(yield* makeReply(request)) + yield* latch.await + yield* Fiber.await(fiber) + }).pipe(Effect.provide(MemoryLive))) + }) +}) + +export const GetUserRpc = Rpc.make("GetUser", { + payload: { id: Schema.Number } +}) + +export const makeRequest = Effect.fnUntraced(function*(options?: { + readonly rpc?: Rpc.AnyWithProps + readonly payload?: any +}) { + const snowflake = yield* Snowflake.Generator + const rpc = options?.rpc ?? GetUserRpc + return new Message.OutgoingRequest({ + envelope: Envelope.makeRequest({ + requestId: snowflake.nextUnsafe(), + address: EntityAddress.make({ + shardId: ShardId.make("default", 1), + entityType: EntityType.make("test"), + entityId: EntityId.make("1") + }), + tag: rpc._tag, + payload: options?.payload ?? { id: 123 }, + traceId: "noop", + spanId: "noop", + sampled: false, + headers: Headers.empty + }), + services: ServiceMap.empty() as any, + rpc, + lastReceivedReply: undefined, + respond() { + return Effect.void + } + }) +}) + +export class PrimaryKeyTest extends Rpc.make("PrimaryKeyTest", { + payload: { + id: Schema.Number + }, + primaryKey: (value) => value.id.toString() +}) {} + +export class StreamRpc extends Rpc.make("StreamTest", { + success: RpcSchema.Stream(Schema.Void, Schema.Never), + payload: { + id: Schema.Number + }, + primaryKey: (value) => value.id.toString() +}) {} + +export const makeReply = Effect.fnUntraced(function*(request: Message.OutgoingRequest) { + const snowflake = yield* Snowflake.Generator + return new Reply.ReplyWithContext({ + reply: new Reply.WithExit({ + id: snowflake.nextUnsafe(), + requestId: request.envelope.requestId, + exit: Exit.void as any + }), + services: request.services, + rpc: request.rpc + }) +}) + +export const makeAckChunk = Effect.fnUntraced(function*( + request: Message.OutgoingRequest, + chunk: Reply.ReplyWithContext +) { + const snowflake = yield* Snowflake.Generator + return new Message.OutgoingEnvelope({ + envelope: new Envelope.AckChunk({ + id: snowflake.nextUnsafe(), + address: request.envelope.address, + requestId: chunk.reply.requestId, + replyId: chunk.reply.id + }), + rpc: request.rpc + }) +}) + +export const makeChunkReply = Effect.fnUntraced(function*(request: Message.OutgoingRequest, sequence = 0) { + const snowflake = yield* Snowflake.Generator + return new Reply.ReplyWithContext({ + reply: new Reply.Chunk({ + id: snowflake.nextUnsafe(), + requestId: request.envelope.requestId, + sequence, + values: [undefined] + }), + services: request.services, + rpc: request.rpc + }) +}) + +export const makeEmptyReply = (request: Message.OutgoingRequest) => { + return new Reply.ReplyWithContext({ + reply: Reply.Chunk.emptyFrom(request.envelope.requestId), + services: request.services, + rpc: request.rpc + }) +} diff --git a/packages/platform-node/test/fixtures/mysql2-utils.ts b/packages/platform-node/test/fixtures/mysql2-utils.ts deleted file mode 120000 index 78c6ff9fb2..0000000000 --- a/packages/platform-node/test/fixtures/mysql2-utils.ts +++ /dev/null @@ -1 +0,0 @@ -../../../sql/mysql2/test/utils.ts \ No newline at end of file diff --git a/packages/platform-node/test/fixtures/mysql2-utils.ts b/packages/platform-node/test/fixtures/mysql2-utils.ts new file mode 100644 index 0000000000..0a782f9346 --- /dev/null +++ b/packages/platform-node/test/fixtures/mysql2-utils.ts @@ -0,0 +1,65 @@ +import { MysqlClient } from "@effect/sql-mysql2" +import type { StartedMySqlContainer } from "@testcontainers/mysql" +import { MySqlContainer } from "@testcontainers/mysql" +import { Effect, Layer, ServiceMap, String } from "effect" +import { Data, Redacted } from "effect/data" + +export class ContainerError extends Data.TaggedError("ContainerError")<{ + cause: unknown +}> {} + +export class MysqlContainer extends ServiceMap.Service< + MysqlContainer, + StartedMySqlContainer +>()("test/MysqlContainer") { + static layer = Layer.effect(this)( + Effect.acquireRelease( + Effect.tryPromise({ + try: () => new MySqlContainer("mysql:lts").start(), + catch: (cause) => new ContainerError({ cause }) + }), + (container) => Effect.promise(() => container.stop()) + ) + ) + + static client = Layer.unwrap( + Effect.gen(function*() { + const container = yield* MysqlContainer + return MysqlClient.layer({ + url: Redacted.make(container.getConnectionUri()) + }) + }) + ) + + static layerClient = this.client.pipe(Layer.provide(this.layer)) + + static layerClientWithTransforms = Layer.unwrap( + Effect.gen(function*() { + const container = yield* MysqlContainer + return MysqlClient.layer({ + url: Redacted.make(container.getConnectionUri()), + transformQueryNames: String.camelToSnake, + transformResultNames: String.snakeToCamel + }) + }) + ).pipe(Layer.provide(this.layer)) + + static layerVitest = Layer.effect( + this, + Effect.acquireRelease( + Effect.tryPromise({ + try: () => + new MySqlContainer("vitess/vttestserver:mysql80").withEnvironment({ + KEYSPACES: "test,unsharded", + NUM_SHARDS: "1,1", + MYSQL_BIND_HOST: "0.0.0.0", + PORT: "3303" + }).start(), + catch: (cause) => new ContainerError({ cause }) + }), + (container) => Effect.promise(() => container.stop()) + ) + ) + + static layerClientVitess = this.client.pipe(Layer.provide(this.layerVitest)) +} diff --git a/packages/platform-node/test/fixtures/pg-utils.ts b/packages/platform-node/test/fixtures/pg-utils.ts deleted file mode 120000 index 9b44f07132..0000000000 --- a/packages/platform-node/test/fixtures/pg-utils.ts +++ /dev/null @@ -1 +0,0 @@ -../../../sql/pg/test/utils.ts \ No newline at end of file diff --git a/packages/platform-node/test/fixtures/pg-utils.ts b/packages/platform-node/test/fixtures/pg-utils.ts new file mode 100644 index 0000000000..901239baf7 --- /dev/null +++ b/packages/platform-node/test/fixtures/pg-utils.ts @@ -0,0 +1,40 @@ +import { PgClient } from "@effect/sql-pg" +import { PostgreSqlContainer } from "@testcontainers/postgresql" +import { Effect, Layer, ServiceMap, String } from "effect" +import { Data, Redacted } from "effect/data" + +export class ContainerError extends Data.TaggedError("ContainerError")<{ + cause: unknown +}> {} + +export class PgContainer extends ServiceMap.Service()("test/PgContainer", { + make: Effect.acquireRelease( + Effect.tryPromise({ + try: () => new PostgreSqlContainer("postgres:alpine").start(), + catch: (cause) => new ContainerError({ cause }) + }), + (container) => Effect.promise(() => container.stop()) + ) +}) { + static layer = Layer.effect(this)(this.make) + + static layerClient = Layer.unwrap( + Effect.gen(function*() { + const container = yield* PgContainer + return PgClient.layer({ + url: Redacted.make(container.getConnectionUri()) + }) + }) + ).pipe(Layer.provide(this.layer)) + + static layerClientWithTransforms = Layer.unwrap( + Effect.gen(function*() { + const container = yield* PgContainer + return PgClient.layer({ + url: Redacted.make(container.getConnectionUri()), + transformResultNames: String.snakeToCamel, + transformQueryNames: String.camelToSnake + }) + }) + ).pipe(Layer.provide(this.layer)) +} diff --git a/packages/platform-node/test/fixtures/rpc-e2e.ts b/packages/platform-node/test/fixtures/rpc-e2e.ts index a0e66f502d..fe506e26f7 100644 --- a/packages/platform-node/test/fixtures/rpc-e2e.ts +++ b/packages/platform-node/test/fixtures/rpc-e2e.ts @@ -1,11 +1,10 @@ import { assert, describe, it } from "@effect/vitest" -import { Cause, Effect, Fiber, ServiceMap } from "effect" +import { Cause, Effect, Fiber, ServiceMap, Stream } from "effect" import { Option } from "effect/data" // @ts-ignore // eslint-disable-next-line @typescript-eslint/no-unused-vars import { NodeInspectSymbol } from "effect/interfaces/Inspectable" import * as Layer from "effect/Layer" -import { Stream } from "effect/stream" import * as RpcClient from "effect/unstable/rpc/RpcClient" import type { RpcClientError } from "effect/unstable/rpc/RpcClientError" import type * as RpcGroup from "effect/unstable/rpc/RpcGroup" diff --git a/packages/sql/clickhouse/src/ClickhouseClient.ts b/packages/sql/clickhouse/src/ClickhouseClient.ts index 40b4d192a1..aee855b273 100644 --- a/packages/sql/clickhouse/src/ClickhouseClient.ts +++ b/packages/sql/clickhouse/src/ClickhouseClient.ts @@ -11,7 +11,7 @@ import { dual } from "effect/Function" import * as Layer from "effect/Layer" import type * as Scope from "effect/Scope" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Reactivity from "effect/unstable/reactivity/Reactivity" import * as Client from "effect/unstable/sql/SqlClient" import type { Connection } from "effect/unstable/sql/SqlConnection" diff --git a/packages/sql/d1/src/D1Client.ts b/packages/sql/d1/src/D1Client.ts index f9d52f84a4..3009cd5d88 100644 --- a/packages/sql/d1/src/D1Client.ts +++ b/packages/sql/d1/src/D1Client.ts @@ -10,7 +10,7 @@ import { identity } from "effect/Function" import * as Layer from "effect/Layer" import type * as Scope from "effect/Scope" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Reactivity from "effect/unstable/reactivity/Reactivity" import * as Client from "effect/unstable/sql/SqlClient" import type { Connection } from "effect/unstable/sql/SqlConnection" diff --git a/packages/sql/libsql/src/LibsqlClient.ts b/packages/sql/libsql/src/LibsqlClient.ts index f12bfbf355..ee54021deb 100644 --- a/packages/sql/libsql/src/LibsqlClient.ts +++ b/packages/sql/libsql/src/LibsqlClient.ts @@ -9,7 +9,7 @@ import * as Effect from "effect/Effect" import * as Layer from "effect/Layer" import * as Scope from "effect/Scope" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Reactivity from "effect/unstable/reactivity/Reactivity" import * as Client from "effect/unstable/sql/SqlClient" import type { Connection } from "effect/unstable/sql/SqlConnection" diff --git a/packages/sql/mssql/src/MssqlClient.ts b/packages/sql/mssql/src/MssqlClient.ts index 91a9cffed0..7b362e75b9 100644 --- a/packages/sql/mssql/src/MssqlClient.ts +++ b/packages/sql/mssql/src/MssqlClient.ts @@ -10,7 +10,7 @@ import * as Layer from "effect/Layer" import * as Pool from "effect/Pool" import * as Scope from "effect/Scope" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Reactivity from "effect/unstable/reactivity/Reactivity" import * as Client from "effect/unstable/sql/SqlClient" import type { Connection } from "effect/unstable/sql/SqlConnection" diff --git a/packages/sql/mysql2/src/MysqlClient.ts b/packages/sql/mysql2/src/MysqlClient.ts index cc0b9b0efa..3033e2f2d3 100644 --- a/packages/sql/mysql2/src/MysqlClient.ts +++ b/packages/sql/mysql2/src/MysqlClient.ts @@ -8,7 +8,7 @@ import * as Effect from "effect/Effect" import * as Layer from "effect/Layer" import type { Scope } from "effect/Scope" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Reactivity from "effect/unstable/reactivity/Reactivity" import * as Client from "effect/unstable/sql/SqlClient" import type { Connection } from "effect/unstable/sql/SqlConnection" diff --git a/packages/sql/pg/src/PgClient.ts b/packages/sql/pg/src/PgClient.ts index 7288ff2db1..bb67403cfc 100644 --- a/packages/sql/pg/src/PgClient.ts +++ b/packages/sql/pg/src/PgClient.ts @@ -1,6 +1,7 @@ /** * @since 1.0.0 */ +import * as Channel from "effect/Channel" import * as Arr from "effect/collections/Array" import * as Config from "effect/Config" import * as Redacted from "effect/data/Redacted" @@ -9,13 +10,12 @@ import * as Effect from "effect/Effect" import * as Fiber from "effect/Fiber" import * as Layer from "effect/Layer" import * as Number from "effect/Number" +import * as Pull from "effect/Pull" import * as Queue from "effect/Queue" import * as RcRef from "effect/RcRef" import * as Scope from "effect/Scope" import * as ServiceMap from "effect/ServiceMap" -import * as Channel from "effect/stream/Channel" -import * as Pull from "effect/stream/Pull" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Reactivity from "effect/unstable/reactivity/Reactivity" import * as Client from "effect/unstable/sql/SqlClient" import type { Connection } from "effect/unstable/sql/SqlConnection" diff --git a/packages/sql/pg/test/Client.test.ts b/packages/sql/pg/test/Client.test.ts index 1dfc6b9da9..4d0337bd10 100644 --- a/packages/sql/pg/test/Client.test.ts +++ b/packages/sql/pg/test/Client.test.ts @@ -1,8 +1,7 @@ import { PgClient } from "@effect/sql-pg" import { assert, expect, it } from "@effect/vitest" -import { Effect, String } from "effect" +import { Effect, Stream, String } from "effect" import { Redacted } from "effect/data" -import { Stream } from "effect/stream" import { TestClock } from "effect/testing" import { SqlClient } from "effect/unstable/sql" import * as Statement from "effect/unstable/sql/Statement" diff --git a/packages/sql/sqlite-bun/src/SqliteClient.ts b/packages/sql/sqlite-bun/src/SqliteClient.ts index 29c2dacacb..f7b4218544 100644 --- a/packages/sql/sqlite-bun/src/SqliteClient.ts +++ b/packages/sql/sqlite-bun/src/SqliteClient.ts @@ -9,7 +9,7 @@ import { identity } from "effect/Function" import * as Layer from "effect/Layer" import * as Scope from "effect/Scope" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Reactivity from "effect/unstable/reactivity/Reactivity" import * as Client from "effect/unstable/sql/SqlClient" import type { Connection } from "effect/unstable/sql/SqlConnection" diff --git a/packages/sql/sqlite-do/src/SqliteClient.ts b/packages/sql/sqlite-do/src/SqliteClient.ts index 583773a999..6017528fd5 100644 --- a/packages/sql/sqlite-do/src/SqliteClient.ts +++ b/packages/sql/sqlite-do/src/SqliteClient.ts @@ -9,7 +9,7 @@ import { identity } from "effect/Function" import * as Layer from "effect/Layer" import * as Scope from "effect/Scope" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Reactivity from "effect/unstable/reactivity/Reactivity" import * as Client from "effect/unstable/sql/SqlClient" import type { Connection } from "effect/unstable/sql/SqlConnection" diff --git a/packages/sql/sqlite-node/src/SqliteClient.ts b/packages/sql/sqlite-node/src/SqliteClient.ts index cfd39def85..2c2f8a54f4 100644 --- a/packages/sql/sqlite-node/src/SqliteClient.ts +++ b/packages/sql/sqlite-node/src/SqliteClient.ts @@ -11,7 +11,7 @@ import { identity } from "effect/Function" import * as Layer from "effect/Layer" import * as Scope from "effect/Scope" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Reactivity from "effect/unstable/reactivity/Reactivity" import * as Client from "effect/unstable/sql/SqlClient" import type { Connection } from "effect/unstable/sql/SqlConnection" diff --git a/packages/sql/sqlite-react-native/src/SqliteClient.ts b/packages/sql/sqlite-react-native/src/SqliteClient.ts index ae94d2d59d..93d5b2dc42 100644 --- a/packages/sql/sqlite-react-native/src/SqliteClient.ts +++ b/packages/sql/sqlite-react-native/src/SqliteClient.ts @@ -9,7 +9,7 @@ import { constFalse, identity } from "effect/Function" import * as Layer from "effect/Layer" import * as Scope from "effect/Scope" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Reactivity from "effect/unstable/reactivity/Reactivity" import * as Client from "effect/unstable/sql/SqlClient" import type { Connection } from "effect/unstable/sql/SqlConnection" diff --git a/packages/sql/sqlite-wasm/src/SqliteClient.ts b/packages/sql/sqlite-wasm/src/SqliteClient.ts index dc6de0c211..6ad05ccde7 100644 --- a/packages/sql/sqlite-wasm/src/SqliteClient.ts +++ b/packages/sql/sqlite-wasm/src/SqliteClient.ts @@ -14,7 +14,7 @@ import * as Layer from "effect/Layer" import * as Scope from "effect/Scope" import * as ScopedRef from "effect/ScopedRef" import * as ServiceMap from "effect/ServiceMap" -import * as Stream from "effect/stream/Stream" +import * as Stream from "effect/Stream" import * as Reactivity from "effect/unstable/reactivity/Reactivity" import * as Client from "effect/unstable/sql/SqlClient" import type { Connection } from "effect/unstable/sql/SqlConnection"