litedbmodel 2.1.0 → 2.2.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.
Files changed (186) hide show
  1. package/README.md +7 -0
  2. package/dist/DBConditions.d.ts.map +1 -1
  3. package/dist/DBConditions.js +16 -1
  4. package/dist/DBConditions.js.map +1 -1
  5. package/dist/DBHandler.d.ts.map +1 -1
  6. package/dist/DBHandler.js +6 -0
  7. package/dist/DBHandler.js.map +1 -1
  8. package/dist/DBModel.d.ts +84 -2
  9. package/dist/DBModel.d.ts.map +1 -1
  10. package/dist/DBModel.js +312 -29
  11. package/dist/DBModel.js.map +1 -1
  12. package/dist/decorators.d.ts +52 -0
  13. package/dist/decorators.d.ts.map +1 -1
  14. package/dist/decorators.js +83 -0
  15. package/dist/decorators.js.map +1 -1
  16. package/dist/drivers/mysql.d.ts.map +1 -1
  17. package/dist/drivers/mysql.js +6 -2
  18. package/dist/drivers/mysql.js.map +1 -1
  19. package/dist/drivers/postgres.d.ts.map +1 -1
  20. package/dist/drivers/postgres.js +6 -2
  21. package/dist/drivers/postgres.js.map +1 -1
  22. package/dist/drivers/sqlite.d.ts.map +1 -1
  23. package/dist/drivers/sqlite.js +12 -2
  24. package/dist/drivers/sqlite.js.map +1 -1
  25. package/dist/index.cjs +10741 -0
  26. package/dist/index.d.cts +1 -0
  27. package/dist/scp/coltype.d.ts +26 -1
  28. package/dist/scp/coltype.d.ts.map +1 -1
  29. package/dist/scp/coltype.js +82 -15
  30. package/dist/scp/coltype.js.map +1 -1
  31. package/dist/scp/connection-routing.d.ts +312 -0
  32. package/dist/scp/connection-routing.d.ts.map +1 -0
  33. package/dist/scp/connection-routing.js +394 -0
  34. package/dist/scp/connection-routing.js.map +1 -0
  35. package/dist/scp/dbmodel-runtime.d.ts +101 -0
  36. package/dist/scp/dbmodel-runtime.d.ts.map +1 -0
  37. package/dist/scp/dbmodel-runtime.js +174 -0
  38. package/dist/scp/dbmodel-runtime.js.map +1 -0
  39. package/dist/scp/decorator-adapter.d.ts +196 -0
  40. package/dist/scp/decorator-adapter.d.ts.map +1 -0
  41. package/dist/scp/decorator-adapter.js +286 -0
  42. package/dist/scp/decorator-adapter.js.map +1 -0
  43. package/dist/scp/emit/emitter.d.ts +108 -0
  44. package/dist/scp/emit/emitter.d.ts.map +1 -0
  45. package/dist/scp/emit/emitter.js +782 -0
  46. package/dist/scp/emit/emitter.js.map +1 -0
  47. package/dist/scp/emit/endpoint.d.ts +248 -0
  48. package/dist/scp/emit/endpoint.d.ts.map +1 -0
  49. package/dist/scp/emit/endpoint.js +20 -0
  50. package/dist/scp/emit/endpoint.js.map +1 -0
  51. package/dist/scp/emit/index.d.ts +11 -0
  52. package/dist/scp/emit/index.d.ts.map +1 -0
  53. package/dist/scp/emit/index.js +13 -0
  54. package/dist/scp/emit/index.js.map +1 -0
  55. package/dist/scp/errors.d.ts +45 -1
  56. package/dist/scp/errors.d.ts.map +1 -1
  57. package/dist/scp/errors.js +47 -1
  58. package/dist/scp/errors.js.map +1 -1
  59. package/dist/scp/exec-context.d.ts +390 -0
  60. package/dist/scp/exec-context.d.ts.map +1 -0
  61. package/dist/scp/exec-context.js +540 -0
  62. package/dist/scp/exec-context.js.map +1 -0
  63. package/dist/scp/grouping.d.ts +32 -0
  64. package/dist/scp/grouping.d.ts.map +1 -0
  65. package/dist/scp/grouping.js +0 -0
  66. package/dist/scp/grouping.js.map +1 -0
  67. package/dist/scp/index.cjs +6814 -15731
  68. package/dist/scp/index.d.cts +1 -0
  69. package/dist/scp/index.d.mts +1 -0
  70. package/dist/scp/index.d.ts +47 -49
  71. package/dist/scp/index.d.ts.map +1 -1
  72. package/dist/scp/index.js +174 -152
  73. package/dist/scp/index.js.map +1 -1
  74. package/dist/scp/index.mjs +5561 -3704
  75. package/dist/scp/leaf-transport.d.ts +50 -0
  76. package/dist/scp/leaf-transport.d.ts.map +1 -0
  77. package/dist/scp/leaf-transport.js +92 -0
  78. package/dist/scp/leaf-transport.js.map +1 -0
  79. package/dist/scp/leaves.d.ts +174 -0
  80. package/dist/scp/leaves.d.ts.map +1 -0
  81. package/dist/scp/leaves.js +287 -0
  82. package/dist/scp/leaves.js.map +1 -0
  83. package/dist/scp/limit-config.d.ts +118 -0
  84. package/dist/scp/limit-config.d.ts.map +1 -0
  85. package/dist/scp/limit-config.js +126 -0
  86. package/dist/scp/limit-config.js.map +1 -0
  87. package/dist/scp/makesql/compile-relation.d.ts +49 -23
  88. package/dist/scp/makesql/compile-relation.d.ts.map +1 -1
  89. package/dist/scp/makesql/compile-relation.js +101 -76
  90. package/dist/scp/makesql/compile-relation.js.map +1 -1
  91. package/dist/scp/makesql/compile-select.d.ts +45 -10
  92. package/dist/scp/makesql/compile-select.d.ts.map +1 -1
  93. package/dist/scp/makesql/compile-select.js +50 -10
  94. package/dist/scp/makesql/compile-select.js.map +1 -1
  95. package/dist/scp/makesql/handler.d.ts +1 -1
  96. package/dist/scp/makesql/handler.d.ts.map +1 -1
  97. package/dist/scp/makesql/index.d.ts +7 -9
  98. package/dist/scp/makesql/index.d.ts.map +1 -1
  99. package/dist/scp/makesql/index.js +17 -28
  100. package/dist/scp/makesql/index.js.map +1 -1
  101. package/dist/scp/makesql/json-array.d.ts +65 -0
  102. package/dist/scp/makesql/json-array.d.ts.map +1 -1
  103. package/dist/scp/makesql/json-array.js +99 -10
  104. package/dist/scp/makesql/json-array.js.map +1 -1
  105. package/dist/scp/makesql/json-batch.d.ts.map +1 -1
  106. package/dist/scp/makesql/json-batch.js +15 -18
  107. package/dist/scp/makesql/json-batch.js.map +1 -1
  108. package/dist/scp/makesql/makesql.d.ts +1 -1
  109. package/dist/scp/makesql/makesql.d.ts.map +1 -1
  110. package/dist/scp/makesql/mysql-returning.d.ts +93 -0
  111. package/dist/scp/makesql/mysql-returning.d.ts.map +1 -0
  112. package/dist/scp/makesql/mysql-returning.js +215 -0
  113. package/dist/scp/makesql/mysql-returning.js.map +1 -0
  114. package/dist/scp/makesql/outtype.d.ts +40 -54
  115. package/dist/scp/makesql/outtype.d.ts.map +1 -1
  116. package/dist/scp/makesql/outtype.js +46 -204
  117. package/dist/scp/makesql/outtype.js.map +1 -1
  118. package/dist/scp/makesql/pool-executor.d.ts +86 -34
  119. package/dist/scp/makesql/pool-executor.d.ts.map +1 -1
  120. package/dist/scp/makesql/pool-executor.js +179 -39
  121. package/dist/scp/makesql/pool-executor.js.map +1 -1
  122. package/dist/scp/makesql/tx.d.ts +107 -22
  123. package/dist/scp/makesql/tx.d.ts.map +1 -1
  124. package/dist/scp/makesql/tx.js +451 -97
  125. package/dist/scp/makesql/tx.js.map +1 -1
  126. package/dist/scp/makesql/writeouttype.d.ts +4 -4
  127. package/dist/scp/makesql/writeouttype.d.ts.map +1 -1
  128. package/dist/scp/makesql/writeouttype.js +5 -3
  129. package/dist/scp/makesql/writeouttype.js.map +1 -1
  130. package/dist/scp/middleware.d.ts +287 -0
  131. package/dist/scp/middleware.d.ts.map +1 -0
  132. package/dist/scp/middleware.js +358 -0
  133. package/dist/scp/middleware.js.map +1 -0
  134. package/dist/scp/relation.d.ts +65 -8
  135. package/dist/scp/relation.d.ts.map +1 -1
  136. package/dist/scp/relation.js +154 -93
  137. package/dist/scp/relation.js.map +1 -1
  138. package/dist/scp/tx-options.d.ts +136 -0
  139. package/dist/scp/tx-options.d.ts.map +1 -0
  140. package/dist/scp/tx-options.js +184 -0
  141. package/dist/scp/tx-options.js.map +1 -0
  142. package/dist/scp/write-bundle.d.ts +131 -0
  143. package/dist/scp/write-bundle.d.ts.map +1 -0
  144. package/dist/scp/write-bundle.js +160 -0
  145. package/dist/scp/write-bundle.js.map +1 -0
  146. package/dist/types.d.ts +7 -0
  147. package/dist/types.d.ts.map +1 -1
  148. package/dist/types.js.map +1 -1
  149. package/docs/design/phase-a-execution-context.md +139 -0
  150. package/package.json +14 -13
  151. package/dist/scp/authoring-sql.d.ts +0 -134
  152. package/dist/scp/authoring-sql.d.ts.map +0 -1
  153. package/dist/scp/authoring-sql.js +0 -191
  154. package/dist/scp/authoring-sql.js.map +0 -1
  155. package/dist/scp/authoring.d.ts +0 -218
  156. package/dist/scp/authoring.d.ts.map +0 -1
  157. package/dist/scp/authoring.js +0 -351
  158. package/dist/scp/authoring.js.map +0 -1
  159. package/dist/scp/catalog.d.ts +0 -95
  160. package/dist/scp/catalog.d.ts.map +0 -1
  161. package/dist/scp/catalog.js +0 -245
  162. package/dist/scp/catalog.js.map +0 -1
  163. package/dist/scp/codegen.d.ts +0 -201
  164. package/dist/scp/codegen.d.ts.map +0 -1
  165. package/dist/scp/codegen.js +0 -605
  166. package/dist/scp/codegen.js.map +0 -1
  167. package/dist/scp/find-filter-guard.d.ts +0 -68
  168. package/dist/scp/find-filter-guard.d.ts.map +0 -1
  169. package/dist/scp/find-filter-guard.js +0 -88
  170. package/dist/scp/find-filter-guard.js.map +0 -1
  171. package/dist/scp/guard.d.ts +0 -43
  172. package/dist/scp/guard.d.ts.map +0 -1
  173. package/dist/scp/guard.js +0 -140
  174. package/dist/scp/guard.js.map +0 -1
  175. package/dist/scp/makesql/authoring-compile.d.ts +0 -90
  176. package/dist/scp/makesql/authoring-compile.d.ts.map +0 -1
  177. package/dist/scp/makesql/authoring-compile.js +0 -505
  178. package/dist/scp/makesql/authoring-compile.js.map +0 -1
  179. package/dist/scp/makesql/static-bundle.d.ts +0 -196
  180. package/dist/scp/makesql/static-bundle.d.ts.map +0 -1
  181. package/dist/scp/makesql/static-bundle.js +0 -1244
  182. package/dist/scp/makesql/static-bundle.js.map +0 -1
  183. package/dist/scp/runtime.d.ts +0 -243
  184. package/dist/scp/runtime.d.ts.map +0 -1
  185. package/dist/scp/runtime.js +0 -422
  186. package/dist/scp/runtime.js.map +0 -1
@@ -0,0 +1 @@
1
+ export * from './index.js';
@@ -10,6 +10,20 @@
10
10
  */
11
11
  /** bc typed outType のスカラ型(bc 0.3.0 の portable notation と一致;date 型は無い)。 */
12
12
  export type BcScalar = 'string' | 'int' | 'float' | 'bool' | 'null';
13
+ /**
14
+ * SQL 型トークンを基底型名へ正規化する SSoT(`sqlTypeToBcScalar` / `sqlTypeToMaterializeClass` が共有)。
15
+ * 括弧のサイズ/精度と、型判定に無関係な列修飾(`UNSIGNED`/`ZEROFILL`/`PRECISION` と NULL 可否
16
+ * `NOT NULL`/`NULL`)を落として基底型名だけを残す。NULL 可否は {@link sqlTypeIsNotNull} が別に読む
17
+ * (型スカラと直交する — nullability は outType の `opt` ラップの有無、基底スカラではない)。
18
+ */
19
+ export declare function normalizeSqlTypeToken(sqlType: string): string;
20
+ /**
21
+ * 宣言された SQL 型が `NOT NULL` 制約を持つか(`static columns` は列制約を型トークンに書ける)。
22
+ * `true` の列は読み出しセルが非 null 確定 → 読み outType は `opt` ラップ無しの生スカラ(RETURNING の
23
+ * 主キーのような非 null 値を value 位置で消費できる — spec §4.1 の nullability)。既定(無指定)は
24
+ * nullable(ドライバ列は NULL を返し得る)。
25
+ */
26
+ export declare function sqlTypeIsNotNull(sqlType: string): boolean;
13
27
  /**
14
28
  * SQL 型(DDL のトークン。`DECIMAL(10,2)` 等の括弧やサイズは無視)→ bc outType スカラ。
15
29
  * spec §4.1 の正規表に一致。未知/曖昧は throw(fail-closed)。
@@ -48,7 +62,18 @@ export type MaterializeClass = 'int32' | 'int64' | 'date' | 'bool' | 'passthroug
48
62
  * `int` scalar splits int32/int64 by width; `date`/`bool` get their own class; everything else is
49
63
  * `passthrough`.
50
64
  */
65
+ export declare function arrayElementType(sqlType: string): string | null;
51
66
  export declare function sqlTypeToMaterializeClass(sqlType: string): MaterializeClass;
67
+ /**
68
+ * The bc scalar of a de-boxed READ KEY value — the element type a relation key-array (`pluck` → `.as`)
69
+ * carries when it is bound to `= ANY($1)` / `json_each(?)` (#141, spec §4.1). A key array is an opaque
70
+ * transport value list, so its bc element tag is the JS type of the READ-materialized key cell, NOT the
71
+ * column's `sqlTypeToBcScalar` outType: an `int32` column materializes to a JS `number` (bc `float`),
72
+ * a `BIGINT`/`int64` to a decimal STRING (bc `string`), a `date` to a string, a `bool` to a boolean.
73
+ * Derived by composing {@link sqlTypeToMaterializeClass} (the read de-box class) with the base scalar,
74
+ * so it stays the SINGLE type-system SoT — no hand-rolled type table at the relation call site.
75
+ */
76
+ export declare function keyArrayElemScalar(sqlType: string): BcScalar;
52
77
  /**
53
78
  * Coerce ONE raw driver cell to the JS form its {@link MaterializeClass} declares (issue #59 TS
54
79
  * read-path de-box). NULL passes through (nullable columns). This is driver-agnostic: it accepts
@@ -100,7 +125,7 @@ export declare function failClosedMaterializeResolverFromColumnMap(columnTypes:
100
125
  * `outType` SoT). THROWS for an unknown `table`/`column` (no-assume, no-fallback — a typed-native
101
126
  * read must not silently box an untyped column). Built from the model's INLINE `columns` declaration
102
127
  * at registration, it replaces the external `schemaColumnTypeResolver(ddl)` as the codegen type
103
- * source, so `deriveReadOutTypes` reads the declared types.
128
+ * source, so `deriveReadRow` (the read de-box SSoT) reads the declared types.
104
129
  */
105
130
  export declare function columnTypeResolverFromColumnMap(columnTypes: ReadonlyMap<string, ReadonlyMap<string, string>>): ColumnTypeResolver;
106
131
  /** {@link sqlTypeToMaterializeClass} but TOLERANT: returns `undefined` for an unknown SQL type. */
@@ -1 +1 @@
1
- {"version":3,"file":"coltype.d.ts","sourceRoot":"","sources":["../../src/scp/coltype.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,0EAA0E;AAC1E,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpE;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CA+D3D;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC;AAEnF;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,gBA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AAM,CAAC,CAAC,GAC5D,mBAAmB,CAKrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,0CAA0C,CACxD,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC5D,mBAAmB,CAQrB;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAC7C,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC5D,kBAAkB,CAmBpB;AAED,mGAAmG;AACnG,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAMzF;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAwB/F;AAyCD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,kBAAkB,CAqBnF"}
@@ -10,8 +10,12 @@
10
10
  * 行/リレーションの構造型(`obj`/`arr`/`opt`)は列型ではなくクエリ由来なので本変換の対象外。
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.normalizeSqlTypeToken = normalizeSqlTypeToken;
14
+ exports.sqlTypeIsNotNull = sqlTypeIsNotNull;
13
15
  exports.sqlTypeToBcScalar = sqlTypeToBcScalar;
16
+ exports.arrayElementType = arrayElementType;
14
17
  exports.sqlTypeToMaterializeClass = sqlTypeToMaterializeClass;
18
+ exports.keyArrayElemScalar = keyArrayElemScalar;
15
19
  exports.materializeCell = materializeCell;
16
20
  exports.materializeResolverFromColumnMap = materializeResolverFromColumnMap;
17
21
  exports.failClosedMaterializeResolverFromColumnMap = failClosedMaterializeResolverFromColumnMap;
@@ -20,20 +24,39 @@ exports.materializeClassOrUndefined = materializeClassOrUndefined;
20
24
  exports.parseSchemaColumnTypes = parseSchemaColumnTypes;
21
25
  exports.schemaColumnTypeResolver = schemaColumnTypeResolver;
22
26
  /**
23
- * SQL 型(DDL のトークン。`DECIMAL(10,2)` 等の括弧やサイズは無視)→ bc outType スカラ。
24
- * spec §4.1 の正規表に一致。未知/曖昧は throw(fail-closed)。
27
+ * SQL 型トークンを基底型名へ正規化する SSoT(`sqlTypeToBcScalar` / `sqlTypeToMaterializeClass` が共有)。
28
+ * 括弧のサイズ/精度と、型判定に無関係な列修飾(`UNSIGNED`/`ZEROFILL`/`PRECISION` と NULL 可否
29
+ * `NOT NULL`/`NULL`)を落として基底型名だけを残す。NULL 可否は {@link sqlTypeIsNotNull} が別に読む
30
+ * (型スカラと直交する — nullability は outType の `opt` ラップの有無、基底スカラではない)。
25
31
  */
26
- function sqlTypeToBcScalar(sqlType) {
27
- // 括弧のサイズ/精度・`UNSIGNED` 等の修飾を落として基底型名で判定。
28
- const t = sqlType
32
+ function normalizeSqlTypeToken(sqlType) {
33
+ return sqlType
29
34
  .trim()
30
35
  .toUpperCase()
31
36
  .replace(/\(.*\)/, '')
32
- .replace(/\b(UNSIGNED|ZEROFILL|PRECISION)\b/g, '')
37
+ .replace(/\b(UNSIGNED|ZEROFILL|PRECISION|NOT\s+NULL|NULL)\b/g, '')
33
38
  .replace(/\s+/g, ' ')
34
39
  .trim();
40
+ }
41
+ /**
42
+ * 宣言された SQL 型が `NOT NULL` 制約を持つか(`static columns` は列制約を型トークンに書ける)。
43
+ * `true` の列は読み出しセルが非 null 確定 → 読み outType は `opt` ラップ無しの生スカラ(RETURNING の
44
+ * 主キーのような非 null 値を value 位置で消費できる — spec §4.1 の nullability)。既定(無指定)は
45
+ * nullable(ドライバ列は NULL を返し得る)。
46
+ */
47
+ function sqlTypeIsNotNull(sqlType) {
48
+ return /\bNOT\s+NULL\b/i.test(sqlType);
49
+ }
50
+ /**
51
+ * SQL 型(DDL のトークン。`DECIMAL(10,2)` 等の括弧やサイズは無視)→ bc outType スカラ。
52
+ * spec §4.1 の正規表に一致。未知/曖昧は throw(fail-closed)。
53
+ */
54
+ function sqlTypeToBcScalar(sqlType) {
55
+ const t = normalizeSqlTypeToken(sqlType);
35
56
  switch (t) {
36
57
  // int は既定 64bit(i64)。INTEGER も BIGINT も int(bigint を別型にしない — サイズ制限は列制約で表現)。
58
+ // PostgreSQL の SERIAL/SERIAL4/BIGSERIAL/SERIAL8/SMALLSERIAL/SERIAL2(auto-increment 疑似型)も
59
+ // 基底は整数(int4 / int8)で、read 型は plain integer。
37
60
  case 'INTEGER':
38
61
  case 'INT':
39
62
  case 'BIGINT':
@@ -43,6 +66,12 @@ function sqlTypeToBcScalar(sqlType) {
43
66
  case 'INT2':
44
67
  case 'INT4':
45
68
  case 'INT8':
69
+ case 'SERIAL':
70
+ case 'SERIAL4':
71
+ case 'BIGSERIAL':
72
+ case 'SERIAL8':
73
+ case 'SMALLSERIAL':
74
+ case 'SERIAL2':
46
75
  return 'int';
47
76
  // int と real は明確に分離。
48
77
  case 'REAL':
@@ -92,16 +121,25 @@ function sqlTypeToBcScalar(sqlType) {
92
121
  * `int` scalar splits int32/int64 by width; `date`/`bool` get their own class; everything else is
93
122
  * `passthrough`.
94
123
  */
124
+ function arrayElementType(sqlType) {
125
+ const m = /^(.+?)\s*\[\s*\]$/.exec(normalizeSqlTypeToken(sqlType));
126
+ return m === null ? null : m[1].trim();
127
+ }
95
128
  function sqlTypeToMaterializeClass(sqlType) {
96
- const t = sqlType
97
- .trim()
98
- .toUpperCase()
99
- .replace(/\(.*\)/, '')
100
- .replace(/\b(UNSIGNED|ZEROFILL|PRECISION)\b/g, '')
101
- .replace(/\s+/g, ' ')
102
- .trim();
129
+ const t = normalizeSqlTypeToken(sqlType);
130
+ // An ARRAY column (`TEXT[]` / `INT[]` / `NUMERIC[]` / `BOOLEAN[]` / `TIMESTAMP[]` / …) de-boxes as
131
+ // `passthrough`: the driver's own array typeCast already parses the wire form into a JS array whose
132
+ // ELEMENTS match the declared element outType, so the read path leaves the value unchanged (no
133
+ // per-cell coercion — a scalar materialize class does not apply to a whole list). The element base
134
+ // type is still validated (an unknown element type on a DECLARED array column is a hard error too).
135
+ const element = arrayElementType(t);
136
+ if (element !== null) {
137
+ sqlTypeToMaterializeClass(element); // validate the element base type (throws if unknown)
138
+ return 'passthrough';
139
+ }
103
140
  switch (t) {
104
- // 32-bit int family: JS number holds the full range exactly.
141
+ // 32-bit int family: JS number holds the full range exactly. The PostgreSQL SERIAL family maps to
142
+ // its underlying int width (SERIAL/SERIAL4=int4, SMALLSERIAL/SERIAL2=int2).
105
143
  case 'INTEGER':
106
144
  case 'INT':
107
145
  case 'SMALLINT':
@@ -109,10 +147,16 @@ function sqlTypeToMaterializeClass(sqlType) {
109
147
  case 'MEDIUMINT':
110
148
  case 'INT2':
111
149
  case 'INT4':
150
+ case 'SERIAL':
151
+ case 'SERIAL4':
152
+ case 'SMALLSERIAL':
153
+ case 'SERIAL2':
112
154
  return 'int32';
113
155
  // 64-bit int: needs JS bigint for exactness.
114
156
  case 'BIGINT':
115
157
  case 'INT8':
158
+ case 'BIGSERIAL':
159
+ case 'SERIAL8':
116
160
  return 'int64';
117
161
  case 'BOOLEAN':
118
162
  case 'BOOL':
@@ -148,6 +192,29 @@ function sqlTypeToMaterializeClass(sqlType) {
148
192
  `are a hard error (no-assume, no-fallback), never defaulted.`);
149
193
  }
150
194
  }
195
+ /**
196
+ * The bc scalar of a de-boxed READ KEY value — the element type a relation key-array (`pluck` → `.as`)
197
+ * carries when it is bound to `= ANY($1)` / `json_each(?)` (#141, spec §4.1). A key array is an opaque
198
+ * transport value list, so its bc element tag is the JS type of the READ-materialized key cell, NOT the
199
+ * column's `sqlTypeToBcScalar` outType: an `int32` column materializes to a JS `number` (bc `float`),
200
+ * a `BIGINT`/`int64` to a decimal STRING (bc `string`), a `date` to a string, a `bool` to a boolean.
201
+ * Derived by composing {@link sqlTypeToMaterializeClass} (the read de-box class) with the base scalar,
202
+ * so it stays the SINGLE type-system SoT — no hand-rolled type table at the relation call site.
203
+ */
204
+ function keyArrayElemScalar(sqlType) {
205
+ switch (sqlTypeToMaterializeClass(sqlType)) {
206
+ case 'int32':
207
+ return 'float'; // materializes to a JS number → bc float
208
+ case 'int64':
209
+ case 'date':
210
+ return 'string'; // materializes to a decimal / TZ string → bc string
211
+ case 'bool':
212
+ return 'bool';
213
+ case 'passthrough':
214
+ // float stays a JS number (bc float); text / uuid / decimal-as-string / json are all bc string.
215
+ return sqlTypeToBcScalar(sqlType) === 'float' ? 'float' : 'string';
216
+ }
217
+ }
151
218
  /**
152
219
  * Coerce ONE raw driver cell to the JS form its {@link MaterializeClass} declares (issue #59 TS
153
220
  * read-path de-box). NULL passes through (nullable columns). This is driver-agnostic: it accepts
@@ -272,7 +339,7 @@ function failClosedMaterializeResolverFromColumnMap(columnTypes) {
272
339
  * `outType` SoT). THROWS for an unknown `table`/`column` (no-assume, no-fallback — a typed-native
273
340
  * read must not silently box an untyped column). Built from the model's INLINE `columns` declaration
274
341
  * at registration, it replaces the external `schemaColumnTypeResolver(ddl)` as the codegen type
275
- * source, so `deriveReadOutTypes` reads the declared types.
342
+ * source, so `deriveReadRow` (the read de-box SSoT) reads the declared types.
276
343
  */
277
344
  function columnTypeResolverFromColumnMap(columnTypes) {
278
345
  return (table, column) => {
@@ -1 +1 @@
1
- {"version":3,"file":"coltype.js","sourceRoot":"","sources":["../../src/scp/coltype.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AASH,8CA+DC;AAoCD,8DAyDC;AAcD,0CAsDC;AAqCD,4EAOC;AAWD,gGAUC;AASD,0EAqBC;AAGD,kEAMC;AAWD,wDAwBC;AA8CD,4DAqBC;AAlbD;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,OAAe;IAC/C,yCAAyC;IACzC,MAAM,CAAC,GAAG,OAAO;SACd,IAAI,EAAE;SACN,WAAW,EAAE;SACb,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;SACrB,OAAO,CA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module is the **API REFERENCE** for Phase C — the 4 native ports (rust #88 / go #89 / py #90
5
+ * / php #91) mirror THIS contract exactly (config field names + defaults, the connection-registry
6
+ * shape, `withWriter` semantics, and the `connectionFor(intent)` resolution ORDER). It builds ON the
7
+ * Phase A {@link import('./exec-context').ExecutionContext} seam and the Phase A/B owned-connection
8
+ * transaction runtime; it does NOT re-implement the seam — it supplies the pieces
9
+ * {@link import('./exec-context').PooledAsyncContext.connectionFor} uses to complete its resolution.
10
+ *
11
+ * ## The `connectionFor(intent)` resolution order (design §3, v1 `DBModel.ts:313` parity)
12
+ *
13
+ * A statement's connection is resolved in THIS priority (first match wins):
14
+ * 1. **active tx connection** — inside a transaction, always the tx-owned connection (Phase A).
15
+ * 2. **writer scope / writer-sticky** — inside {@link withWriter}, or within `writerStickyDuration`
16
+ * after a transaction (read-your-writes), a READ goes to the WRITER pool (Phase C — here).
17
+ * 3. **read=reader / write=writer** — otherwise a read goes to the reader pool, a write to the
18
+ * writer pool (reader/writer separation; single-pool config ⇒ reader === writer, Phase C).
19
+ * 4. **named-DB routing** — the target pool is selected by `intent.db` (the connection NAME carried
20
+ * by the bundle/model metadata) against the {@link ConnectionRegistry}; absent ⇒ the DEFAULT
21
+ * connection. Named-DB selection happens FIRST (it picks WHICH connection's reader/writer split
22
+ * steps 2-3 then apply to), so the order above is really: pick the named connection, then within
23
+ * it apply tx-pin / writer-sticky / reader-writer. (Phase C, decorator-free — the routing key is
24
+ * config + bundle/model metadata; decorator wiring is Phase F.)
25
+ *
26
+ * ## Backward-compat (the hard constraint)
27
+ *
28
+ * Single DB, `reader === writer` (one pool), empty config, unnamed connection ⇒ BYTE-IDENTICAL to the
29
+ * Phase A/B single-pool behavior. A {@link ConnectionRegistry} built from ONE pool routes every
30
+ * intent to that ONE pool, and the writer-sticky clock only ever diverts to a pool that is the SAME
31
+ * object — so nothing observable changes. The existing `new PooledAsyncContext(pool)` /
32
+ * `new PooledAsyncContext(pool, middleware)` constructors keep working unchanged.
33
+ */
34
+ import type { AsyncConnectionPool } from './exec-context';
35
+ /**
36
+ * Per-connection database config (C3) — the knobs a pool is built with. Mirrors v1
37
+ * `DBConfig`/`DBHandler` (`src/DBHandler.ts`, `src/types.ts`): connection target + pool sizing +
38
+ * per-statement/keepalive/session knobs. Every field is optional with a documented default; the 4
39
+ * native ports MUST expose the SAME field names + defaults. This is a DATA contract — it describes
40
+ * how to BUILD a pool; the actual `pg.Pool` / `mysql2.createPool` construction lives in the driver
41
+ * adapters (`makesql/pool-executor.ts`), which read these fields.
42
+ */
43
+ export interface ConnectionConfig {
44
+ /** Driver dialect for this connection. @default 'postgres' */
45
+ readonly driver?: 'postgres' | 'mysql' | 'sqlite';
46
+ /** DB host (server-based dialects). */
47
+ readonly host?: string;
48
+ /** DB port. */
49
+ readonly port?: number;
50
+ /** DB name (or file path for sqlite). */
51
+ readonly database?: string;
52
+ /** Username. */
53
+ readonly user?: string;
54
+ /** Password. */
55
+ readonly password?: string;
56
+ /**
57
+ * Per-statement timeout in MILLISECONDS. Applied as a session `statement_timeout` (PG) /
58
+ * `max_execution_time` (MySQL) so a runaway query is aborted by the SERVER. `0`/absent ⇒ no
59
+ * statement timeout (the engine default). v1 exposed this as `queryTimeout` in SECONDS on the pg
60
+ * CLIENT (`query_timeout`); the v2 contract is server-side ms so it fires uniformly across drivers.
61
+ * @default 0 (no timeout)
62
+ */
63
+ readonly queryTimeout?: number;
64
+ /** Enable TCP keepalive on pooled connections (recommended for serverless). @default false */
65
+ readonly keepAlive?: boolean;
66
+ /** ms before the first keepalive probe. @default 10000 (when keepAlive) */
67
+ readonly keepAliveInitialDelayMillis?: number;
68
+ /** Minimum pooled connections kept warm. @default 0 */
69
+ readonly minPool?: number;
70
+ /** Maximum pooled connections. @default 10 */
71
+ readonly maxPool?: number;
72
+ /** PG `search_path` set on each pooled connection at checkout (schema routing). */
73
+ readonly searchPath?: string;
74
+ /** MySQL connection charset / PG client_encoding set on each pooled connection. */
75
+ readonly charset?: string;
76
+ }
77
+ /** The resolved (defaults-applied) config the pool builder consumes — no `undefined` holes on the knobs. */
78
+ export interface ResolvedConnectionConfig {
79
+ readonly driver: 'postgres' | 'mysql' | 'sqlite';
80
+ readonly host?: string;
81
+ readonly port?: number;
82
+ readonly database?: string;
83
+ readonly user?: string;
84
+ readonly password?: string;
85
+ readonly queryTimeout: number;
86
+ readonly keepAlive: boolean;
87
+ readonly keepAliveInitialDelayMillis: number;
88
+ readonly minPool: number;
89
+ readonly maxPool: number;
90
+ readonly searchPath?: string;
91
+ readonly charset?: string;
92
+ }
93
+ /** Apply the C3 defaults (queryTimeout=0, keepAlive=false, minPool=0, maxPool=10). */
94
+ export declare function resolveConnectionConfig(config?: ConnectionConfig): ResolvedConnectionConfig;
95
+ /**
96
+ * The SESSION statements a connection must run at checkout to honor a {@link ResolvedConnectionConfig}
97
+ * (issued once per acquired connection, in order). This is the per-dialect mapping the port agents
98
+ * mirror; it is pure (no connection contact) so it is testable in isolation:
99
+ *
100
+ * - **statement timeout** (`queryTimeout` > 0): PG `SET statement_timeout = <ms>`; MySQL
101
+ * `SET SESSION max_execution_time = <ms>` (both server-side, ms).
102
+ * - **searchPath**: PG `SET search_path TO <path>`; MySQL has no schema search path ⇒ ignored.
103
+ * - **charset**: MySQL `SET NAMES <charset>`; PG `SET client_encoding TO <charset>`.
104
+ *
105
+ * A key with no value emits nothing (⇒ empty array for an all-default config ⇒ the session is
106
+ * untouched, backward-compatible). sqlite has no server session ⇒ empty.
107
+ */
108
+ export declare function sessionStatements(config: ResolvedConnectionConfig): readonly string[];
109
+ /**
110
+ * A reader/writer pool PAIR for ONE named connection (C1). `reader` serves read-intent statements;
111
+ * `writer` serves write-intent statements, `withWriter` reads, and writer-sticky reads. When a
112
+ * connection has no separate replica, `reader === writer` is the SAME pool object — reader/writer
113
+ * routing then always lands on that one pool (the single-pool backward-compat case).
114
+ */
115
+ export interface ReaderWriterPools {
116
+ readonly reader: AsyncConnectionPool;
117
+ readonly writer: AsyncConnectionPool;
118
+ }
119
+ /** Build a {@link ReaderWriterPools} where reader === writer (single-pool, backward-compat). */
120
+ export declare function singlePoolPair(pool: AsyncConnectionPool): ReaderWriterPools;
121
+ /** Build a {@link ReaderWriterPools} from a distinct reader + writer pool (reader/writer separation). */
122
+ export declare function readerWriterPair(reader: AsyncConnectionPool, writer: AsyncConnectionPool): ReaderWriterPools;
123
+ /** The reserved name of the DEFAULT (unnamed) connection. An `intent.db` of `undefined` uses this. */
124
+ export declare const DEFAULT_CONNECTION = "default";
125
+ /**
126
+ * The multi-DB connection registry (C2): a map from a connection NAME → its {@link ReaderWriterPools}.
127
+ * `connectionFor(intent)` selects the pair by `intent.db` (the connection name the bundle/model
128
+ * metadata carries — decorator-free, from config + metadata; decorator wiring is Phase F), falling
129
+ * back to {@link DEFAULT_CONNECTION} when unnamed. Selecting a name that was never registered is a
130
+ * LOUD error (a real wiring bug — never a silent default fallback, which would run a query on the
131
+ * wrong DB; mirrors the V0 cross-DB relation registry's loud-fail policy).
132
+ *
133
+ * A single-DB deployment registers exactly one connection under {@link DEFAULT_CONNECTION} with
134
+ * `reader === writer` ⇒ every intent routes to that one pool ⇒ byte-identical to Phase A/B.
135
+ */
136
+ export declare class ConnectionRegistry {
137
+ /** name → reader/writer pools. */
138
+ private readonly connections;
139
+ constructor(connections: ReadonlyMap<string, ReaderWriterPools>);
140
+ /**
141
+ * Build a registry from ONE pool as the default connection (reader === writer). This is the
142
+ * backward-compat path: {@link import('./exec-context').PooledAsyncContext} built from a single
143
+ * pool wraps it here so its `connectionFor` routes every intent to that one pool.
144
+ */
145
+ static singleDefault(pool: AsyncConnectionPool): ConnectionRegistry;
146
+ /** Fluent builder: start from a default connection's pools, then `.add(name, pools)` more. */
147
+ static fromDefault(pools: ReaderWriterPools): ConnectionRegistryBuilder;
148
+ /** The reader/writer pair for `name` (or {@link DEFAULT_CONNECTION} when `undefined`). Loud on a missing name. */
149
+ pairFor(name: string | undefined): ReaderWriterPools;
150
+ /** The registered connection names (for diagnostics / `closeAllPools`). */
151
+ names(): readonly string[];
152
+ /** Every DISTINCT pool object across all connections (a shared reader===writer counts once). */
153
+ distinctPools(): readonly AsyncConnectionPool[];
154
+ }
155
+ /** Incremental {@link ConnectionRegistry} builder (name → pools). */
156
+ export declare class ConnectionRegistryBuilder {
157
+ private readonly connections;
158
+ /** Register `name` → its reader/writer pools (chainable). Re-adding a name overwrites it. */
159
+ add(name: string, pools: ReaderWriterPools): this;
160
+ /** Finalize into an immutable {@link ConnectionRegistry}. */
161
+ build(): ConnectionRegistry;
162
+ }
163
+ /** True if the current async scope is inside a {@link withWriter} scope. */
164
+ export declare function inWriterScope(): boolean;
165
+ /**
166
+ * Run `fn` with reads pinned to the WRITER pool (mirror v1 `DBModel.withWriter`): every read `fn`
167
+ * issues resolves the writer pool (read-your-writes without replication lag), and — because this ALSO
168
+ * enters a {@link import('./tx-options').withReadOnly} scope — ANY write inside `fn` throws
169
+ * {@link import('../types').WriteInReadOnlyContextError}. Nested `withWriter` is idempotent (already
170
+ * in a writer scope ⇒ just run `fn`). Inside a transaction the tx-owned connection already wins in
171
+ * `connectionFor`, so a `withWriter` there is a no-op on routing (matches v1 :2941).
172
+ *
173
+ * @param fn the read-your-writes scope body.
174
+ */
175
+ export declare function withWriter<R>(fn: () => Promise<R>): Promise<R>;
176
+ /**
177
+ * A writer-sticky CLOCK (C1, read-your-writes; v1 `_shouldUseWriterSticky` :344 + `_lastTransactionTime`).
178
+ * After a transaction (or a bare write) COMMITs, reads within `stickyDurationMs` route to the WRITER
179
+ * pool so a just-committed row is visible despite reader-replica lag. The ctx owns ONE clock instance;
180
+ * the tx runtime `.mark()`s it on every successful write/commit; `connectionFor` reads `.isSticky()`.
181
+ *
182
+ * `useWriterAfterTransaction=false` disables it entirely (`.isSticky()` always false). A single-pool
183
+ * deployment (reader === writer) is unaffected by stickiness — the diverted pool is the same object.
184
+ */
185
+ export declare class WriterStickyClock {
186
+ private lastWriteAt;
187
+ private readonly enabled;
188
+ private readonly stickyDurationMs;
189
+ /** Injectable clock (tests advance it); defaults to `Date.now`. */
190
+ private readonly now;
191
+ constructor(opts?: {
192
+ useWriterAfterTransaction?: boolean;
193
+ writerStickyDuration?: number;
194
+ now?: () => number;
195
+ });
196
+ /** Record that a write/commit just happened (the tx runtime calls this on success). */
197
+ mark(): void;
198
+ /** Is a read currently sticky-to-writer (within `writerStickyDuration` of the last write)? */
199
+ isSticky(): boolean;
200
+ /** Reset the clock (e.g. between tests / on `closeAllPools`). */
201
+ reset(): void;
202
+ }
203
+ /**
204
+ * The routing configuration a {@link import('./exec-context').PooledAsyncContext} carries to complete
205
+ * its `connectionFor(intent)` resolution (steps 2-4): the multi-DB {@link ConnectionRegistry}, the
206
+ * {@link WriterStickyClock}, and the resolved per-connection {@link ResolvedConnectionConfig} (for the
207
+ * session statements the pool applies). Absent ⇒ the ctx falls back to its single default pool with
208
+ * an always-false sticky clock — the byte-identical Phase A/B path.
209
+ */
210
+ export interface RoutingConfig {
211
+ readonly registry: ConnectionRegistry;
212
+ readonly sticky: WriterStickyClock;
213
+ }
214
+ /**
215
+ * Resolve WHICH pool serves a statement given its {@link import('./exec-context').StatementIntent}
216
+ * and the routing config — the completion of `connectionFor`'s steps 2-4 (step 1, the tx-pin, is
217
+ * handled by the ctx BEFORE calling this, since only the ctx holds the ALS pin). The order:
218
+ *
219
+ * 1. **named-DB** (`intent.db`) selects the {@link ReaderWriterPools} pair (loud on unknown name).
220
+ * 2. within that pair: a WRITE ⇒ the writer pool.
221
+ * 3. a READ in a {@link withWriter} scope OR within writer-sticky ⇒ the writer pool (read-your-writes).
222
+ * 4. otherwise a READ ⇒ the reader pool.
223
+ *
224
+ * Single-pool (reader === writer) ⇒ every branch returns the same pool (backward-compat).
225
+ */
226
+ export declare function resolvePool(intent: {
227
+ readonly write: boolean;
228
+ readonly db?: string;
229
+ }, routing: RoutingConfig): AsyncConnectionPool;
230
+ /**
231
+ * The RESET statements that undo {@link sessionStatements} on release (per dialect), so a session
232
+ * knob (`statement_timeout` / `search_path` / `client_encoding` / `max_execution_time` / charset)
233
+ * set for THIS configured connection does NOT leak to the next caller that draws the SAME underlying
234
+ * pooled connection — pg/mysql2 do NOT auto-reset session state on release. `RESET`/`SET … DEFAULT`
235
+ * restores the server default. Only the knobs `config` actually set are reset (an all-default config
236
+ * ⇒ nothing to reset).
237
+ */
238
+ export declare function sessionResetStatements(config: ResolvedConnectionConfig): readonly string[];
239
+ /**
240
+ * Wrap an {@link AsyncConnectionPool} so every acquired connection first runs the
241
+ * {@link sessionStatements} for `config` (statement timeout / search_path / charset) and, on release,
242
+ * runs {@link sessionResetStatements} to restore the server defaults (so a pooled connection never
243
+ * leaks THIS config's session state to the next caller — pg/mysql2 don't auto-reset on release). A
244
+ * config with no session knobs (all defaults) ⇒ ZERO extra statements ⇒ the wrapper is a transparent
245
+ * passthrough (backward-compat). This is where C3's `queryTimeout`/`searchPath`/`charset` become REAL
246
+ * per-server effects — the acquired connection carries them for the statement(s) that run on it.
247
+ *
248
+ * If a session statement itself fails (e.g. an invalid search_path), the connection is released back
249
+ * as DESTROYED so a mis-configured connection never re-enters the pool. On release, if a statement
250
+ * ERRORED (the connection is possibly aborted — e.g. a fired statement timeout), the reset is SKIPPED
251
+ * and the connection is DESTROYED (a poisoned connection must not re-enter the pool anyway).
252
+ */
253
+ export declare function configuredPool(pool: AsyncConnectionPool, config: ResolvedConnectionConfig): AsyncConnectionPool;
254
+ /** A pool CLOSER — closes a pool's underlying connections (pg `pool.end()` / mysql2 `pool.end()`). */
255
+ export type PoolCloser = () => Promise<void>;
256
+ /**
257
+ * A driver's pool factory: BUILD a pool from a {@link ResolvedConnectionConfig}, returning the
258
+ * {@link AsyncConnectionPool} seam adapter plus a {@link PoolCloser}. This is where the CONSTRUCTION
259
+ * knobs — pool sizing (`minPool`/`maxPool`) + `keepAlive`/`keepAliveInitialDelayMillis` — reach the
260
+ * real driver (`new pg.Pool({ max, keepAlive, … })` / `mysql2.createPool({ connectionLimit, … })`),
261
+ * because those are pool-CONSTRUCTION options a pre-built pool can no longer accept.
262
+ *
263
+ * `buildRoutingConfig` OWNS the call to this factory with the RESOLVED config, so the configured
264
+ * sizing/keepAlive is the SOLE source of the pool's cap — there is no second raw `new Pool({max})`
265
+ * path. `role` lets a factory build a distinct replica pool for the reader vs. the writer (e.g. a
266
+ * different host) while sharing the same sizing config; a factory that returns the SAME pool for both
267
+ * roles collapses to single-pool (reader === writer).
268
+ *
269
+ * The module stays driver-AGNOSTIC: the factory is supplied by the peer-dep-owning caller (this file
270
+ * imports no driver). The pool-executor adapters (`makesql/pool-executor.ts`) provide the concrete
271
+ * pg/mysql2 factories; the port agents (#88-91) supply their language's equivalent — the SAME shape.
272
+ */
273
+ export type PoolFactory = (config: ResolvedConnectionConfig, role: 'reader' | 'writer') => {
274
+ pool: AsyncConnectionPool;
275
+ close: PoolCloser;
276
+ };
277
+ /**
278
+ * One connection's inputs to {@link buildRoutingConfig}: its NAME (default when absent), its
279
+ * {@link ConnectionConfig} (connection params + sizing + keepAlive + session knobs), and a
280
+ * {@link PoolFactory} that `buildRoutingConfig` CALLS with the resolved config to construct the
281
+ * pool(s) — so sizing/keepAlive are applied at construction and the config is the sole cap source.
282
+ *
283
+ * `separateWriter: true` asks the factory for a DISTINCT writer pool (reader/writer replica split);
284
+ * otherwise the factory's reader pool is reused as the writer (single-pool, reader === writer).
285
+ */
286
+ export interface ConnectionSetup {
287
+ readonly name?: string;
288
+ readonly config?: ConnectionConfig;
289
+ /** The driver pool factory (built by `buildRoutingConfig` with the resolved config — sizing/keepAlive land here). */
290
+ readonly poolFactory: PoolFactory;
291
+ /** Build a distinct writer pool via the factory (replica split). Default false ⇒ reader === writer. */
292
+ readonly separateWriter?: boolean;
293
+ }
294
+ /**
295
+ * The C3 `setConfig` result: the {@link RoutingConfig} a {@link import('./exec-context').PooledAsyncContext}
296
+ * runs on, plus a `close()` that shuts every constructed pool ({@link closeAllPools}). Build it from
297
+ * one or more {@link ConnectionSetup}s (the one named `default`, or the first unnamed, is the default
298
+ * connection).
299
+ *
300
+ * For each setup: resolve the config, CALL its {@link PoolFactory} to construct the pool(s) — so
301
+ * `minPool`/`maxPool`/`keepAlive`/`keepAliveInitialDelayMillis` are applied at `new Pool()` /
302
+ * `createPool()` time (the config is the SOLE source of the cap) — then wrap each pool with
303
+ * {@link configuredPool} so the SESSION knobs (queryTimeout/searchPath/charset) apply on checkout.
304
+ */
305
+ export declare function buildRoutingConfig(setups: readonly ConnectionSetup[], stickyOpts?: {
306
+ useWriterAfterTransaction?: boolean;
307
+ writerStickyDuration?: number;
308
+ }): {
309
+ routing: RoutingConfig;
310
+ close: PoolCloser;
311
+ };
312
+ //# sourceMappingURL=connection-routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-routing.d.ts","sourceRoot":"","sources":["../../src/scp/connection-routing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAI1D;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;IAClD,uCAAuC;IACvC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe;IACf,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,yCAAyC;IACzC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB;IAChB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,8FAA8F;IAC9F,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC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