-
-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Michael Arnaldi <michael.arnaldi@effectful.co> Co-authored-by: Tim <hello@timsmart.co>
- Loading branch information
1 parent
25d74f8
commit 1499974
Showing
147 changed files
with
11,506 additions
and
412 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"@effect/sql-sqlite-react-native": minor | ||
"@effect/sql-sqlite-node": minor | ||
"@effect/sql-sqlite-wasm": minor | ||
"@effect/sql-sqlite-bun": minor | ||
"@effect/sql-mysql2": minor | ||
"@effect/sql-mssql": minor | ||
"@effect/sql-pg": minor | ||
"@effect/sql": minor | ||
--- | ||
|
||
initial @effect/sql release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"effect": patch | ||
--- | ||
|
||
don't run resolver if there are no incomplete requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"effect": patch | ||
--- | ||
|
||
add String casing transformation apis | ||
|
||
- `snakeToCamel` | ||
- `snakeToPascal` | ||
- `snakeToKebab` | ||
- `camelToSnake` | ||
- `pascalToSnake` | ||
- `kebabToSnake` |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
/packages/effect/ @mikearnaldi | ||
/packages/cli/ @IMax153 | ||
/packages/experimental/ @tim-smart | ||
/packages/opentelemetry/ @tim-smart | ||
/packages/platform/ @tim-smart | ||
/packages/platform-browser/ @tim-smart | ||
/packages/platform-bun/ @tim-smart | ||
/packages/platform-node/ @tim-smart | ||
/packages/printer/ @IMax153 | ||
/packages/printer-ansi/ @IMax153 | ||
/packages/rpc/ @tim-smart | ||
/packages/rpc-http/ @tim-smart | ||
/packages/schema/ @gcanti | ||
/packages/typeclass/ @gcanti | ||
/packages/effect/ @mikearnaldi | ||
/packages/cli/ @IMax153 | ||
/packages/experimental/ @tim-smart | ||
/packages/opentelemetry/ @tim-smart | ||
/packages/platform/ @tim-smart | ||
/packages/platform-browser/ @tim-smart | ||
/packages/platform-bun/ @tim-smart | ||
/packages/platform-node/ @tim-smart | ||
/packages/platform-node-shared/ @tim-smart | ||
/packages/printer/ @IMax153 | ||
/packages/printer-ansi/ @IMax153 | ||
/packages/rpc/ @tim-smart | ||
/packages/rpc-http/ @tim-smart | ||
/packages/schema/ @gcanti | ||
/packages/sql/ @tim-smart | ||
/packages/sql-mssql/ @tim-smart | ||
/packages/sql-mysql2/ @tim-smart | ||
/packages/sql-pg/ @tim-smart | ||
/packages/sql-sqlite-bun/ @tim-smart | ||
/packages/sql-sqlite-node/ @tim-smart | ||
/packages/sql-sqlite-react-native/ @tim-smart | ||
/packages/sql-sqlite-wasm/ @tim-smart | ||
/packages/typeclass/ @gcanti | ||
/packages/vitest/ @mikearnaldi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023-present The Contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Effect SQL - Microsoft SQL Server | ||
|
||
An @effect/sql implementation using the mssql `tedious` library. | ||
|
||
See here for more information: https://github.com/Effect-TS/effect/tree/main/packages/sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"$schema": "../../node_modules/@effect/docgen/schema.json", | ||
"exclude": [ | ||
"src/internal/**/*.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
services: | ||
db: | ||
environment: | ||
ACCEPT_EULA: "Y" | ||
SA_PASSWORD: "Sq1Fx_password" | ||
# mssql server image isn't available for arm64 architecture, so we use azure-sql instead | ||
# image: mcr.microsoft.com/azure-sql-edge:1.0.4 | ||
# If you really want to use MS SQL Server, uncomment the following line | ||
image: mcr.microsoft.com/mssql/server | ||
ports: | ||
- 1433:1433 | ||
restart: always | ||
healthcheck: | ||
test: | ||
[ | ||
"CMD-SHELL", | ||
"/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Sq1Fx_password -Q 'SELECT 1' || exit 1", | ||
] | ||
interval: 10s | ||
retries: 10 | ||
start_period: 10s | ||
timeout: 3s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import * as DevTools from "@effect/experimental/DevTools" | ||
import { NodeFileSystem } from "@effect/platform-node" | ||
import * as Sql from "@effect/sql-mssql" | ||
import { Config, Effect, Layer, Logger, LogLevel, Secret, String } from "effect" | ||
import { pipe } from "effect/Function" | ||
import { fileURLToPath } from "node:url" | ||
|
||
const peopleProcedure = pipe( | ||
Sql.procedure.make("people_proc"), | ||
Sql.procedure.param<string>()("name", Sql.types.VarChar), | ||
Sql.procedure.withRows<{ readonly id: number; readonly name: string }>(), | ||
Sql.procedure.compile | ||
) | ||
|
||
const program = Effect.gen(function*(_) { | ||
const sql = yield* _(Sql.client.MssqlClient) | ||
|
||
yield* _( | ||
sql` | ||
CREATE OR ALTER PROC people_proc | ||
@name VARCHAR(255) | ||
AS | ||
BEGIN | ||
SELECT * FROM people WHERE name = @name | ||
END | ||
` | ||
) | ||
|
||
// Insert | ||
const [inserted] = yield* _( | ||
sql`INSERT INTO ${sql("people")} ${ | ||
sql.insert({ | ||
name: "Tim", | ||
createdAt: new Date() | ||
}) | ||
}` | ||
) | ||
console.log(inserted) | ||
|
||
console.log( | ||
yield* _( | ||
Effect.all( | ||
[ | ||
sql`SELECT TOP 3 * FROM ${sql("people")}`, | ||
sql`SELECT TOP 3 * FROM ${sql("people")}`.values, | ||
sql`SELECT TOP 3 * FROM ${sql("people")}`.withoutTransform, | ||
sql.call(peopleProcedure({ name: "Tim" })) | ||
], | ||
{ concurrency: "unbounded" } | ||
) | ||
) | ||
) | ||
|
||
console.log( | ||
yield* _(sql` | ||
UPDATE people | ||
SET name = data.name | ||
OUTPUT inserted.* | ||
FROM ${sql.updateValues([{ ...inserted, name: "New name" }], "data")} | ||
WHERE people.id = data.id | ||
`) | ||
) | ||
|
||
console.log( | ||
yield* _( | ||
sql`SELECT TOP 3 * FROM ${sql("people")}`, | ||
Effect.zipRight( | ||
Effect.catchAllCause( | ||
sql.withTransaction(Effect.die("fail")), | ||
(_) => Effect.unit | ||
) | ||
), | ||
Effect.zipRight( | ||
sql.withTransaction(sql`SELECT TOP 3 * FROM ${sql("people")}`) | ||
), | ||
sql.withTransaction | ||
) | ||
) | ||
}) | ||
|
||
const SqlLive = Sql.migrator.layer({ | ||
loader: Sql.migrator.fromFileSystem( | ||
fileURLToPath(new URL("./migrations", import.meta.url)) | ||
) | ||
}).pipe( | ||
Layer.provideMerge( | ||
Sql.client.layer({ | ||
database: Config.succeed("msdb"), | ||
server: Config.succeed("localhost"), | ||
username: Config.succeed("sa"), | ||
password: Config.succeed(Secret.fromString("Sq1Fx_password")), | ||
transformQueryNames: Config.succeed(String.camelToSnake), | ||
transformResultNames: Config.succeed(String.snakeToCamel) | ||
}) | ||
), | ||
Layer.provide(NodeFileSystem.layer), | ||
Layer.provide(DevTools.layer()), | ||
Layer.provide(Logger.minimumLogLevel(LogLevel.All)) | ||
) | ||
|
||
pipe( | ||
program, | ||
Effect.provide(SqlLive), | ||
Effect.tapErrorCause(Effect.logError), | ||
Effect.runFork | ||
) |
Oops, something went wrong.