Skip to content

Commit

Permalink
Release queue: minor (#3248)
Browse files Browse the repository at this point in the history
Co-authored-by: ecyrbe <ecyrbe@gmail.com>
Co-authored-by: Giulio Canti <giulio.canti@gmail.com>
Co-authored-by: Michael Arnaldi <michael.arnaldi@effectful.co>
Co-authored-by: Dmitry <dilame@users.noreply.github.com>
Co-authored-by: Tim <hello@timsmart.co>
Co-authored-by: Sebastian Lorenz <fubhy@fubhy.com>
Co-authored-by: Milan Suk <Milansuk@email.cz>
Co-authored-by: Vincent François <vincent.francois@inato.com>
Co-authored-by: Tim Smart <tim.smart@arisechurch.com>
Co-authored-by: Maxim Khramtsov <khraks.mamtsov@gmail.com>
Co-authored-by: maksim.khramtsov <maksim.khramtsov@btsdigital.kz>
  • Loading branch information
12 people authored Jul 30, 2024
1 parent d12ec65 commit 9c058c9
Show file tree
Hide file tree
Showing 88 changed files with 4,753 additions and 128 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-moons-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": minor
---

make List.Cons extend NonEmptyIterable
34 changes: 34 additions & 0 deletions .changeset/clean-trainers-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
"effect": minor
---

add DateTime module

The `DateTime` module provides functionality for working with time, including
support for time zones and daylight saving time.

It has two main data types: `DateTime.Utc` and `DateTime.Zoned`.

A `DateTime.Utc` represents a time in Coordinated Universal Time (UTC), and
a `DateTime.Zoned` contains both a UTC timestamp and a time zone.

There is also a `CurrentTimeZone` service, for setting a time zone contextually.

```ts
import { DateTime, Effect } from "effect";

Effect.gen(function* () {
// Get the current time in the current time zone
const now = yield* DateTime.nowInCurrentZone;

// Math functions are included
const tomorrow = DateTime.add(now, 1, "day");

// Convert to a different time zone
// The UTC portion of the `DateTime` is preserved and only the time zone is
// changed
const sydneyTime = tomorrow.pipe(
DateTime.unsafeSetZoneNamed("Australia/Sydney"),
);
}).pipe(DateTime.withCurrentZoneNamed("America/New_York"));
```
5 changes: 5 additions & 0 deletions .changeset/fluffy-countries-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/sql-mssql": patch
---

make mssql placeholder format compatible with kysely
35 changes: 35 additions & 0 deletions .changeset/forty-beers-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
"effect": minor
---

add Stream.asyncPush api

This api creates a stream from an external push-based resource.

You can use the `emit` helper to emit values to the stream. You can also use
the `emit` helper to signal the end of the stream by using apis such as
`emit.end` or `emit.fail`.

By default it uses an "unbounded" buffer size.
You can customize the buffer size and strategy by passing an object as the
second argument with the `bufferSize` and `strategy` fields.

```ts
import { Effect, Stream } from "effect";

Stream.asyncPush<string>(
(emit) =>
Effect.acquireRelease(
Effect.gen(function* () {
yield* Effect.log("subscribing");
return setInterval(() => emit.single("tick"), 1000);
}),
(handle) =>
Effect.gen(function* () {
yield* Effect.log("unsubscribing");
clearInterval(handle);
}),
),
{ bufferSize: 16, strategy: "dropping" },
);
```
19 changes: 19 additions & 0 deletions .changeset/lovely-buckets-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
"effect": minor
---

Implement Struct.keys as a typed alternative to Object.keys

```ts
import { Struct } from "effect"

const symbol: unique symbol = Symbol()

const value = {
a: 1,
b: 2,
[symbol]: 3
}

const keys: Array<"a" | "b"> = Struct.keys(value)
```
5 changes: 5 additions & 0 deletions .changeset/metal-spoons-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/sql-kysely": patch
---

Add kysely support with @effect/sql-kysely package
14 changes: 14 additions & 0 deletions .changeset/new-garlics-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"effect": minor
---

Add `Random.choice`.

```ts
import { Random } from "effect"

Effect.gen(function* () {
const randomItem = yield* Random.choice([1, 2, 3])
console.log(randomItem)
})
```
5 changes: 5 additions & 0 deletions .changeset/pink-ghosts-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": minor
---

Add onlyEffect option to Effect.tap
5 changes: 5 additions & 0 deletions .changeset/purple-onions-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": minor
---

Support `Refinement` in `Predicate.tuple` and `Predicate.struct`
5 changes: 5 additions & 0 deletions .changeset/red-bottles-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/schema": patch
---

add schemas for working with the DateTime module
22 changes: 22 additions & 0 deletions .changeset/stream-on-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
"effect": minor
---

Implement `Stream.onEnd` that adds an effect to be executed at the end of the stream.

```ts
import { Console, Effect, Stream } from "effect";

const stream = Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.tap((n) => Console.log(`after mapping: ${n}`)),
Stream.onEnd(Console.log("Stream ended"))
)

Effect.runPromise(Stream.runCollect(stream)).then(console.log)
// after mapping: 2
// after mapping: 4
// after mapping: 6
// Stream ended
// { _id: 'Chunk', values: [ 2, 4, 6 ] }
```
22 changes: 22 additions & 0 deletions .changeset/stream-on-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
"effect": minor
---

Implement `Stream.onStart` that adds an effect to be executed at the start of the stream.

```ts
import { Console, Effect, Stream } from "effect";

const stream = Stream.make(1, 2, 3).pipe(
Stream.onStart(Console.log("Stream started")),
Stream.map((n) => n * 2),
Stream.tap((n) => Console.log(`after mapping: ${n}`))
)

Effect. runPromise(Stream. runCollect(stream)).then(console. log)
// Stream started
// after mapping: 2
// after mapping: 4
// after mapping: 6
// { _id: 'Chunk', values: [ 2, 4, 6 ] }
```
5 changes: 5 additions & 0 deletions .changeset/tricky-cheetahs-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": minor
---

add `bufferSize` option to Stream.fromEventListener
8 changes: 8 additions & 0 deletions .changeset/wet-laws-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@effect/platform": patch
"effect": minor
"@effect/cli": patch
"@effect/rpc": patch
---

Changed various function signatures to return `Array` instead of `ReadonlyArray`
2 changes: 1 addition & 1 deletion packages/cli/src/internal/commandDescriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ const parseInternal = (
case "Standard": {
const parseCommandLine = (
args: ReadonlyArray<string>
): Effect.Effect<ReadonlyArray<string>, ValidationError.ValidationError> =>
): Effect.Effect<Array<string>, ValidationError.ValidationError> =>
Arr.matchLeft(args, {
onEmpty: () => {
const error = InternalHelpDoc.p(`Missing command name: '${self.name}'`)
Expand Down
12 changes: 12 additions & 0 deletions packages/effect/dtslint/Effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,18 @@ Effect.succeed("a" as const).pipe(Effect.filterOrElse(
// $ExpectType Effect<"a", never, never>
Effect.succeed("a" as const).pipe(Effect.tap(tacitString))

// $ExpectType Effect<"a", never, never>
Effect.succeed("a" as const).pipe(Effect.tap(tacitString, { onlyEffect: true }))

// @ts-expect-error
Effect.succeed("a" as const).pipe(Effect.tap(tacitStringError, { onlyEffect: true }))

// $ExpectType Effect<"a", never, never>
Effect.succeed("a" as const).pipe(Effect.tap(tacitString("a"), { onlyEffect: true }))

// @ts-expect-error
Effect.succeed("a" as const).pipe(Effect.tap("a", { onlyEffect: true }))

// $ExpectType Effect<never, "a", never>
Effect.fail("a" as const).pipe(Effect.tapError(tacitString))

Expand Down
48 changes: 48 additions & 0 deletions packages/effect/dtslint/Predicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,51 @@ pipe(Predicate.isString, Predicate.or(Predicate.isNumber))

// $ExpectType Refinement<unknown, string | number>
Predicate.or(Predicate.isString, Predicate.isNumber)

// -------------------------------------------------------------------------------------
// tuple
// -------------------------------------------------------------------------------------

const isA = hole<Predicate.Refinement<string, "a">>()
const isTrue = hole<Predicate.Refinement<boolean, true>>()
const isOdd = hole<Predicate.Predicate<number>>()

// $ExpectType Refinement<readonly [boolean, string], readonly [true, "a"]>
Predicate.tuple(isTrue, isA)

// $ExpectType Refinement<readonly [boolean, number], readonly [true, number]>
Predicate.tuple(isTrue, isOdd)

// $ExpectType Predicate<readonly [number, number]>
Predicate.tuple(isOdd, isOdd)

// $ExpectType Predicate<readonly number[]>
Predicate.tuple(...hole<Array<Predicate.Predicate<number>>>())

// $ExpectType Refinement<readonly never[], readonly never[]>
Predicate.tuple(...hole<Array<Predicate.Predicate<number> | Predicate.Refinement<boolean, true>>>())

// $ExpectType Refinement<readonly boolean[], readonly true[]>
Predicate.tuple(...hole<Array<Predicate.Refinement<boolean, true>>>())

// -------------------------------------------------------------------------------------
// struct
// -------------------------------------------------------------------------------------

// $ExpectType Refinement<{ readonly a: string; readonly true: boolean; }, { readonly a: "a"; readonly true: true; }>
Predicate.struct({
a: isA,
true: isTrue
})

// $ExpectType Refinement<{ readonly odd: number; readonly true: boolean; }, { readonly odd: number; readonly true: true; }>
Predicate.struct({
odd: isOdd,
true: isTrue
})

// $ExpectType Predicate<{ readonly odd: number; readonly odd1: number; }>
Predicate.struct({
odd: isOdd,
odd1: isOdd
})
30 changes: 30 additions & 0 deletions packages/effect/dtslint/Random.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type * as Array from "../src/Array.js"
import type { Chunk } from "../src/index.js"
import * as Random from "../src/Random.js"

declare const array: Array<number>
declare const nonEmptyArray: Array.NonEmptyArray<number>

// $ExpectType Effect<number, NoSuchElementException, never>
Random.choice(array)

// $ExpectType Effect<number, never, never>
Random.choice(nonEmptyArray)

declare const readonlyArray: Array<number>
declare const nonEmptyReadonlyArray: Array.NonEmptyArray<number>

// $ExpectType Effect<number, NoSuchElementException, never>
Random.choice(readonlyArray)

// $ExpectType Effect<number, never, never>
Random.choice(nonEmptyReadonlyArray)

declare const chunk: Chunk.Chunk<number>
declare const nonEmptyChunk: Chunk.NonEmptyChunk<number>

// $ExpectType Effect<number, NoSuchElementException, never>
Random.choice(chunk)

// $ExpectType Effect<number, never, never>
Random.choice(nonEmptyChunk)
4 changes: 2 additions & 2 deletions packages/effect/src/ConfigProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export declare namespace ConfigProvider {
path: ReadonlyArray<string>,
config: Config.Config.Primitive<A>,
split?: boolean
): Effect.Effect<ReadonlyArray<A>, ConfigError.ConfigError>
): Effect.Effect<Array<A>, ConfigError.ConfigError>
enumerateChildren(
path: ReadonlyArray<string>
): Effect.Effect<HashSet.HashSet<string>, ConfigError.ConfigError>
Expand Down Expand Up @@ -162,7 +162,7 @@ export const makeFlat: (options: {
path: ReadonlyArray<string>,
config: Config.Config.Primitive<A>,
split: boolean
) => Effect.Effect<ReadonlyArray<A>, ConfigError.ConfigError>
) => Effect.Effect<Array<A>, ConfigError.ConfigError>
readonly enumerateChildren: (
path: ReadonlyArray<string>
) => Effect.Effect<HashSet.HashSet<string>, ConfigError.ConfigError>
Expand Down
Loading

0 comments on commit 9c058c9

Please sign in to comment.