@effect/sql-mssql 4.0.0-beta.65 → 4.0.0-beta.67
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 +57 -11
- package/dist/MssqlClient.d.ts.map +1 -1
- package/dist/MssqlClient.js +49 -9
- package/dist/MssqlClient.js.map +1 -1
- package/dist/MssqlMigrator.d.ts +29 -4
- package/dist/MssqlMigrator.d.ts.map +1 -1
- package/dist/MssqlMigrator.js +7 -3
- package/dist/MssqlMigrator.js.map +1 -1
- package/dist/Parameter.d.ts +12 -4
- package/dist/Parameter.d.ts.map +1 -1
- package/dist/Parameter.js +27 -3
- package/dist/Parameter.js.map +1 -1
- package/dist/Procedure.d.ts +36 -12
- package/dist/Procedure.d.ts.map +1 -1
- package/dist/Procedure.js +36 -7
- package/dist/Procedure.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/package.json +3 -3
- package/src/MssqlClient.ts +58 -12
- package/src/MssqlMigrator.ts +29 -4
- package/src/Parameter.ts +33 -5
- package/src/Procedure.ts +54 -13
- package/src/index.ts +6 -6
package/src/Procedure.ts
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Typed builders for Microsoft SQL Server stored procedure definitions.
|
|
3
|
+
*
|
|
4
|
+
* This module describes the metadata consumed by `MssqlClient.call`: create a
|
|
5
|
+
* definition with `make`, add input and output parameters with their Tedious
|
|
6
|
+
* data types and `ParameterOptions`, optionally describe the returned row shape
|
|
7
|
+
* with `withRows`, and use `compile` to bind the input values before execution.
|
|
8
|
+
* It is useful when application code calls stored procedures for commands,
|
|
9
|
+
* reports, migrations, or workflows that return both result sets and output
|
|
10
|
+
* parameters.
|
|
11
|
+
*
|
|
12
|
+
* Parameter value types are supplied explicitly through `param<A>()` and
|
|
13
|
+
* `outputParam<A>()`; they are not inferred from the Tedious data type. Input
|
|
14
|
+
* values must be keyed by the parameter names in the definition, output
|
|
15
|
+
* parameters are collected separately from returned rows, and `withRows` only
|
|
16
|
+
* records the expected TypeScript row type, so row names and transforms still
|
|
17
|
+
* follow the configured `MssqlClient` result handling.
|
|
18
|
+
*
|
|
19
|
+
* @since 4.0.0
|
|
3
20
|
*/
|
|
4
21
|
import { identity } from "effect/Function"
|
|
5
22
|
import type { Pipeable } from "effect/Pipeable"
|
|
@@ -11,20 +28,26 @@ import type { ParameterOptions } from "tedious/lib/request.ts"
|
|
|
11
28
|
import * as Parameter from "./Parameter.ts"
|
|
12
29
|
|
|
13
30
|
/**
|
|
31
|
+
* Runtime type identifier used to mark SQL Server stored procedure definitions.
|
|
32
|
+
*
|
|
14
33
|
* @category type id
|
|
15
|
-
* @since
|
|
34
|
+
* @since 4.0.0
|
|
16
35
|
*/
|
|
17
36
|
export const TypeId: TypeId = "~@effect/sql-mssql/Procedure"
|
|
18
37
|
|
|
19
38
|
/**
|
|
39
|
+
* Type-level identifier used to mark SQL Server stored procedure definitions.
|
|
40
|
+
*
|
|
20
41
|
* @category type id
|
|
21
|
-
* @since
|
|
42
|
+
* @since 4.0.0
|
|
22
43
|
*/
|
|
23
44
|
export type TypeId = "~@effect/sql-mssql/Procedure"
|
|
24
45
|
|
|
25
46
|
/**
|
|
47
|
+
* Pipeable definition of a SQL Server stored procedure, tracking its input parameters, output parameters, and result row type.
|
|
48
|
+
*
|
|
26
49
|
* @category model
|
|
27
|
-
* @since
|
|
50
|
+
* @since 4.0.0
|
|
28
51
|
*/
|
|
29
52
|
export interface Procedure<
|
|
30
53
|
I extends Record<string, Parameter.Parameter<any>>,
|
|
@@ -41,8 +64,10 @@ export interface Procedure<
|
|
|
41
64
|
}
|
|
42
65
|
|
|
43
66
|
/**
|
|
67
|
+
* Stored procedure definition with concrete input values bound for execution.
|
|
68
|
+
*
|
|
44
69
|
* @category model
|
|
45
|
-
* @since
|
|
70
|
+
* @since 4.0.0
|
|
46
71
|
*/
|
|
47
72
|
export interface ProcedureWithValues<
|
|
48
73
|
I extends Record<string, Parameter.Parameter<any>>,
|
|
@@ -53,11 +78,15 @@ export interface ProcedureWithValues<
|
|
|
53
78
|
}
|
|
54
79
|
|
|
55
80
|
/**
|
|
56
|
-
*
|
|
81
|
+
* Namespace containing type helpers and result types for SQL Server stored procedures.
|
|
82
|
+
*
|
|
83
|
+
* @since 4.0.0
|
|
57
84
|
*/
|
|
58
85
|
export namespace Procedure {
|
|
59
86
|
/**
|
|
60
|
-
*
|
|
87
|
+
* Maps a record of `Parameter` metadata to the corresponding record of parameter value types.
|
|
88
|
+
*
|
|
89
|
+
* @since 4.0.0
|
|
61
90
|
*/
|
|
62
91
|
export type ParametersRecord<
|
|
63
92
|
A extends Record<string, Parameter.Parameter<any>>
|
|
@@ -69,8 +98,10 @@ export namespace Procedure {
|
|
|
69
98
|
& {}
|
|
70
99
|
|
|
71
100
|
/**
|
|
101
|
+
* Result of a SQL Server stored procedure call, containing typed output parameter values and returned rows.
|
|
102
|
+
*
|
|
72
103
|
* @category model
|
|
73
|
-
* @since
|
|
104
|
+
* @since 4.0.0
|
|
74
105
|
*/
|
|
75
106
|
export interface Result<
|
|
76
107
|
O extends Record<string, Parameter.Parameter<any>>,
|
|
@@ -94,8 +125,10 @@ const procedureProto = {
|
|
|
94
125
|
}
|
|
95
126
|
|
|
96
127
|
/**
|
|
128
|
+
* Creates an empty SQL Server stored procedure definition for the given procedure name.
|
|
129
|
+
*
|
|
97
130
|
* @category constructor
|
|
98
|
-
* @since
|
|
131
|
+
* @since 4.0.0
|
|
99
132
|
*/
|
|
100
133
|
export const make = (name: string): Procedure<{}, {}> => {
|
|
101
134
|
const procedure = Object.create(procedureProto)
|
|
@@ -106,8 +139,10 @@ export const make = (name: string): Procedure<{}, {}> => {
|
|
|
106
139
|
}
|
|
107
140
|
|
|
108
141
|
/**
|
|
142
|
+
* Adds a typed input parameter to a SQL Server stored procedure definition.
|
|
143
|
+
*
|
|
109
144
|
* @category combinator
|
|
110
|
-
* @since
|
|
145
|
+
* @since 4.0.0
|
|
111
146
|
*/
|
|
112
147
|
export const param = <A>() =>
|
|
113
148
|
<N extends string, T extends DataType>(
|
|
@@ -129,8 +164,10 @@ export const param = <A>() =>
|
|
|
129
164
|
})
|
|
130
165
|
|
|
131
166
|
/**
|
|
167
|
+
* Adds a typed output parameter to a SQL Server stored procedure definition.
|
|
168
|
+
*
|
|
132
169
|
* @category combinator
|
|
133
|
-
* @since
|
|
170
|
+
* @since 4.0.0
|
|
134
171
|
*/
|
|
135
172
|
export const outputParam = <A>() =>
|
|
136
173
|
<N extends string, T extends DataType>(
|
|
@@ -152,8 +189,10 @@ export const outputParam = <A>() =>
|
|
|
152
189
|
})
|
|
153
190
|
|
|
154
191
|
/**
|
|
192
|
+
* Sets the expected row type for a SQL Server stored procedure definition.
|
|
193
|
+
*
|
|
155
194
|
* @category combinator
|
|
156
|
-
* @since
|
|
195
|
+
* @since 4.0.0
|
|
157
196
|
*/
|
|
158
197
|
export const withRows = <A extends object = Row>() =>
|
|
159
198
|
<
|
|
@@ -164,8 +203,10 @@ export const withRows = <A extends object = Row>() =>
|
|
|
164
203
|
): Procedure<I, O, A> => self as any
|
|
165
204
|
|
|
166
205
|
/**
|
|
206
|
+
* Binds input values to a SQL Server stored procedure definition, producing a value that can be executed with `MssqlClient.call`.
|
|
207
|
+
*
|
|
167
208
|
* @category combinator
|
|
168
|
-
* @since
|
|
209
|
+
* @since 4.0.0
|
|
169
210
|
*/
|
|
170
211
|
export const compile = <
|
|
171
212
|
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"
|