@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.
@@ -5,18 +5,24 @@ import type { DataType } from "tedious/lib/data-type.ts";
5
5
  import type { ParameterOptions } from "tedious/lib/request.ts";
6
6
  import * as Parameter from "./Parameter.ts";
7
7
  /**
8
+ * Runtime type identifier used to mark SQL Server stored procedure definitions.
9
+ *
8
10
  * @category type id
9
- * @since 1.0.0
11
+ * @since 4.0.0
10
12
  */
11
13
  export declare const TypeId: TypeId;
12
14
  /**
15
+ * Type-level identifier used to mark SQL Server stored procedure definitions.
16
+ *
13
17
  * @category type id
14
- * @since 1.0.0
18
+ * @since 4.0.0
15
19
  */
16
20
  export type TypeId = "~@effect/sql-mssql/Procedure";
17
21
  /**
22
+ * Pipeable definition of a SQL Server stored procedure, tracking its input parameters, output parameters, and result row type.
23
+ *
18
24
  * @category model
19
- * @since 1.0.0
25
+ * @since 4.0.0
20
26
  */
21
27
  export interface Procedure<I extends Record<string, Parameter.Parameter<any>>, O extends Record<string, Parameter.Parameter<any>>, A = never> extends Pipeable {
22
28
  readonly [TypeId]: {
@@ -28,25 +34,33 @@ export interface Procedure<I extends Record<string, Parameter.Parameter<any>>, O
28
34
  readonly outputParams: O;
29
35
  }
30
36
  /**
37
+ * Stored procedure definition with concrete input values bound for execution.
38
+ *
31
39
  * @category model
32
- * @since 1.0.0
40
+ * @since 4.0.0
33
41
  */
34
42
  export interface ProcedureWithValues<I extends Record<string, Parameter.Parameter<any>>, O extends Record<string, Parameter.Parameter<any>>, A> extends Procedure<I, O, A> {
35
43
  readonly values: Procedure.ParametersRecord<I>;
36
44
  }
37
45
  /**
38
- * @since 1.0.0
46
+ * Namespace containing type helpers and result types for SQL Server stored procedures.
47
+ *
48
+ * @since 4.0.0
39
49
  */
40
50
  export declare namespace Procedure {
41
51
  /**
42
- * @since 1.0.0
52
+ * Maps a record of `Parameter` metadata to the corresponding record of parameter value types.
53
+ *
54
+ * @since 4.0.0
43
55
  */
44
56
  type ParametersRecord<A extends Record<string, Parameter.Parameter<any>>> = {
45
57
  readonly [K in keyof A]: A[K] extends Parameter.Parameter<infer T> ? T : never;
46
58
  } & {};
47
59
  /**
60
+ * Result of a SQL Server stored procedure call, containing typed output parameter values and returned rows.
61
+ *
48
62
  * @category model
49
- * @since 1.0.0
63
+ * @since 4.0.0
50
64
  */
51
65
  interface Result<O extends Record<string, Parameter.Parameter<any>>, A> {
52
66
  readonly output: ParametersRecord<O>;
@@ -57,28 +71,38 @@ type Simplify<A> = {
57
71
  [K in keyof A]: A[K];
58
72
  } & {};
59
73
  /**
74
+ * Creates an empty SQL Server stored procedure definition for the given procedure name.
75
+ *
60
76
  * @category constructor
61
- * @since 1.0.0
77
+ * @since 4.0.0
62
78
  */
63
79
  export declare const make: (name: string) => Procedure<{}, {}>;
64
80
  /**
81
+ * Adds a typed input parameter to a SQL Server stored procedure definition.
82
+ *
65
83
  * @category combinator
66
- * @since 1.0.0
84
+ * @since 4.0.0
67
85
  */
68
86
  export declare const param: <A>() => <N extends string, T extends DataType>(name: N, type: T, options?: ParameterOptions) => <I extends Record<string, Parameter.Parameter<any>>, O extends Record<string, Parameter.Parameter<any>>>(self: Procedure<I, O>) => Procedure<Simplify<I & { [K in N]: Parameter.Parameter<A>; }>, O>;
69
87
  /**
88
+ * Adds a typed output parameter to a SQL Server stored procedure definition.
89
+ *
70
90
  * @category combinator
71
- * @since 1.0.0
91
+ * @since 4.0.0
72
92
  */
73
93
  export declare const outputParam: <A>() => <N extends string, T extends DataType>(name: N, type: T, options?: ParameterOptions) => <I extends Record<string, Parameter.Parameter<any>>, O extends Record<string, Parameter.Parameter<any>>>(self: Procedure<I, O>) => Procedure<I, Simplify<O & { [K in N]: Parameter.Parameter<A>; }>>;
74
94
  /**
95
+ * Sets the expected row type for a SQL Server stored procedure definition.
96
+ *
75
97
  * @category combinator
76
- * @since 1.0.0
98
+ * @since 4.0.0
77
99
  */
78
100
  export declare const withRows: <A extends object = Row>() => <I extends Record<string, Parameter.Parameter<any>>, O extends Record<string, Parameter.Parameter<any>>>(self: Procedure<I, O>) => Procedure<I, O, A>;
79
101
  /**
102
+ * Binds input values to a SQL Server stored procedure definition, producing a value that can be executed with `MssqlClient.call`.
103
+ *
80
104
  * @category combinator
81
- * @since 1.0.0
105
+ * @since 4.0.0
82
106
  */
83
107
  export declare const compile: <I extends Record<string, Parameter.Parameter<any>>, O extends Record<string, Parameter.Parameter<any>>, A>(self: Procedure<I, O, A>) => (input: Procedure.ParametersRecord<I>) => ProcedureWithValues<I, O, A>;
84
108
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Procedure.d.ts","sourceRoot":"","sources":["../src/Procedure.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mCAAmC,CAAA;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,MAAuC,CAAA;AAE5D;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,8BAA8B,CAAA;AAEnD;;;GAGG;AACH,MAAM,WAAW,SAAS,CACxB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAClD,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAClD,CAAC,GAAG,KAAK,CACT,SAAQ,QAAQ;IAChB,QAAQ,CAAC,CAAC,MAAM,CAAC,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.
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 { pipeArguments } from "effect/Pipeable";
6
23
  import * as Parameter from "./Parameter.js";
7
24
  /**
25
+ * Runtime type identifier used to mark SQL Server stored procedure definitions.
26
+ *
8
27
  * @category type id
9
- * @since 1.0.0
28
+ * @since 4.0.0
10
29
  */
11
30
  export const TypeId = "~@effect/sql-mssql/Procedure";
12
31
  const procedureProto = {
@@ -19,8 +38,10 @@ const procedureProto = {
19
38
  }
20
39
  };
21
40
  /**
41
+ * Creates an empty SQL Server stored procedure definition for the given procedure name.
42
+ *
22
43
  * @category constructor
23
- * @since 1.0.0
44
+ * @since 4.0.0
24
45
  */
25
46
  export const make = name => {
26
47
  const procedure = Object.create(procedureProto);
@@ -30,8 +51,10 @@ export const make = name => {
30
51
  return procedure;
31
52
  };
32
53
  /**
54
+ * Adds a typed input parameter to a SQL Server stored procedure definition.
55
+ *
33
56
  * @category combinator
34
- * @since 1.0.0
57
+ * @since 4.0.0
35
58
  */
36
59
  export const param = () => (name, type, options) => self => ({
37
60
  ...self,
@@ -41,8 +64,10 @@ export const param = () => (name, type, options) => self => ({
41
64
  }
42
65
  });
43
66
  /**
67
+ * Adds a typed output parameter to a SQL Server stored procedure definition.
68
+ *
44
69
  * @category combinator
45
- * @since 1.0.0
70
+ * @since 4.0.0
46
71
  */
47
72
  export const outputParam = () => (name, type, options) => self => ({
48
73
  ...self,
@@ -52,13 +77,17 @@ export const outputParam = () => (name, type, options) => self => ({
52
77
  }
53
78
  });
54
79
  /**
80
+ * Sets the expected row type for a SQL Server stored procedure definition.
81
+ *
55
82
  * @category combinator
56
- * @since 1.0.0
83
+ * @since 4.0.0
57
84
  */
58
85
  export const withRows = () => self => self;
59
86
  /**
87
+ * Binds input values to a SQL Server stored procedure definition, producing a value that can be executed with `MssqlClient.call`.
88
+ *
60
89
  * @category combinator
61
- * @since 1.0.0
90
+ * @since 4.0.0
62
91
  */
63
92
  export const compile = self => input => ({
64
93
  ...self,
@@ -1 +1 @@
1
- {"version":3,"file":"Procedure.js","names":["identity","pipeArguments","Parameter","TypeId","procedureProto","_A","_tag","pipe","arguments","make","name","procedure","Object","create","params","outputParams","param","type","options","self","outputParam","withRows","compile","input","values"],"sources":["../src/Procedure.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,SAASA,QAAQ,QAAQ,iBAAiB;AAE1C,SAASC,aAAa,QAAQ,iBAAiB;AAK/C,OAAO,KAAKC,SAAS,MAAM,gBAAgB;AAE3C;;;;AAIA,OAAO,MAAMC,MAAM,GAAW,8BAA8B;AAqE5D,MAAMC,cAAc,GAAG;EACrB,CAACD,MAAM,GAAG;IACRE,EAAE,EAAEL;GACL;EACDM,IAAI,EAAE,WAAW;EACjBC,IAAIA,CAAA;IACF,OAAON,aAAa,CAAC,IAAI,EAAEO,SAAS,CAAC;EACvC;CACD;AAED;;;;AAIA,OAAO,MAAMC,IAAI,GAAIC,IAAY,IAAuB;EACtD,MAAMC,SAAS,GAAGC,MAAM,CAACC,MAAM,CAACT,cAAc,CAAC;EAC/CO,SAAS,CAACD,IAAI,GAAGA,IAAI;EACrBC,SAAS,CAACG,MAAM,GAAG,EAAE;EACrBH,SAAS,CAACI,YAAY,GAAG,EAAE;EAC3B,OAAOJ,SAAS;AAClB,CAAC;AAED;;;;AAIA,OAAO,MAAMK,KAAK,GAAGA,CAAA,KACrB,CACEN,IAAO,EACPO,IAAO,EACPC,OAA0B,KAM1BC,IAAqB,KACiD;EACtE,GAAGA,IAAI;EACPL,MAAM,EAAE;IACN,GAAGK,IAAI,CAACL,MAAM;IACd,CAACJ,IAAI,GAAGR,SAAS,CAACO,IAAI,CAACC,IAAI,EAAEO,IAAI,EAAEC,OAAO;;CAE7C,CAAC;AAEF;;;;AAIA,OAAO,MAAME,WAAW,GAAGA,CAAA,KAC3B,CACEV,IAAO,EACPO,IAAO,EACPC,OAA0B,KAM1BC,IAAqB,KACiD;EACtE,GAAGA,IAAI;EACPJ,YAAY,EAAE;IACZ,GAAGI,IAAI,CAACJ,YAAY;IACpB,CAACL,IAAI,GAAGR,SAAS,CAACO,IAAI,CAACC,IAAI,EAAEO,IAAI,EAAEC,OAAO;;CAE7C,CAAC;AAEF;;;;AAIA,OAAO,MAAMG,QAAQ,GAAGA,CAAA,KAKtBF,IAAqB,IACEA,IAAW;AAEpC;;;;AAIA,OAAO,MAAMG,OAAO,GAKlBH,IAAwB,IAEzBI,KAAoC,KAAoC;EACvE,GAAGJ,IAAI;EACPK,MAAM,EAAED;CACT,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Procedure.js","names":["identity","pipeArguments","Parameter","TypeId","procedureProto","_A","_tag","pipe","arguments","make","name","procedure","Object","create","params","outputParams","param","type","options","self","outputParam","withRows","compile","input","values"],"sources":["../src/Procedure.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;AAoBA,SAASA,QAAQ,QAAQ,iBAAiB;AAE1C,SAASC,aAAa,QAAQ,iBAAiB;AAK/C,OAAO,KAAKC,SAAS,MAAM,gBAAgB;AAE3C;;;;;;AAMA,OAAO,MAAMC,MAAM,GAAW,8BAA8B;AAiF5D,MAAMC,cAAc,GAAG;EACrB,CAACD,MAAM,GAAG;IACRE,EAAE,EAAEL;GACL;EACDM,IAAI,EAAE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5
5
  /**
6
- * @since 1.0.0
6
+ * @since 4.0.0
7
7
  */
8
8
  TYPES as MssqlTypes } from "tedious";
9
9
  /**
10
- * @since 1.0.0
10
+ * @since 4.0.0
11
11
  */
12
12
  export * as MssqlClient from "./MssqlClient.ts";
13
13
  /**
14
- * @since 1.0.0
14
+ * @since 4.0.0
15
15
  */
16
16
  export * as MssqlMigrator from "./MssqlMigrator.ts";
17
17
  /**
18
- * @since 1.0.0
18
+ * @since 4.0.0
19
19
  */
20
20
  export * as Parameter from "./Parameter.ts";
21
21
  /**
22
- * @since 1.0.0
22
+ * @since 4.0.0
23
23
  */
24
24
  export * as Procedure from "./Procedure.ts";
25
25
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,26 +1,26 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
  export {
5
5
  /**
6
- * @since 1.0.0
6
+ * @since 4.0.0
7
7
  */
8
8
  TYPES as MssqlTypes } from "tedious";
9
9
  // @barrel: Auto-generated exports. Do not edit manually.
10
10
  /**
11
- * @since 1.0.0
11
+ * @since 4.0.0
12
12
  */
13
13
  export * as MssqlClient from "./MssqlClient.js";
14
14
  /**
15
- * @since 1.0.0
15
+ * @since 4.0.0
16
16
  */
17
17
  export * as MssqlMigrator from "./MssqlMigrator.js";
18
18
  /**
19
- * @since 1.0.0
19
+ * @since 4.0.0
20
20
  */
21
21
  export * as Parameter from "./Parameter.js";
22
22
  /**
23
- * @since 1.0.0
23
+ * @since 4.0.0
24
24
  */
25
25
  export * as Procedure from "./Procedure.js";
26
26
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/sql-mssql",
3
- "version": "4.0.0-beta.65",
3
+ "version": "4.0.0-beta.67",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "A Microsoft SQL Server toolkit for Effect",
@@ -43,10 +43,10 @@
43
43
  "provenance": true
44
44
  },
45
45
  "devDependencies": {
46
- "effect": "^4.0.0-beta.65"
46
+ "effect": "^4.0.0-beta.67"
47
47
  },
48
48
  "peerDependencies": {
49
- "effect": "^4.0.0-beta.65"
49
+ "effect": "^4.0.0-beta.67"
50
50
  },
51
51
  "dependencies": {
52
52
  "tedious": "^19.2.1"
@@ -1,5 +1,31 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Microsoft SQL Server client implementation for Effect SQL, backed by the
3
+ * `tedious` driver.
4
+ *
5
+ * This module provides the `MssqlClient` service and layers that also satisfy
6
+ * the generic `SqlClient` service. It is intended for server applications,
7
+ * background workers, migrations, and tests that need SQL Server query
8
+ * compilation, Tedious parameter typing, scoped connection management,
9
+ * transactions, and typed stored procedure calls.
10
+ *
11
+ * Clients own a scoped pool of Tedious connections and validate startup with
12
+ * `SELECT 1`. Regular queries borrow a pooled connection per operation, while
13
+ * transactions keep one pooled connection for their lifetime and use SQL Server
14
+ * savepoints for nested transactions. Long-running transactions therefore
15
+ * reduce available pool capacity; size `maxConnections`, `connectionTTL`, and
16
+ * `connectTimeout` accordingly.
17
+ *
18
+ * Tedious permits one active request per connection. This client compiles
19
+ * statements with named `@1`-style parameters, maps Effect SQL primitive values
20
+ * to Tedious `DataType`s unless `param` is used, and does not implement
21
+ * streaming queries. Be deliberate about TLS options: `encrypt` defaults to
22
+ * `false` and `trustServerCertificate` defaults to `true` unless overridden.
23
+ * Stored procedure calls go through `callProcedure`; define input and output
24
+ * parameters with the `Procedure` and `Parameter` helpers so Tedious receives
25
+ * the correct data types and output values can be collected from `returnValue`
26
+ * events.
27
+ *
28
+ * @since 4.0.0
3
29
  */
4
30
  import * as Config from "effect/Config"
5
31
  import * as Context from "effect/Context"
@@ -130,20 +156,26 @@ const classifyError = (
130
156
  }
131
157
 
132
158
  /**
159
+ * Runtime type identifier used to mark `MssqlClient` values.
160
+ *
133
161
  * @category type ids
134
- * @since 1.0.0
162
+ * @since 4.0.0
135
163
  */
136
164
  export const TypeId: unique symbol = Symbol.for("@effect/sql-mssql/MssqlClient")
137
165
 
138
166
  /**
167
+ * Type-level identifier used to mark `MssqlClient` values.
168
+ *
139
169
  * @category type ids
140
- * @since 1.0.0
170
+ * @since 4.0.0
141
171
  */
142
172
  export type TypeId = typeof TypeId
143
173
 
144
174
  /**
175
+ * Microsoft SQL Server client service, extending `SqlClient` with typed parameter fragments and stored procedure calls.
176
+ *
145
177
  * @category models
146
- * @since 1.0.0
178
+ * @since 4.0.0
147
179
  */
148
180
  export interface MssqlClient extends Client.SqlClient {
149
181
  readonly [TypeId]: TypeId
@@ -166,14 +198,18 @@ export interface MssqlClient extends Client.SqlClient {
166
198
  }
167
199
 
168
200
  /**
201
+ * Context tag used to access the `MssqlClient` service.
202
+ *
169
203
  * @category tags
170
- * @since 1.0.0
204
+ * @since 4.0.0
171
205
  */
172
206
  export const MssqlClient = Context.Service<MssqlClient>("@effect/sql-mssql/MssqlClient")
173
207
 
174
208
  /**
209
+ * Configuration for a Microsoft SQL Server client, including connection, authentication, pool, parameter type, span attribute, and query/result name transform options.
210
+ *
175
211
  * @category models
176
- * @since 1.0.0
212
+ * @since 4.0.0
177
213
  */
178
214
  export interface MssqlClientConfig {
179
215
  readonly domain?: string | undefined
@@ -220,8 +256,10 @@ const TransactionConnection = Client.TransactionConnection as unknown as (client
220
256
  let clientIdCounter = 0
221
257
 
222
258
  /**
259
+ * Creates a scoped Microsoft SQL Server client backed by a connection pool, with transaction and stored procedure support. Streaming queries are not implemented.
260
+ *
223
261
  * @category constructors
224
- * @since 1.0.0
262
+ * @since 4.0.0
225
263
  */
226
264
  export const make = (
227
265
  options: MssqlClientConfig
@@ -565,8 +603,10 @@ export const make = (
565
603
  })
566
604
 
567
605
  /**
606
+ * Creates a layer from a `Config`-wrapped SQL Server client configuration, providing both `MssqlClient` and `SqlClient`.
607
+ *
568
608
  * @category layers
569
- * @since 1.0.0
609
+ * @since 4.0.0
570
610
  */
571
611
  export const layerConfig: (
572
612
  config: Config.Wrap<MssqlClientConfig>
@@ -574,7 +614,7 @@ export const layerConfig: (
574
614
  config: Config.Wrap<MssqlClientConfig>
575
615
  ): Layer.Layer<Client.SqlClient | MssqlClient, Config.ConfigError | SqlError> =>
576
616
  Layer.effectContext(
577
- Config.unwrap(config).asEffect().pipe(
617
+ Config.unwrap(config).pipe(
578
618
  Effect.flatMap(make),
579
619
  Effect.map((client) =>
580
620
  Context.make(MssqlClient, client).pipe(
@@ -585,8 +625,10 @@ export const layerConfig: (
585
625
  ).pipe(Layer.provide(Reactivity.layer))
586
626
 
587
627
  /**
628
+ * Creates a layer from a concrete SQL Server client configuration, providing both `MssqlClient` and `SqlClient`.
629
+ *
588
630
  * @category layers
589
- * @since 1.0.0
631
+ * @since 4.0.0
590
632
  */
591
633
  export const layer = (
592
634
  config: MssqlClientConfig
@@ -599,8 +641,10 @@ export const layer = (
599
641
  ).pipe(Layer.provide(Reactivity.layer))
600
642
 
601
643
  /**
644
+ * Creates the SQL Server statement compiler, using `@1`-style placeholders, bracket-escaped identifiers, and SQL Server `OUTPUT INSERTED` returning clauses.
645
+ *
602
646
  * @category compiler
603
- * @since 1.0.0
647
+ * @since 4.0.0
604
648
  */
605
649
  export const makeCompiler = (transform?: (_: string) => string) =>
606
650
  Statement.makeCompiler<MssqlCustom>({
@@ -649,7 +693,9 @@ function numberToParamName(n: number) {
649
693
  }
650
694
 
651
695
  /**
652
- * @since 1.0.0
696
+ * Default mapping from Effect SQL primitive value kinds to Tedious SQL Server parameter data types.
697
+ *
698
+ * @since 4.0.0
653
699
  */
654
700
  export const defaultParameterTypes: Record<Statement.PrimitiveKind, DataType> = {
655
701
  string: Tedious.TYPES.VarChar,
@@ -1,5 +1,26 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Utilities for applying Effect SQL migrations to Microsoft SQL Server.
3
+ *
4
+ * This module re-exports the shared `Migrator` loaders and error types, then
5
+ * provides `run` and `layer` helpers for applying ordered migrations through
6
+ * the current SQL Server `SqlClient`. It is typically used at application
7
+ * startup, during deployment, in integration tests that provision temporary SQL
8
+ * Server databases, or in layer graphs that need the database schema to be
9
+ * current before dependent services are acquired.
10
+ *
11
+ * Applied migrations are stored in `effect_sql_migrations` by default and use
12
+ * the shared `<id>_<name>` loader convention. Only migrations with ids greater
13
+ * than the latest recorded id are run, so avoid inserting older migration ids
14
+ * after a later migration has reached production. SQL Server migrations run
15
+ * inside the shared migrator transaction and this adapter does not add a
16
+ * dialect-specific table lock, so coordinate concurrent startup runners and
17
+ * write T-SQL that is valid inside an explicit transaction. Remember that `GO`
18
+ * is a client-side batch separator rather than a T-SQL statement, and split
19
+ * migrations when SQL Server requires an object definition such as `CREATE
20
+ * VIEW`, `CREATE PROCEDURE`, or `CREATE TRIGGER` to start its own batch. This
21
+ * adapter also does not emit SQL Server schema dumps for `schemaDirectory`.
22
+ *
23
+ * @since 4.0.0
3
24
  */
4
25
  import type * as Effect from "effect/Effect"
5
26
  import * as Layer from "effect/Layer"
@@ -8,13 +29,15 @@ import type * as Client from "effect/unstable/sql/SqlClient"
8
29
  import type { SqlError } from "effect/unstable/sql/SqlError"
9
30
 
10
31
  /**
11
- * @since 1.0.0
32
+ * @since 4.0.0
12
33
  */
13
34
  export * from "effect/unstable/sql/Migrator"
14
35
 
15
36
  /**
37
+ * Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
38
+ *
16
39
  * @category constructor
17
- * @since 1.0.0
40
+ * @since 4.0.0
18
41
  */
19
42
  export const run: <R>(
20
43
  options: Migrator.MigratorOptions<R>
@@ -25,8 +48,10 @@ export const run: <R>(
25
48
  > = Migrator.make({})
26
49
 
27
50
  /**
51
+ * Creates a layer that runs the configured SQL migrations during layer construction.
52
+ *
28
53
  * @category layers
29
- * @since 1.0.0
54
+ * @since 4.0.0
30
55
  */
31
56
  export const layer = <R>(
32
57
  options: Migrator.MigratorOptions<R>
package/src/Parameter.ts CHANGED
@@ -1,25 +1,51 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Typed metadata for SQL Server stored procedure parameters.
3
+ *
4
+ * This module records the bare parameter name, Tedious `DataType`, Tedious
5
+ * `ParameterOptions`, and phantom TypeScript value type used by
6
+ * `Procedure.param` and `Procedure.outputParam`. `MssqlClient.call` later
7
+ * forwards input parameters to Tedious with `Request.addParameter` and output
8
+ * parameters with `Request.addOutputParameter`, so names should match the
9
+ * stored procedure parameter name without a leading `@`.
10
+ *
11
+ * Use these values when defining stored procedures that need explicit SQL
12
+ * Server parameter metadata, such as sized strings or binary values, decimal
13
+ * precision/scale, table-valued parameters, and output parameters. The generic
14
+ * type parameter is only a compile-time guide for the value record accepted by
15
+ * `Procedure.compile`; Tedious still validates and encodes the runtime value.
16
+ * In particular, TVP values must use Tedious' table shape with `name`,
17
+ * optional `schema`, `columns`, and `rows`, and output parameters are registered
18
+ * with no initial value, so SQL Server input-output parameters need separate
19
+ * care rather than assuming an output parameter is populated from compiled
20
+ * input values.
21
+ *
22
+ * @since 4.0.0
3
23
  */
4
24
  import { identity } from "effect/Function"
5
25
  import type { DataType } from "tedious/lib/data-type.ts"
6
26
  import type { ParameterOptions } from "tedious/lib/request.ts"
7
27
 
8
28
  /**
29
+ * Runtime type identifier used to mark SQL Server stored procedure parameter metadata.
30
+ *
9
31
  * @category type id
10
- * @since 1.0.0
32
+ * @since 4.0.0
11
33
  */
12
34
  export const TypeId: TypeId = "~@effect/sql-mssql/Parameter"
13
35
 
14
36
  /**
37
+ * Type-level identifier used to mark SQL Server stored procedure parameter metadata.
38
+ *
15
39
  * @category type id
16
- * @since 1.0.0
40
+ * @since 4.0.0
17
41
  */
18
42
  export type TypeId = "~@effect/sql-mssql/Parameter"
19
43
 
20
44
  /**
45
+ * Metadata for a SQL Server stored procedure parameter, including its name, Tedious data type, options, and phantom value type.
46
+ *
21
47
  * @category model
22
- * @since 1.0.0
48
+ * @since 4.0.0
23
49
  */
24
50
  export interface Parameter<out A> {
25
51
  readonly [TypeId]: (_: never) => A
@@ -30,8 +56,10 @@ export interface Parameter<out A> {
30
56
  }
31
57
 
32
58
  /**
59
+ * Creates typed metadata for a SQL Server stored procedure parameter.
60
+ *
33
61
  * @category constructor
34
- * @since 1.0.0
62
+ * @since 4.0.0
35
63
  */
36
64
  export const make = <A>(
37
65
  name: string,