@effect/sql-mssql 0.50.0 → 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{dts/MssqlClient.d.ts → MssqlClient.d.ts} +13 -14
- package/dist/MssqlClient.d.ts.map +1 -0
- package/dist/{esm/MssqlClient.js → MssqlClient.js} +38 -34
- package/dist/MssqlClient.js.map +1 -0
- package/dist/{dts/MssqlMigrator.d.ts → MssqlMigrator.d.ts} +4 -8
- package/dist/MssqlMigrator.d.ts.map +1 -0
- package/dist/{esm/MssqlMigrator.js → MssqlMigrator.js} +2 -9
- package/dist/MssqlMigrator.js.map +1 -0
- package/dist/{dts/Parameter.d.ts → Parameter.d.ts} +6 -6
- package/dist/Parameter.d.ts.map +1 -0
- package/dist/{esm/Parameter.js → Parameter.js} +2 -2
- package/dist/Parameter.js.map +1 -0
- package/dist/{dts/Procedure.d.ts → Procedure.d.ts} +6 -9
- package/dist/Procedure.d.ts.map +1 -0
- package/dist/{esm/Procedure.js → Procedure.js} +4 -1
- package/dist/Procedure.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/{esm/index.js → index.js} +1 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -74
- package/src/MssqlClient.ts +61 -61
- package/src/MssqlMigrator.ts +4 -9
- package/src/Parameter.ts +7 -7
- package/src/Procedure.ts +6 -6
- package/src/index.ts +6 -4
- package/.index/package.json +0 -6
- package/MssqlClient/package.json +0 -6
- package/MssqlMigrator/package.json +0 -6
- package/Parameter/package.json +0 -6
- package/Procedure/package.json +0 -6
- package/dist/cjs/MssqlClient.js +0 -353
- package/dist/cjs/MssqlClient.js.map +0 -1
- package/dist/cjs/MssqlMigrator.js +0 -60
- package/dist/cjs/MssqlMigrator.js.map +0 -1
- package/dist/cjs/Parameter.js +0 -29
- package/dist/cjs/Parameter.js.map +0 -1
- package/dist/cjs/Procedure.js +0 -76
- package/dist/cjs/Procedure.js.map +0 -1
- package/dist/cjs/index.js +0 -24
- package/dist/cjs/index.js.map +0 -1
- package/dist/dts/MssqlClient.d.ts.map +0 -1
- package/dist/dts/MssqlMigrator.d.ts.map +0 -1
- package/dist/dts/Parameter.d.ts.map +0 -1
- package/dist/dts/Procedure.d.ts.map +0 -1
- package/dist/dts/index.d.ts +0 -25
- package/dist/dts/index.d.ts.map +0 -1
- package/dist/esm/MssqlClient.js.map +0 -1
- package/dist/esm/MssqlMigrator.js.map +0 -1
- package/dist/esm/Parameter.js.map +0 -1
- package/dist/esm/Procedure.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/package.json +0 -4
- package/index/package.json +0 -6
package/package.json
CHANGED
|
@@ -1,88 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/sql-mssql",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"description": "A Microsoft SQL Server toolkit for Effect",
|
|
7
|
+
"homepage": "https://effect.website",
|
|
6
8
|
"repository": {
|
|
7
9
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/Effect-TS/effect.git",
|
|
9
|
-
"directory": "packages/sql
|
|
10
|
+
"url": "https://github.com/Effect-TS/effect-smol.git",
|
|
11
|
+
"directory": "packages/sql/mssql"
|
|
10
12
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"dependencies": {
|
|
14
|
-
"tedious": "^18.3.0"
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Effect-TS/effect-smol/issues"
|
|
15
15
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
16
|
+
"tags": [
|
|
17
|
+
"typescript",
|
|
18
|
+
"sql",
|
|
19
|
+
"database"
|
|
20
|
+
],
|
|
21
|
+
"keywords": [
|
|
22
|
+
"typescript",
|
|
23
|
+
"sql",
|
|
24
|
+
"database"
|
|
25
|
+
],
|
|
26
|
+
"sideEffects": [],
|
|
27
|
+
"exports": {
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
".": "./dist/index.js",
|
|
30
|
+
"./*": "./dist/*.js",
|
|
31
|
+
"./internal/*": null,
|
|
32
|
+
"./*/index": null
|
|
21
33
|
},
|
|
34
|
+
"files": [
|
|
35
|
+
"src/**/*.ts",
|
|
36
|
+
"dist/**/*.js",
|
|
37
|
+
"dist/**/*.js.map",
|
|
38
|
+
"dist/**/*.d.ts",
|
|
39
|
+
"dist/**/*.d.ts.map"
|
|
40
|
+
],
|
|
22
41
|
"publishConfig": {
|
|
42
|
+
"access": "public",
|
|
23
43
|
"provenance": true
|
|
24
44
|
},
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"default": "./dist/cjs/index.js"
|
|
34
|
-
},
|
|
35
|
-
"./.index": {
|
|
36
|
-
"types": "./dist/dts/.index.d.ts",
|
|
37
|
-
"import": "./dist/esm/.index.js",
|
|
38
|
-
"default": "./dist/cjs/.index.js"
|
|
39
|
-
},
|
|
40
|
-
"./MssqlClient": {
|
|
41
|
-
"types": "./dist/dts/MssqlClient.d.ts",
|
|
42
|
-
"import": "./dist/esm/MssqlClient.js",
|
|
43
|
-
"default": "./dist/cjs/MssqlClient.js"
|
|
44
|
-
},
|
|
45
|
-
"./MssqlMigrator": {
|
|
46
|
-
"types": "./dist/dts/MssqlMigrator.d.ts",
|
|
47
|
-
"import": "./dist/esm/MssqlMigrator.js",
|
|
48
|
-
"default": "./dist/cjs/MssqlMigrator.js"
|
|
49
|
-
},
|
|
50
|
-
"./Parameter": {
|
|
51
|
-
"types": "./dist/dts/Parameter.d.ts",
|
|
52
|
-
"import": "./dist/esm/Parameter.js",
|
|
53
|
-
"default": "./dist/cjs/Parameter.js"
|
|
54
|
-
},
|
|
55
|
-
"./Procedure": {
|
|
56
|
-
"types": "./dist/dts/Procedure.d.ts",
|
|
57
|
-
"import": "./dist/esm/Procedure.js",
|
|
58
|
-
"default": "./dist/cjs/Procedure.js"
|
|
59
|
-
},
|
|
60
|
-
"./index": {
|
|
61
|
-
"types": "./dist/dts/index.d.ts",
|
|
62
|
-
"import": "./dist/esm/index.js",
|
|
63
|
-
"default": "./dist/cjs/index.js"
|
|
64
|
-
}
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"effect": "^4.0.0-beta.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"effect": "^4.0.0-beta.0"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"tedious": "^19.2.0"
|
|
65
53
|
},
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"MssqlMigrator": [
|
|
75
|
-
"./dist/dts/MssqlMigrator.d.ts"
|
|
76
|
-
],
|
|
77
|
-
"Parameter": [
|
|
78
|
-
"./dist/dts/Parameter.d.ts"
|
|
79
|
-
],
|
|
80
|
-
"Procedure": [
|
|
81
|
-
"./dist/dts/Procedure.d.ts"
|
|
82
|
-
],
|
|
83
|
-
"index": [
|
|
84
|
-
"./dist/dts/index.d.ts"
|
|
85
|
-
]
|
|
86
|
-
}
|
|
54
|
+
"scripts": {
|
|
55
|
+
"codegen": "effect-utils codegen",
|
|
56
|
+
"build": "tsc -b tsconfig.json && pnpm babel",
|
|
57
|
+
"build:tsgo": "tsgo -b tsconfig.json && pnpm babel",
|
|
58
|
+
"babel": "babel dist --plugins annotate-pure-calls --out-dir dist --source-maps",
|
|
59
|
+
"check": "tsc -b tsconfig.json",
|
|
60
|
+
"test": "vitest",
|
|
61
|
+
"coverage": "vitest --coverage"
|
|
87
62
|
}
|
|
88
63
|
}
|
package/src/MssqlClient.ts
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import * as Reactivity from "@effect/experimental/Reactivity"
|
|
5
|
-
import * as Client from "@effect/sql/SqlClient"
|
|
6
|
-
import type { Connection } from "@effect/sql/SqlConnection"
|
|
7
|
-
import { SqlError } from "@effect/sql/SqlError"
|
|
8
|
-
import * as Statement from "@effect/sql/Statement"
|
|
9
4
|
import * as Config from "effect/Config"
|
|
10
|
-
import type { ConfigError } from "effect/ConfigError"
|
|
11
|
-
import * as Context from "effect/Context"
|
|
12
5
|
import * as Duration from "effect/Duration"
|
|
13
6
|
import * as Effect from "effect/Effect"
|
|
14
7
|
import { identity } from "effect/Function"
|
|
@@ -16,12 +9,19 @@ import * as Layer from "effect/Layer"
|
|
|
16
9
|
import * as Pool from "effect/Pool"
|
|
17
10
|
import * as Redacted from "effect/Redacted"
|
|
18
11
|
import * as Scope from "effect/Scope"
|
|
12
|
+
import * as ServiceMap from "effect/ServiceMap"
|
|
13
|
+
import * as Stream from "effect/Stream"
|
|
14
|
+
import * as Reactivity from "effect/unstable/reactivity/Reactivity"
|
|
15
|
+
import * as Client from "effect/unstable/sql/SqlClient"
|
|
16
|
+
import type { Connection } from "effect/unstable/sql/SqlConnection"
|
|
17
|
+
import { SqlError } from "effect/unstable/sql/SqlError"
|
|
18
|
+
import * as Statement from "effect/unstable/sql/Statement"
|
|
19
19
|
import * as Tedious from "tedious"
|
|
20
|
-
import type { ConnectionOptions } from "tedious/lib/connection.
|
|
21
|
-
import type { DataType } from "tedious/lib/data-type.
|
|
22
|
-
import type { ParameterOptions } from "tedious/lib/request.
|
|
23
|
-
import type { Parameter } from "./Parameter.
|
|
24
|
-
import type * as Procedure from "./Procedure.
|
|
20
|
+
import type { ConnectionOptions } from "tedious/lib/connection.ts"
|
|
21
|
+
import type { DataType } from "tedious/lib/data-type.ts"
|
|
22
|
+
import type { ParameterOptions } from "tedious/lib/request.ts"
|
|
23
|
+
import type { Parameter } from "./Parameter.ts"
|
|
24
|
+
import type * as Procedure from "./Procedure.ts"
|
|
25
25
|
|
|
26
26
|
const ATTR_DB_SYSTEM_NAME = "db.system.name"
|
|
27
27
|
const ATTR_DB_NAMESPACE = "db.namespace"
|
|
@@ -68,7 +68,7 @@ export interface MssqlClient extends Client.SqlClient {
|
|
|
68
68
|
* @category tags
|
|
69
69
|
* @since 1.0.0
|
|
70
70
|
*/
|
|
71
|
-
export const MssqlClient =
|
|
71
|
+
export const MssqlClient = ServiceMap.Service<MssqlClient>("@effect/sql-mssql/MssqlClient")
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* @category models
|
|
@@ -91,7 +91,7 @@ export interface MssqlClientConfig {
|
|
|
91
91
|
readonly maxConnections?: number | undefined
|
|
92
92
|
readonly connectionTTL?: Duration.DurationInput | undefined
|
|
93
93
|
|
|
94
|
-
readonly parameterTypes?: Record<
|
|
94
|
+
readonly parameterTypes?: Record<Statement.PrimitiveKind, DataType> | undefined
|
|
95
95
|
|
|
96
96
|
readonly spanAttributes?: Record<string, unknown> | undefined
|
|
97
97
|
|
|
@@ -111,7 +111,7 @@ interface MssqlConnection extends Connection {
|
|
|
111
111
|
readonly rollback: (name?: string) => Effect.Effect<void, SqlError>
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
const TransactionConnection = Client.TransactionConnection as unknown as
|
|
114
|
+
const TransactionConnection = Client.TransactionConnection as unknown as ServiceMap.Service<
|
|
115
115
|
readonly [conn: MssqlConnection, counter: number],
|
|
116
116
|
readonly [conn: MssqlConnection, counter: number]
|
|
117
117
|
>
|
|
@@ -140,7 +140,7 @@ export const make = (
|
|
|
140
140
|
[ATTR_SERVER_PORT, options.port ?? 1433]
|
|
141
141
|
]
|
|
142
142
|
|
|
143
|
-
//
|
|
143
|
+
// oxlint-disable-next-line prefer-const
|
|
144
144
|
let pool: Pool.Pool<MssqlConnection, SqlError>
|
|
145
145
|
|
|
146
146
|
const makeConnection = Effect.gen(function*() {
|
|
@@ -150,7 +150,7 @@ export const make = (
|
|
|
150
150
|
database: options.database,
|
|
151
151
|
trustServerCertificate: options.trustServer ?? true,
|
|
152
152
|
connectTimeout: options.connectTimeout
|
|
153
|
-
? Duration.toMillis(Duration.
|
|
153
|
+
? Duration.toMillis(Duration.fromDurationInputUnsafe(options.connectTimeout))
|
|
154
154
|
: undefined,
|
|
155
155
|
rowCollectionOnRequestCompletion: true,
|
|
156
156
|
useColumnNames: false,
|
|
@@ -171,7 +171,7 @@ export const make = (
|
|
|
171
171
|
|
|
172
172
|
yield* Effect.addFinalizer(() => Effect.sync(() => conn.close()))
|
|
173
173
|
|
|
174
|
-
yield* Effect.
|
|
174
|
+
yield* Effect.callback<void, SqlError>((resume) => {
|
|
175
175
|
conn.connect((cause) => {
|
|
176
176
|
if (cause) {
|
|
177
177
|
resume(Effect.fail(new SqlError({ cause, message: "Failed to connect" })))
|
|
@@ -186,7 +186,7 @@ export const make = (
|
|
|
186
186
|
values?: ReadonlyArray<any>,
|
|
187
187
|
rowsAsArray = false
|
|
188
188
|
) =>
|
|
189
|
-
Effect.
|
|
189
|
+
Effect.callback<any, SqlError>((resume) => {
|
|
190
190
|
const req = new Tedious.Request(sql, (cause, _rowCount, result) => {
|
|
191
191
|
if (cause) {
|
|
192
192
|
resume(Effect.fail(new SqlError({ cause, message: "Failed to execute statement" })))
|
|
@@ -208,7 +208,7 @@ export const make = (
|
|
|
208
208
|
const name = numberToParamName(i)
|
|
209
209
|
|
|
210
210
|
if (isMssqlParam(value)) {
|
|
211
|
-
req.addParameter(name, value.
|
|
211
|
+
req.addParameter(name, value.paramA, value.paramB, value.paramC)
|
|
212
212
|
} else {
|
|
213
213
|
const kind = Statement.primitiveKind(value)
|
|
214
214
|
const type = parameterTypes[kind]
|
|
@@ -225,7 +225,7 @@ export const make = (
|
|
|
225
225
|
procedure: Procedure.ProcedureWithValues<any, any, any>,
|
|
226
226
|
transformRows: ((rows: ReadonlyArray<any>) => ReadonlyArray<any>) | undefined
|
|
227
227
|
) =>
|
|
228
|
-
Effect.
|
|
228
|
+
Effect.callback<any, SqlError>((resume) => {
|
|
229
229
|
const result: Record<string, any> = {}
|
|
230
230
|
|
|
231
231
|
const req = new Tedious.Request(
|
|
@@ -283,12 +283,12 @@ export const make = (
|
|
|
283
283
|
return this.execute(sql, params, transformRows)
|
|
284
284
|
},
|
|
285
285
|
executeStream() {
|
|
286
|
-
return
|
|
286
|
+
return Stream.die("executeStream not implemented")
|
|
287
287
|
},
|
|
288
288
|
call(procedure, transformRows) {
|
|
289
289
|
return runProcedure(procedure, transformRows)
|
|
290
290
|
},
|
|
291
|
-
begin: Effect.
|
|
291
|
+
begin: Effect.callback<void, SqlError>((resume) => {
|
|
292
292
|
conn.beginTransaction((cause) => {
|
|
293
293
|
if (cause) {
|
|
294
294
|
resume(Effect.fail(new SqlError({ cause, message: "Failed to begin transaction" })))
|
|
@@ -297,7 +297,7 @@ export const make = (
|
|
|
297
297
|
}
|
|
298
298
|
})
|
|
299
299
|
}),
|
|
300
|
-
commit: Effect.
|
|
300
|
+
commit: Effect.callback<void, SqlError>((resume) => {
|
|
301
301
|
conn.commitTransaction((cause) => {
|
|
302
302
|
if (cause) {
|
|
303
303
|
resume(Effect.fail(new SqlError({ cause, message: "Failed to commit transaction" })))
|
|
@@ -307,7 +307,7 @@ export const make = (
|
|
|
307
307
|
})
|
|
308
308
|
}),
|
|
309
309
|
savepoint: (name: string) =>
|
|
310
|
-
Effect.
|
|
310
|
+
Effect.callback<void, SqlError>((resume) => {
|
|
311
311
|
conn.saveTransaction((cause) => {
|
|
312
312
|
if (cause) {
|
|
313
313
|
resume(Effect.fail(new SqlError({ cause, message: "Failed to create savepoint" })))
|
|
@@ -317,7 +317,7 @@ export const make = (
|
|
|
317
317
|
}, name)
|
|
318
318
|
}),
|
|
319
319
|
rollback: (name?: string) =>
|
|
320
|
-
Effect.
|
|
320
|
+
Effect.callback<void, SqlError>((resume) => {
|
|
321
321
|
conn.rollbackTransaction((cause) => {
|
|
322
322
|
if (cause) {
|
|
323
323
|
resume(Effect.fail(new SqlError({ cause, message: "Failed to rollback transaction" })))
|
|
@@ -328,10 +328,10 @@ export const make = (
|
|
|
328
328
|
})
|
|
329
329
|
})
|
|
330
330
|
|
|
331
|
-
yield* Effect.
|
|
331
|
+
yield* Effect.callback<never, unknown>((resume) => {
|
|
332
332
|
conn.on("error", (_) => resume(Effect.fail(_)))
|
|
333
333
|
}).pipe(
|
|
334
|
-
Effect.
|
|
334
|
+
Effect.catch(() => Pool.invalidate(pool, connection)),
|
|
335
335
|
Effect.interruptible,
|
|
336
336
|
Effect.forkScoped
|
|
337
337
|
)
|
|
@@ -347,31 +347,30 @@ export const make = (
|
|
|
347
347
|
timeToLiveStrategy: "creation"
|
|
348
348
|
})
|
|
349
349
|
|
|
350
|
-
yield*
|
|
350
|
+
yield* Pool.get(pool).pipe(
|
|
351
351
|
Effect.tap((connection) => connection.executeUnprepared("SELECT 1", [], undefined)),
|
|
352
352
|
Effect.mapError(({ cause }) => new SqlError({ cause, message: "MssqlClient: Failed to connect" })),
|
|
353
353
|
Effect.scoped,
|
|
354
|
-
Effect.
|
|
354
|
+
Effect.timeoutOrElse({
|
|
355
355
|
duration: options.connectTimeout ?? Duration.seconds(5),
|
|
356
356
|
onTimeout: () =>
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
357
|
+
Effect.fail(
|
|
358
|
+
new SqlError({
|
|
359
|
+
message: "MssqlClient: Connection timeout",
|
|
360
|
+
cause: new Error("connection timeout")
|
|
361
|
+
})
|
|
362
|
+
)
|
|
361
363
|
})
|
|
362
364
|
)
|
|
363
365
|
|
|
364
366
|
const withTransaction = Client.makeWithTransaction({
|
|
365
|
-
|
|
367
|
+
transactionService: TransactionConnection,
|
|
366
368
|
spanAttributes,
|
|
367
|
-
acquireConnection: Effect.
|
|
368
|
-
Scope.
|
|
369
|
-
(scope)
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
(conn) => [scope, conn] as const
|
|
373
|
-
)
|
|
374
|
-
),
|
|
369
|
+
acquireConnection: Effect.gen(function*() {
|
|
370
|
+
const scope = Scope.makeUnsafe()
|
|
371
|
+
const conn = yield* Scope.provide(Pool.get(pool), scope)
|
|
372
|
+
return [scope, conn] as const
|
|
373
|
+
}),
|
|
375
374
|
begin: (conn) => conn.begin,
|
|
376
375
|
savepoint: (conn, id) => conn.savepoint(`effect_sql_${id}`),
|
|
377
376
|
commit: (conn) => conn.commit,
|
|
@@ -381,7 +380,7 @@ export const make = (
|
|
|
381
380
|
|
|
382
381
|
return identity<MssqlClient>(Object.assign(
|
|
383
382
|
yield* Client.make({
|
|
384
|
-
acquirer:
|
|
383
|
+
acquirer: Pool.get(pool),
|
|
385
384
|
compiler,
|
|
386
385
|
spanAttributes,
|
|
387
386
|
transformRows
|
|
@@ -394,16 +393,16 @@ export const make = (
|
|
|
394
393
|
type: DataType,
|
|
395
394
|
value: unknown,
|
|
396
395
|
options: ParameterOptions = {}
|
|
397
|
-
) => mssqlParam(type, value, options),
|
|
396
|
+
) => Statement.fragment([mssqlParam(type, value, options)]),
|
|
398
397
|
call: <
|
|
399
398
|
I extends Record<string, Parameter<any>>,
|
|
400
399
|
O extends Record<string, Parameter<any>>,
|
|
401
400
|
A
|
|
402
401
|
>(
|
|
403
402
|
procedure: Procedure.ProcedureWithValues<I, O, A>
|
|
404
|
-
) => Effect.scoped(Effect.flatMap(
|
|
403
|
+
) => Effect.scoped(Effect.flatMap(Pool.get(pool), (_) => _.call(procedure, transformRows))),
|
|
405
404
|
withoutTransforms() {
|
|
406
|
-
const statement = Statement.make(
|
|
405
|
+
const statement = Statement.make(Pool.get(pool), compiler.withoutTransform, spanAttributes, undefined)
|
|
407
406
|
const client = Object.assign(
|
|
408
407
|
statement,
|
|
409
408
|
this,
|
|
@@ -415,7 +414,7 @@ export const make = (
|
|
|
415
414
|
A
|
|
416
415
|
>(
|
|
417
416
|
procedure: Procedure.ProcedureWithValues<I, O, A>
|
|
418
|
-
) => Effect.scoped(Effect.flatMap(
|
|
417
|
+
) => Effect.scoped(Effect.flatMap(Pool.get(pool), (_) => _.call(procedure, undefined)))
|
|
419
418
|
}
|
|
420
419
|
)
|
|
421
420
|
;(client as any).safe = client
|
|
@@ -430,15 +429,17 @@ export const make = (
|
|
|
430
429
|
* @category layers
|
|
431
430
|
* @since 1.0.0
|
|
432
431
|
*/
|
|
433
|
-
export const layerConfig
|
|
434
|
-
config: Config.
|
|
435
|
-
)
|
|
436
|
-
|
|
437
|
-
|
|
432
|
+
export const layerConfig: (
|
|
433
|
+
config: Config.Wrap<MssqlClientConfig>
|
|
434
|
+
) => Layer.Layer<Client.SqlClient | MssqlClient, Config.ConfigError | SqlError> = (
|
|
435
|
+
config: Config.Wrap<MssqlClientConfig>
|
|
436
|
+
): Layer.Layer<Client.SqlClient | MssqlClient, Config.ConfigError | SqlError> =>
|
|
437
|
+
Layer.effectServices(
|
|
438
|
+
Config.unwrap(config).asEffect().pipe(
|
|
438
439
|
Effect.flatMap(make),
|
|
439
440
|
Effect.map((client) =>
|
|
440
|
-
|
|
441
|
-
|
|
441
|
+
ServiceMap.make(MssqlClient, client).pipe(
|
|
442
|
+
ServiceMap.add(Client.SqlClient, client)
|
|
442
443
|
)
|
|
443
444
|
)
|
|
444
445
|
)
|
|
@@ -450,11 +451,11 @@ export const layerConfig = (
|
|
|
450
451
|
*/
|
|
451
452
|
export const layer = (
|
|
452
453
|
config: MssqlClientConfig
|
|
453
|
-
): Layer.Layer<Client.SqlClient | MssqlClient,
|
|
454
|
-
Layer.
|
|
454
|
+
): Layer.Layer<Client.SqlClient | MssqlClient, never | SqlError> =>
|
|
455
|
+
Layer.effectServices(
|
|
455
456
|
Effect.map(make(config), (client) =>
|
|
456
|
-
|
|
457
|
-
|
|
457
|
+
ServiceMap.make(MssqlClient, client).pipe(
|
|
458
|
+
ServiceMap.add(Client.SqlClient, client)
|
|
458
459
|
))
|
|
459
460
|
).pipe(Layer.provide(Reactivity.layer))
|
|
460
461
|
|
|
@@ -519,8 +520,7 @@ export const defaultParameterTypes: Record<Statement.PrimitiveKind, DataType> =
|
|
|
519
520
|
Date: Tedious.TYPES.DateTime,
|
|
520
521
|
Uint8Array: Tedious.TYPES.VarBinary,
|
|
521
522
|
Int8Array: Tedious.TYPES.VarBinary,
|
|
522
|
-
null: Tedious.TYPES.Bit
|
|
523
|
-
object: Tedious.TYPES.NVarChar
|
|
523
|
+
null: Tedious.TYPES.Bit
|
|
524
524
|
}
|
|
525
525
|
|
|
526
526
|
// custom types
|
package/src/MssqlMigrator.ts
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import * as Migrator from "@effect/sql/Migrator"
|
|
5
|
-
import type * as Client from "@effect/sql/SqlClient"
|
|
6
|
-
import type { SqlError } from "@effect/sql/SqlError"
|
|
7
4
|
import type * as Effect from "effect/Effect"
|
|
8
5
|
import * as Layer from "effect/Layer"
|
|
6
|
+
import * as Migrator from "effect/unstable/sql/Migrator"
|
|
7
|
+
import type * as Client from "effect/unstable/sql/SqlClient"
|
|
8
|
+
import type { SqlError } from "effect/unstable/sql/SqlError"
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @since 1.0.0
|
|
12
12
|
*/
|
|
13
|
-
export * from "
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @since 1.0.0
|
|
17
|
-
*/
|
|
18
|
-
export * from "@effect/sql/Migrator/FileSystem"
|
|
13
|
+
export * from "effect/unstable/sql/Migrator"
|
|
19
14
|
|
|
20
15
|
/**
|
|
21
16
|
* @category constructor
|
package/src/Parameter.ts
CHANGED
|
@@ -2,27 +2,27 @@
|
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
4
|
import { identity } from "effect/Function"
|
|
5
|
-
import type { DataType } from "tedious/lib/data-type.
|
|
6
|
-
import type { ParameterOptions } from "tedious/lib/request.
|
|
5
|
+
import type { DataType } from "tedious/lib/data-type.ts"
|
|
6
|
+
import type { ParameterOptions } from "tedious/lib/request.ts"
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @category type id
|
|
10
10
|
* @since 1.0.0
|
|
11
11
|
*/
|
|
12
|
-
export const
|
|
12
|
+
export const TypeId: TypeId = "~@effect/sql-mssql/Parameter"
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @category type id
|
|
16
16
|
* @since 1.0.0
|
|
17
17
|
*/
|
|
18
|
-
export type
|
|
18
|
+
export type TypeId = "~@effect/sql-mssql/Parameter"
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* @category model
|
|
22
22
|
* @since 1.0.0
|
|
23
23
|
*/
|
|
24
|
-
export interface Parameter<A> {
|
|
25
|
-
readonly [
|
|
24
|
+
export interface Parameter<out A> {
|
|
25
|
+
readonly [TypeId]: (_: never) => A
|
|
26
26
|
readonly _tag: "Parameter"
|
|
27
27
|
readonly name: string
|
|
28
28
|
readonly type: DataType
|
|
@@ -38,7 +38,7 @@ export const make = <A>(
|
|
|
38
38
|
type: DataType,
|
|
39
39
|
options: ParameterOptions = {}
|
|
40
40
|
): Parameter<A> => ({
|
|
41
|
-
[
|
|
41
|
+
[TypeId]: identity,
|
|
42
42
|
_tag: "Parameter",
|
|
43
43
|
name,
|
|
44
44
|
type,
|
package/src/Procedure.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import type { Row } from "@effect/sql/SqlConnection"
|
|
5
4
|
import { identity } from "effect/Function"
|
|
6
5
|
import type { Pipeable } from "effect/Pipeable"
|
|
7
6
|
import { pipeArguments } from "effect/Pipeable"
|
|
8
7
|
import type { Covariant } from "effect/Types"
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import
|
|
8
|
+
import type { Row } from "effect/unstable/sql/SqlConnection"
|
|
9
|
+
import type { DataType } from "tedious/lib/data-type.ts"
|
|
10
|
+
import type { ParameterOptions } from "tedious/lib/request.ts"
|
|
11
|
+
import * as Parameter from "./Parameter.ts"
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @category type id
|
|
15
15
|
* @since 1.0.0
|
|
16
16
|
*/
|
|
17
|
-
export const TypeId:
|
|
17
|
+
export const TypeId: TypeId = "~@effect/sql-mssql/Procedure"
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @category type id
|
|
21
21
|
* @since 1.0.0
|
|
22
22
|
*/
|
|
23
|
-
export type TypeId =
|
|
23
|
+
export type TypeId = "~@effect/sql-mssql/Procedure"
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* @category model
|
package/src/index.ts
CHANGED
|
@@ -9,22 +9,24 @@ export {
|
|
|
9
9
|
TYPES as MssqlTypes
|
|
10
10
|
} from "tedious"
|
|
11
11
|
|
|
12
|
+
// @barrel: Auto-generated exports. Do not edit manually.
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* @since 1.0.0
|
|
14
16
|
*/
|
|
15
|
-
export * as MssqlClient from "./MssqlClient.
|
|
17
|
+
export * as MssqlClient from "./MssqlClient.ts"
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* @since 1.0.0
|
|
19
21
|
*/
|
|
20
|
-
export * as MssqlMigrator from "./MssqlMigrator.
|
|
22
|
+
export * as MssqlMigrator from "./MssqlMigrator.ts"
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
25
|
* @since 1.0.0
|
|
24
26
|
*/
|
|
25
|
-
export * as Parameter from "./Parameter.
|
|
27
|
+
export * as Parameter from "./Parameter.ts"
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
30
|
* @since 1.0.0
|
|
29
31
|
*/
|
|
30
|
-
export * as Procedure from "./Procedure.
|
|
32
|
+
export * as Procedure from "./Procedure.ts"
|
package/.index/package.json
DELETED
package/MssqlClient/package.json
DELETED
package/Parameter/package.json
DELETED