@effect/sql-mssql 4.0.0-beta.7 → 4.0.0-beta.71
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/MssqlClient.d.ts +71 -15
- package/dist/MssqlClient.d.ts.map +1 -1
- package/dist/MssqlClient.js +164 -37
- package/dist/MssqlClient.js.map +1 -1
- package/dist/MssqlMigrator.d.ts +30 -5
- package/dist/MssqlMigrator.d.ts.map +1 -1
- package/dist/MssqlMigrator.js +8 -4
- package/dist/MssqlMigrator.js.map +1 -1
- package/dist/Parameter.d.ts +14 -6
- package/dist/Parameter.d.ts.map +1 -1
- package/dist/Parameter.js +43 -4
- package/dist/Parameter.js.map +1 -1
- package/dist/Procedure.d.ts +41 -16
- package/dist/Procedure.d.ts.map +1 -1
- package/dist/Procedure.js +51 -8
- package/dist/Procedure.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/package.json +4 -4
- package/src/MssqlClient.ts +231 -36
- package/src/MssqlMigrator.ts +30 -5
- package/src/Parameter.ts +50 -7
- package/src/Procedure.ts +74 -18
- package/src/index.ts +6 -6
package/src/Procedure.ts
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Typed metadata builders for Microsoft SQL Server stored procedure calls.
|
|
3
|
+
*
|
|
4
|
+
* This module defines the `Procedure` values consumed by `MssqlClient.call`.
|
|
5
|
+
* Use it when application code invokes SQL Server stored procedures for
|
|
6
|
+
* commands, reports, migrations, or workflows that need explicit Tedious
|
|
7
|
+
* parameter metadata, output parameters, and typed result rows.
|
|
8
|
+
*
|
|
9
|
+
* **Mental model**
|
|
10
|
+
*
|
|
11
|
+
* A `Procedure` is a typed description, not an executable request. Start with
|
|
12
|
+
* `make`, add input parameters with `param` and output parameters with
|
|
13
|
+
* `outputParam`, optionally attach the expected row type with `withRows`, and
|
|
14
|
+
* finish with `compile` to bind the input value record. `MssqlClient.call`
|
|
15
|
+
* turns the compiled value into a Tedious request, registers output parameters,
|
|
16
|
+
* and returns output values separately from returned rows.
|
|
17
|
+
*
|
|
18
|
+
* **Common tasks**
|
|
19
|
+
*
|
|
20
|
+
* Use `param<A>()` for every input parameter whose value should appear in the
|
|
21
|
+
* record passed to `compile`, and `outputParam<A>()` for values collected from
|
|
22
|
+
* SQL Server `returnValue` events. Use `withRows<A>()` when the procedure
|
|
23
|
+
* returns a result set and callers should see a typed row array.
|
|
24
|
+
*
|
|
25
|
+
* **Gotchas**
|
|
26
|
+
*
|
|
27
|
+
* The generic type arguments are supplied explicitly; they are not inferred from
|
|
28
|
+
* Tedious `DataType`s or `ParameterOptions`. Parameter names should match the
|
|
29
|
+
* stored procedure parameter names used by Tedious, typically without a leading
|
|
30
|
+
* `@`. `withRows` records only the expected TypeScript row type; runtime row
|
|
31
|
+
* names and transforms still follow the configured `MssqlClient`.
|
|
32
|
+
*
|
|
33
|
+
* @since 4.0.0
|
|
3
34
|
*/
|
|
4
35
|
import { identity } from "effect/Function"
|
|
5
36
|
import type { Pipeable } from "effect/Pipeable"
|
|
@@ -11,20 +42,26 @@ import type { ParameterOptions } from "tedious/lib/request.ts"
|
|
|
11
42
|
import * as Parameter from "./Parameter.ts"
|
|
12
43
|
|
|
13
44
|
/**
|
|
45
|
+
* Runtime type identifier used to mark SQL Server stored procedure definitions.
|
|
46
|
+
*
|
|
14
47
|
* @category type id
|
|
15
|
-
* @since
|
|
48
|
+
* @since 4.0.0
|
|
16
49
|
*/
|
|
17
50
|
export const TypeId: TypeId = "~@effect/sql-mssql/Procedure"
|
|
18
51
|
|
|
19
52
|
/**
|
|
53
|
+
* Type-level identifier used to mark SQL Server stored procedure definitions.
|
|
54
|
+
*
|
|
20
55
|
* @category type id
|
|
21
|
-
* @since
|
|
56
|
+
* @since 4.0.0
|
|
22
57
|
*/
|
|
23
58
|
export type TypeId = "~@effect/sql-mssql/Procedure"
|
|
24
59
|
|
|
25
60
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
61
|
+
* Pipeable definition of a SQL Server stored procedure, tracking its input parameters, output parameters, and result row type.
|
|
62
|
+
*
|
|
63
|
+
* @category models
|
|
64
|
+
* @since 4.0.0
|
|
28
65
|
*/
|
|
29
66
|
export interface Procedure<
|
|
30
67
|
I extends Record<string, Parameter.Parameter<any>>,
|
|
@@ -41,8 +78,10 @@ export interface Procedure<
|
|
|
41
78
|
}
|
|
42
79
|
|
|
43
80
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
81
|
+
* Stored procedure definition with concrete input values bound for execution.
|
|
82
|
+
*
|
|
83
|
+
* @category models
|
|
84
|
+
* @since 4.0.0
|
|
46
85
|
*/
|
|
47
86
|
export interface ProcedureWithValues<
|
|
48
87
|
I extends Record<string, Parameter.Parameter<any>>,
|
|
@@ -53,11 +92,16 @@ export interface ProcedureWithValues<
|
|
|
53
92
|
}
|
|
54
93
|
|
|
55
94
|
/**
|
|
56
|
-
*
|
|
95
|
+
* Namespace containing type helpers and result types for SQL Server stored procedures.
|
|
96
|
+
*
|
|
97
|
+
* @since 4.0.0
|
|
57
98
|
*/
|
|
58
|
-
export namespace Procedure {
|
|
99
|
+
export declare namespace Procedure {
|
|
59
100
|
/**
|
|
60
|
-
*
|
|
101
|
+
* Maps a record of `Parameter` metadata to the corresponding record of parameter value types.
|
|
102
|
+
*
|
|
103
|
+
* @category utility types
|
|
104
|
+
* @since 4.0.0
|
|
61
105
|
*/
|
|
62
106
|
export type ParametersRecord<
|
|
63
107
|
A extends Record<string, Parameter.Parameter<any>>
|
|
@@ -69,8 +113,10 @@ export namespace Procedure {
|
|
|
69
113
|
& {}
|
|
70
114
|
|
|
71
115
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
116
|
+
* Result of a SQL Server stored procedure call, containing typed output parameter values and returned rows.
|
|
117
|
+
*
|
|
118
|
+
* @category models
|
|
119
|
+
* @since 4.0.0
|
|
74
120
|
*/
|
|
75
121
|
export interface Result<
|
|
76
122
|
O extends Record<string, Parameter.Parameter<any>>,
|
|
@@ -94,8 +140,10 @@ const procedureProto = {
|
|
|
94
140
|
}
|
|
95
141
|
|
|
96
142
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
143
|
+
* Creates an empty SQL Server stored procedure definition for the given procedure name.
|
|
144
|
+
*
|
|
145
|
+
* @category constructors
|
|
146
|
+
* @since 4.0.0
|
|
99
147
|
*/
|
|
100
148
|
export const make = (name: string): Procedure<{}, {}> => {
|
|
101
149
|
const procedure = Object.create(procedureProto)
|
|
@@ -106,8 +154,10 @@ export const make = (name: string): Procedure<{}, {}> => {
|
|
|
106
154
|
}
|
|
107
155
|
|
|
108
156
|
/**
|
|
157
|
+
* Adds a typed input parameter to a SQL Server stored procedure definition.
|
|
158
|
+
*
|
|
109
159
|
* @category combinator
|
|
110
|
-
* @since
|
|
160
|
+
* @since 4.0.0
|
|
111
161
|
*/
|
|
112
162
|
export const param = <A>() =>
|
|
113
163
|
<N extends string, T extends DataType>(
|
|
@@ -129,8 +179,10 @@ export const param = <A>() =>
|
|
|
129
179
|
})
|
|
130
180
|
|
|
131
181
|
/**
|
|
182
|
+
* Adds a typed output parameter to a SQL Server stored procedure definition.
|
|
183
|
+
*
|
|
132
184
|
* @category combinator
|
|
133
|
-
* @since
|
|
185
|
+
* @since 4.0.0
|
|
134
186
|
*/
|
|
135
187
|
export const outputParam = <A>() =>
|
|
136
188
|
<N extends string, T extends DataType>(
|
|
@@ -152,8 +204,10 @@ export const outputParam = <A>() =>
|
|
|
152
204
|
})
|
|
153
205
|
|
|
154
206
|
/**
|
|
207
|
+
* Sets the expected row type for a SQL Server stored procedure definition.
|
|
208
|
+
*
|
|
155
209
|
* @category combinator
|
|
156
|
-
* @since
|
|
210
|
+
* @since 4.0.0
|
|
157
211
|
*/
|
|
158
212
|
export const withRows = <A extends object = Row>() =>
|
|
159
213
|
<
|
|
@@ -164,8 +218,10 @@ export const withRows = <A extends object = Row>() =>
|
|
|
164
218
|
): Procedure<I, O, A> => self as any
|
|
165
219
|
|
|
166
220
|
/**
|
|
221
|
+
* Binds input values to a SQL Server stored procedure definition, producing a value that can be executed with `MssqlClient.call`.
|
|
222
|
+
*
|
|
167
223
|
* @category combinator
|
|
168
|
-
* @since
|
|
224
|
+
* @since 4.0.0
|
|
169
225
|
*/
|
|
170
226
|
export const compile = <
|
|
171
227
|
I extends Record<string, Parameter.Parameter<any>>,
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @since
|
|
2
|
+
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
export {
|
|
6
6
|
/**
|
|
7
|
-
* @since
|
|
7
|
+
* @since 4.0.0
|
|
8
8
|
*/
|
|
9
9
|
TYPES as MssqlTypes
|
|
10
10
|
} from "tedious"
|
|
@@ -12,21 +12,21 @@ export {
|
|
|
12
12
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @since
|
|
15
|
+
* @since 4.0.0
|
|
16
16
|
*/
|
|
17
17
|
export * as MssqlClient from "./MssqlClient.ts"
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* @since
|
|
20
|
+
* @since 4.0.0
|
|
21
21
|
*/
|
|
22
22
|
export * as MssqlMigrator from "./MssqlMigrator.ts"
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* @since
|
|
25
|
+
* @since 4.0.0
|
|
26
26
|
*/
|
|
27
27
|
export * as Parameter from "./Parameter.ts"
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* @since
|
|
30
|
+
* @since 4.0.0
|
|
31
31
|
*/
|
|
32
32
|
export * as Procedure from "./Procedure.ts"
|