@effect/sql-mssql 4.0.0-beta.98 → 4.0.0-rc.108

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.
Files changed (89) hide show
  1. package/AGENTS.md +381 -0
  2. package/CLAUDE.md +381 -0
  3. package/README.md +10 -3
  4. package/ai-docs/README.md +44 -0
  5. package/ai-docs/package.json +36 -0
  6. package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
  7. package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +39 -0
  8. package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
  9. package/ai-docs/src/01_effect/01_basics/index.md +5 -0
  10. package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
  11. package/ai-docs/src/01_effect/02_schema/index.md +7 -0
  12. package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
  13. package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
  14. package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
  15. package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
  16. package/ai-docs/src/01_effect/03_services/index.md +5 -0
  17. package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
  18. package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
  19. package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
  20. package/ai-docs/src/01_effect/04_errors/index.md +1 -0
  21. package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
  22. package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
  23. package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
  24. package/ai-docs/src/01_effect/05_resources/index.md +3 -0
  25. package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
  26. package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
  27. package/ai-docs/src/01_effect/06_running/index.md +1 -0
  28. package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
  29. package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
  30. package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
  31. package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
  32. package/ai-docs/src/03_stream/30_encoding.ts +165 -0
  33. package/ai-docs/src/03_stream/index.md +4 -0
  34. package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
  35. package/ai-docs/src/04_integration/index.md +5 -0
  36. package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
  37. package/ai-docs/src/05_batching/index.md +3 -0
  38. package/ai-docs/src/06_schedule/10_schedules.ts +110 -0
  39. package/ai-docs/src/06_schedule/index.md +3 -0
  40. package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
  41. package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
  42. package/ai-docs/src/07_datetime/index.md +5 -0
  43. package/ai-docs/src/08_observability/10_logging.ts +66 -0
  44. package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
  45. package/ai-docs/src/08_observability/index.md +7 -0
  46. package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
  47. package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
  48. package/ai-docs/src/09_testing/index.md +1 -0
  49. package/ai-docs/src/10_predicate/01_basics.ts +14 -0
  50. package/ai-docs/src/10_predicate/index.md +9 -0
  51. package/ai-docs/src/50_http-client/10_basics.ts +102 -0
  52. package/ai-docs/src/50_http-client/index.md +3 -0
  53. package/ai-docs/src/51_http-server/10_basics.ts +116 -0
  54. package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
  55. package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
  56. package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
  57. package/ai-docs/src/51_http-server/fixtures/api/Users.ts +91 -0
  58. package/ai-docs/src/51_http-server/fixtures/domain/User.ts +12 -0
  59. package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
  60. package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +36 -0
  61. package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +71 -0
  62. package/ai-docs/src/51_http-server/fixtures/server/Users.ts +62 -0
  63. package/ai-docs/src/51_http-server/index.md +3 -0
  64. package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
  65. package/ai-docs/src/60_child-process/index.md +3 -0
  66. package/ai-docs/src/70_cli/10_basics.ts +136 -0
  67. package/ai-docs/src/70_cli/index.md +5 -0
  68. package/ai-docs/src/71_ai/10_language-model.ts +156 -0
  69. package/ai-docs/src/71_ai/20_tools.ts +226 -0
  70. package/ai-docs/src/71_ai/30_chat.ts +158 -0
  71. package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
  72. package/ai-docs/src/71_ai/index.md +5 -0
  73. package/ai-docs/src/80_cluster/10_entities.ts +97 -0
  74. package/ai-docs/src/80_cluster/index.md +4 -0
  75. package/ai-docs/src/index.md +10 -0
  76. package/ai-docs/tsconfig.json +24 -0
  77. package/dist/MssqlClient.d.ts +9 -3
  78. package/dist/MssqlClient.d.ts.map +1 -1
  79. package/dist/MssqlClient.js +12 -9
  80. package/dist/MssqlClient.js.map +1 -1
  81. package/dist/MssqlMigrator.d.ts +1 -1
  82. package/dist/MssqlMigrator.js +1 -1
  83. package/dist/MssqlMigrator.js.map +1 -1
  84. package/dist/Parameter.js.map +1 -1
  85. package/dist/Procedure.js.map +1 -1
  86. package/dist/index.js.map +1 -1
  87. package/package.json +12 -9
  88. package/src/MssqlClient.ts +19 -10
  89. package/src/MssqlMigrator.ts +1 -1
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@effect/sql-mssql",
3
- "version": "4.0.0-beta.98",
3
+ "version": "4.0.0-rc.108",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "A Microsoft SQL Server toolkit for Effect",
7
7
  "homepage": "https://effect.website",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "https://github.com/Effect-TS/effect-smol.git",
10
+ "url": "https://github.com/Effect-TS/effect.git",
11
11
  "directory": "packages/sql/mssql"
12
12
  },
13
13
  "bugs": {
14
- "url": "https://github.com/Effect-TS/effect-smol/issues"
14
+ "url": "https://github.com/Effect-TS/effect/issues"
15
15
  },
16
16
  "tags": [
17
17
  "typescript",
@@ -29,6 +29,7 @@
29
29
  ".": "./dist/index.js",
30
30
  "./*": "./dist/*.js",
31
31
  "./internal/*": null,
32
+ "./index": null,
32
33
  "./*/index": null
33
34
  },
34
35
  "files": [
@@ -36,17 +37,21 @@
36
37
  "dist/**/*.js",
37
38
  "dist/**/*.js.map",
38
39
  "dist/**/*.d.ts",
39
- "dist/**/*.d.ts.map"
40
+ "dist/**/*.d.ts.map",
41
+ "AGENTS.md",
42
+ "CLAUDE.md",
43
+ "ai-docs/**/*"
40
44
  ],
41
45
  "publishConfig": {
42
46
  "access": "public",
43
47
  "provenance": true
44
48
  },
45
49
  "devDependencies": {
46
- "effect": "^4.0.0-beta.98"
50
+ "@testcontainers/mssqlserver": "^12.0.4",
51
+ "effect": "^4.0.0-rc.108"
47
52
  },
48
53
  "peerDependencies": {
49
- "effect": "^4.0.0-beta.98"
54
+ "effect": "^4.0.0-rc.108"
50
55
  },
51
56
  "dependencies": {
52
57
  "tedious": "^19.2.1"
@@ -55,8 +60,6 @@
55
60
  "codegen": "effect-utils codegen",
56
61
  "build": "tsc -b tsconfig.json && pnpm babel",
57
62
  "babel": "babel dist --plugins annotate-pure-calls --out-dir dist --source-maps",
58
- "check": "tsc -b tsconfig.json",
59
- "test": "vitest",
60
- "coverage": "vitest --coverage"
63
+ "check": "tsc -b tsconfig.json"
61
64
  }
62
65
  }
@@ -19,6 +19,7 @@ import * as Effect from "effect/Effect"
19
19
  import { identity } from "effect/Function"
20
20
  import * as Layer from "effect/Layer"
21
21
  import * as Pool from "effect/Pool"
22
+ import * as Rec from "effect/Record"
22
23
  import * as Redacted from "effect/Redacted"
23
24
  import * as Scope from "effect/Scope"
24
25
  import * as Stream from "effect/Stream"
@@ -159,7 +160,7 @@ export type TypeId = typeof TypeId
159
160
  /**
160
161
  * Microsoft SQL Server client service, extending `SqlClient` with typed parameter fragments and stored procedure calls.
161
162
  *
162
- * @category models
163
+ * @category services
163
164
  * @since 4.0.0
164
165
  */
165
166
  export interface MssqlClient extends Client.SqlClient {
@@ -205,7 +206,13 @@ export interface MssqlClientConfig {
205
206
  readonly domain?: string | undefined
206
207
  readonly server: string
207
208
  readonly instanceName?: string | undefined
209
+ /**
210
+ * Whether to encrypt traffic between the client and server. Defaults to `true`. Setting this to `false` disables transport encryption and transmits credentials in cleartext.
211
+ */
208
212
  readonly encrypt?: boolean | undefined
213
+ /**
214
+ * Whether to trust the server certificate without validating it. Defaults to `false`. Setting this to `true` disables TLS certificate validation.
215
+ */
209
216
  readonly trustServer?: boolean | undefined
210
217
  readonly port?: number | undefined
211
218
  readonly authType?: string | undefined
@@ -283,7 +290,7 @@ export const make = (
283
290
  options: {
284
291
  port: options.port,
285
292
  database: options.database,
286
- trustServerCertificate: options.trustServer ?? true,
293
+ trustServerCertificate: options.trustServer ?? false,
287
294
  multiSubnetFailover: options.multiSubnetFailover,
288
295
  connectTimeout: options.connectTimeout
289
296
  ? Duration.toMillis(Duration.fromInputUnsafe(options.connectTimeout))
@@ -291,7 +298,7 @@ export const make = (
291
298
  rowCollectionOnRequestCompletion: true,
292
299
  useColumnNames: false,
293
300
  instanceName: options.instanceName,
294
- encrypt: options.encrypt ?? false,
301
+ encrypt: options.encrypt ?? true,
295
302
  cancelTimeout: options.cancelTimeout
296
303
  ? Duration.toMillis(Duration.fromInputUnsafe(options.cancelTimeout))
297
304
  : undefined,
@@ -366,6 +373,7 @@ export const make = (
366
373
 
367
374
  conn.cancel()
368
375
  conn.execSql(req)
376
+ return Effect.sync(() => conn.cancel())
369
377
  })
370
378
 
371
379
  const runProcedure = (
@@ -389,7 +397,7 @@ export const make = (
389
397
  }
390
398
  resume(
391
399
  Effect.succeed({
392
- params: result,
400
+ output: result,
393
401
  rows
394
402
  })
395
403
  )
@@ -409,11 +417,12 @@ export const make = (
409
417
  }
410
418
 
411
419
  req.on("returnValue", (name, value) => {
412
- result[name] = value
420
+ Rec.assignProperty(result, name, value)
413
421
  })
414
422
 
415
423
  conn.cancel()
416
424
  conn.callProcedure(req)
425
+ return Effect.sync(() => conn.cancel())
417
426
  })
418
427
 
419
428
  const connection = identity<MssqlConnection>({
@@ -648,7 +657,7 @@ export const layer = (
648
657
  /**
649
658
  * Creates the SQL Server statement compiler, using `@1`-style placeholders, bracket-escaped identifiers, and SQL Server `OUTPUT INSERTED` returning clauses.
650
659
  *
651
- * @category compiler
660
+ * @category constructors
652
661
  * @since 4.0.0
653
662
  */
654
663
  export const makeCompiler = (transform?: (_: string) => string) =>
@@ -700,12 +709,12 @@ function numberToParamName(n: number) {
700
709
  /**
701
710
  * Default mapping from Effect SQL primitive value kinds to Tedious SQL Server parameter data types.
702
711
  *
703
- * @category configuration
712
+ * @category constants
704
713
  * @since 4.0.0
705
714
  */
706
715
  export const defaultParameterTypes: Record<Statement.PrimitiveKind, DataType> = {
707
- string: Tedious.TYPES.VarChar,
708
- number: Tedious.TYPES.Int,
716
+ string: Tedious.TYPES.NVarChar,
717
+ number: Tedious.TYPES.Float,
709
718
  bigint: Tedious.TYPES.BigInt,
710
719
  boolean: Tedious.TYPES.Bit,
711
720
  Date: Tedious.TYPES.DateTime,
@@ -738,7 +747,7 @@ function rowsToObjects(rows: ReadonlyArray<any>) {
738
747
  const newRow: any = {}
739
748
  for (let j = 0, columnLen = row.length; j < columnLen; j++) {
740
749
  const column = row[j]
741
- newRow[column.metadata.colName] = column.value
750
+ Rec.assignProperty(newRow, column.metadata.colName, column.value)
742
751
  }
743
752
  newRows[i] = newRow
744
753
  }
@@ -23,7 +23,7 @@ export * from "effect/unstable/sql/Migrator"
23
23
  /**
24
24
  * Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
25
25
  *
26
- * @category constructors
26
+ * @category running
27
27
  * @since 4.0.0
28
28
  */
29
29
  export const run: <R>(