postgrelize 0.0.0-stage → 1.1.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 (319) hide show
  1. package/CHANGELOG.md +289 -0
  2. package/LICENSE +21 -0
  3. package/README.md +131 -2
  4. package/dist/associations/alias-minifier.d.ts +43 -0
  5. package/dist/associations/association-accessors.d.ts +21 -0
  6. package/dist/associations/association-key-types.d.ts +44 -0
  7. package/dist/associations/association-keys.d.ts +98 -0
  8. package/dist/associations/association-lookup.d.ts +26 -0
  9. package/dist/associations/association-shape.d.ts +25 -0
  10. package/dist/associations/association.d.ts +95 -0
  11. package/dist/associations/belongs-to-many.d.ts +86 -0
  12. package/dist/associations/belongs-to.d.ts +45 -0
  13. package/dist/associations/has-many.d.ts +79 -0
  14. package/dist/associations/has-one.d.ts +44 -0
  15. package/dist/associations/include-assembler.d.ts +21 -0
  16. package/dist/associations/include-columns.d.ts +24 -0
  17. package/dist/associations/include-joins.d.ts +17 -0
  18. package/dist/associations/include-loader.d.ts +48 -0
  19. package/dist/associations/include-order.d.ts +22 -0
  20. package/dist/associations/include-query-builder.d.ts +54 -0
  21. package/dist/associations/include-resolver.d.ts +29 -0
  22. package/dist/associations/include-rows.d.ts +47 -0
  23. package/dist/associations/include-sub-query.d.ts +35 -0
  24. package/dist/associations/include.d.ts +112 -0
  25. package/dist/associations/junction-keys.d.ts +23 -0
  26. package/dist/associations/nested-creator.d.ts +44 -0
  27. package/dist/associations/nested-saver.d.ts +30 -0
  28. package/dist/associations/owner-keys.d.ts +34 -0
  29. package/dist/associations/separate-include-loader.d.ts +24 -0
  30. package/dist/associations/types.d.ts +139 -0
  31. package/dist/connection/after-connect-hook.d.ts +24 -0
  32. package/dist/connection/connect-hooks.d.ts +26 -0
  33. package/dist/connection/connection-config.d.ts +33 -0
  34. package/dist/connection/connection-manager.d.ts +65 -0
  35. package/dist/connection/connection-types.d.ts +21 -0
  36. package/dist/connection/copy-from-stdin.d.ts +52 -0
  37. package/dist/connection/copy-runner.d.ts +30 -0
  38. package/dist/connection/copy-to-stdout.d.ts +49 -0
  39. package/dist/connection/copy.d.ts +22 -0
  40. package/dist/connection/notifications.d.ts +28 -0
  41. package/dist/connection/options.d.ts +165 -0
  42. package/dist/connection/query-logger.d.ts +41 -0
  43. package/dist/connection/replica-router.d.ts +20 -0
  44. package/dist/connection/statement-cache.d.ts +36 -0
  45. package/dist/connection/statement-timeout.d.ts +22 -0
  46. package/dist/data-types/abstract-data-type.d.ts +58 -0
  47. package/dist/data-types/array-literal-parser.d.ts +17 -0
  48. package/dist/data-types/array-type.d.ts +18 -0
  49. package/dist/data-types/bit-type.d.ts +14 -0
  50. package/dist/data-types/blob-type.d.ts +12 -0
  51. package/dist/data-types/char-type.d.ts +12 -0
  52. package/dist/data-types/composite-fields.d.ts +26 -0
  53. package/dist/data-types/composite-type.d.ts +32 -0
  54. package/dist/data-types/data-types.d.ts +176 -0
  55. package/dist/data-types/date-type.d.ts +14 -0
  56. package/dist/data-types/decimal-type.d.ts +13 -0
  57. package/dist/data-types/default-value-generator.d.ts +15 -0
  58. package/dist/data-types/enum-type.d.ts +19 -0
  59. package/dist/data-types/ewkb-reader.d.ts +18 -0
  60. package/dist/data-types/ewkb-writer.d.ts +17 -0
  61. package/dist/data-types/float-type.d.ts +12 -0
  62. package/dist/data-types/geometric-text.d.ts +65 -0
  63. package/dist/data-types/geometric-type.d.ts +46 -0
  64. package/dist/data-types/hstore-type.d.ts +16 -0
  65. package/dist/data-types/integer-type.d.ts +24 -0
  66. package/dist/data-types/json-type.d.ts +16 -0
  67. package/dist/data-types/multirange-type.d.ts +19 -0
  68. package/dist/data-types/range-type.d.ts +28 -0
  69. package/dist/data-types/record-text.d.ts +29 -0
  70. package/dist/data-types/scalar-type.d.ts +13 -0
  71. package/dist/data-types/spatial-type.d.ts +20 -0
  72. package/dist/data-types/string-type.d.ts +12 -0
  73. package/dist/data-types/text-type.d.ts +12 -0
  74. package/dist/data-types/timestamp-type.d.ts +15 -0
  75. package/dist/data-types/virtual-type.d.ts +15 -0
  76. package/dist/data-types/wall-clock.d.ts +14 -0
  77. package/dist/ddl/column-ddl.d.ts +73 -0
  78. package/dist/ddl/constraint-ddl.d.ts +30 -0
  79. package/dist/ddl/ddl-generator.d.ts +181 -0
  80. package/dist/ddl/ddl-guards.d.ts +60 -0
  81. package/dist/ddl/ddl-types.d.ts +204 -0
  82. package/dist/ddl/enum-ddl.d.ts +42 -0
  83. package/dist/ddl/extension-ddl.d.ts +57 -0
  84. package/dist/ddl/function-ddl.d.ts +98 -0
  85. package/dist/ddl/index-ddl.d.ts +29 -0
  86. package/dist/ddl/index-element-ddl.d.ts +19 -0
  87. package/dist/ddl/partition-ddl.d.ts +88 -0
  88. package/dist/ddl/partition-types.d.ts +94 -0
  89. package/dist/ddl/policy-ddl.d.ts +137 -0
  90. package/dist/ddl/routine-guards.d.ts +63 -0
  91. package/dist/ddl/sequence-ddl.d.ts +103 -0
  92. package/dist/ddl/sql-literal.d.ts +61 -0
  93. package/dist/ddl/table-ddl.d.ts +35 -0
  94. package/dist/ddl/trigger-ddl.d.ts +81 -0
  95. package/dist/ddl/view-ddl.d.ts +122 -0
  96. package/dist/decorators/association-applier.d.ts +18 -0
  97. package/dist/decorators/association-decorators.d.ts +72 -0
  98. package/dist/decorators/column-decorators.d.ts +147 -0
  99. package/dist/decorators/decorator-factory.d.ts +45 -0
  100. package/dist/decorators/decorator-signature.d.ts +26 -0
  101. package/dist/decorators/decorator-types.d.ts +24 -0
  102. package/dist/decorators/foreign-key-decorator.d.ts +21 -0
  103. package/dist/decorators/hook-decorators.d.ts +393 -0
  104. package/dist/decorators/init-arguments.d.ts +29 -0
  105. package/dist/decorators/model-decorators.d.ts +18 -0
  106. package/dist/decorators/model-metadata.d.ts +70 -0
  107. package/dist/decorators/table-decorators.d.ts +43 -0
  108. package/dist/decorators/timestamp-decorators.d.ts +38 -0
  109. package/dist/errors/base-error.d.ts +40 -0
  110. package/dist/errors/connection-errors.d.ts +152 -0
  111. package/dist/errors/database-errors.d.ts +186 -0
  112. package/dist/errors/errors.d.ts +5 -0
  113. package/dist/errors/map-pg-error.d.ts +27 -0
  114. package/dist/errors/misc-errors.d.ts +232 -0
  115. package/dist/errors/validation-errors.d.ts +141 -0
  116. package/dist/exports-associations.d.ts +6 -0
  117. package/dist/exports-core.d.ts +95 -0
  118. package/dist/exports-decorators.d.ts +8 -0
  119. package/dist/exports-errors.d.ts +2 -0
  120. package/dist/exports-model.d.ts +21 -0
  121. package/dist/exports-schema.d.ts +19 -0
  122. package/dist/expressions/call-expressions.d.ts +54 -0
  123. package/dist/expressions/condition-expressions.d.ts +51 -0
  124. package/dist/expressions/expression.d.ts +52 -0
  125. package/dist/expressions/jsonpath-helpers.d.ts +37 -0
  126. package/dist/expressions/logic.d.ts +25 -0
  127. package/dist/expressions/methods.d.ts +188 -0
  128. package/dist/expressions/op.d.ts +182 -0
  129. package/dist/expressions/query-expressions.d.ts +110 -0
  130. package/dist/expressions/row-expressions.d.ts +35 -0
  131. package/dist/expressions/search-helpers.d.ts +138 -0
  132. package/dist/expressions/trigram-helpers.d.ts +40 -0
  133. package/dist/hooks/hooks.d.ts +125 -0
  134. package/dist/index.cjs +21864 -0
  135. package/dist/index.cjs.map +1 -0
  136. package/dist/index.d.ts +6 -0
  137. package/dist/index.js +21688 -0
  138. package/dist/index.js.map +1 -0
  139. package/dist/model/attribute-columns.d.ts +85 -0
  140. package/dist/model/attribute-normalizer.d.ts +42 -0
  141. package/dist/model/attribute-options.d.ts +121 -0
  142. package/dist/model/bulk-insert-builder.d.ts +24 -0
  143. package/dist/model/bulk-options.d.ts +173 -0
  144. package/dist/model/copy-options.d.ts +51 -0
  145. package/dist/model/cte-builder.d.ts +134 -0
  146. package/dist/model/definition-normalizer.d.ts +26 -0
  147. package/dist/model/delete-query-builder.d.ts +42 -0
  148. package/dist/model/find-options.d.ts +144 -0
  149. package/dist/model/find-query-builder.d.ts +38 -0
  150. package/dist/model/inflector.d.ts +28 -0
  151. package/dist/model/insert-query-builder.d.ts +41 -0
  152. package/dist/model/instance-destroyer.d.ts +44 -0
  153. package/dist/model/instance-lifecycle-services.d.ts +61 -0
  154. package/dist/model/instance-lifecycle.d.ts +128 -0
  155. package/dist/model/instance-saver.d.ts +25 -0
  156. package/dist/model/instance-state.d.ts +48 -0
  157. package/dist/model/instance-validation.d.ts +35 -0
  158. package/dist/model/instance-values.d.ts +88 -0
  159. package/dist/model/instance-writer.d.ts +59 -0
  160. package/dist/model/join-source-builder.d.ts +25 -0
  161. package/dist/model/lateral-keys-builder.d.ts +25 -0
  162. package/dist/model/merge-action-builder.d.ts +31 -0
  163. package/dist/model/merge-options.d.ts +72 -0
  164. package/dist/model/merge-query-builder.d.ts +29 -0
  165. package/dist/model/merge-source-builder.d.ts +22 -0
  166. package/dist/model/mixins/model-aggregates.d.ts +69 -0
  167. package/dist/model/mixins/model-associations.d.ts +113 -0
  168. package/dist/model/mixins/model-constructor.d.ts +7 -0
  169. package/dist/model/mixins/model-finders.d.ts +140 -0
  170. package/dist/model/mixins/model-hooks.d.ts +142 -0
  171. package/dist/model/mixins/model-postgres.d.ts +198 -0
  172. package/dist/model/mixins/model-schema-binding.d.ts +36 -0
  173. package/dist/model/mixins/model-schema.d.ts +100 -0
  174. package/dist/model/mixins/model-scopes.d.ts +57 -0
  175. package/dist/model/mixins/model-writers.d.ts +175 -0
  176. package/dist/model/mixins/named-hooks.d.ts +28 -0
  177. package/dist/model/model-accessors.d.ts +22 -0
  178. package/dist/model/model-base.d.ts +83 -0
  179. package/dist/model/model-definition.d.ts +130 -0
  180. package/dist/model/model-instance-persistence.d.ts +132 -0
  181. package/dist/model/model-instance-values.d.ts +197 -0
  182. package/dist/model/model-operations.d.ts +22 -0
  183. package/dist/model/model-registry.d.ts +152 -0
  184. package/dist/model/model-services.d.ts +46 -0
  185. package/dist/model/model-state.d.ts +68 -0
  186. package/dist/model/model-values.d.ts +86 -0
  187. package/dist/model/model.d.ts +629 -0
  188. package/dist/model/on-conflict-builder.d.ts +111 -0
  189. package/dist/model/operations/bulk-create-operation.d.ts +40 -0
  190. package/dist/model/operations/copy-from-source.d.ts +51 -0
  191. package/dist/model/operations/copy-operation.d.ts +54 -0
  192. package/dist/model/operations/count-operation.d.ts +52 -0
  193. package/dist/model/operations/create-operation.d.ts +31 -0
  194. package/dist/model/operations/destroy-operation.d.ts +65 -0
  195. package/dist/model/operations/find-cursor.d.ts +23 -0
  196. package/dist/model/operations/find-lookups.d.ts +99 -0
  197. package/dist/model/operations/find-operation.d.ts +47 -0
  198. package/dist/model/operations/increment-operation.d.ts +40 -0
  199. package/dist/model/operations/insert-operation.d.ts +71 -0
  200. package/dist/model/operations/merge-operation.d.ts +56 -0
  201. package/dist/model/operations/model-operation.d.ts +33 -0
  202. package/dist/model/operations/update-operation.d.ts +45 -0
  203. package/dist/model/operations/upsert-operation.d.ts +39 -0
  204. package/dist/model/options.d.ts +103 -0
  205. package/dist/model/returning-old.d.ts +52 -0
  206. package/dist/model/row-mapper.d.ts +78 -0
  207. package/dist/model/row-plan.d.ts +31 -0
  208. package/dist/model/runtime.d.ts +56 -0
  209. package/dist/model/scope-registry.d.ts +81 -0
  210. package/dist/model/select-aggregates.d.ts +37 -0
  211. package/dist/model/select-lock.d.ts +13 -0
  212. package/dist/model/select-options.d.ts +92 -0
  213. package/dist/model/select-query-builder.d.ts +73 -0
  214. package/dist/model/select-targets.d.ts +77 -0
  215. package/dist/model/source-option-builder.d.ts +23 -0
  216. package/dist/model/source-options.d.ts +108 -0
  217. package/dist/model/statement-builder.d.ts +77 -0
  218. package/dist/model/statement-services.d.ts +2 -0
  219. package/dist/model/sync-hooks.d.ts +18 -0
  220. package/dist/model/table-sample-builder.d.ts +13 -0
  221. package/dist/model/types.d.ts +85 -0
  222. package/dist/model/unnest-insert-builder.d.ts +24 -0
  223. package/dist/model/update-query-builder.d.ts +39 -0
  224. package/dist/model/v6-conflict-builder.d.ts +37 -0
  225. package/dist/model/value-cloner.d.ts +17 -0
  226. package/dist/model/values-writer.d.ts +12 -0
  227. package/dist/model/where-options.d.ts +164 -0
  228. package/dist/model/write-options.d.ts +160 -0
  229. package/dist/model/written-rows.d.ts +56 -0
  230. package/dist/package-version.d.ts +8 -0
  231. package/dist/query/query-result-shaper.d.ts +93 -0
  232. package/dist/query/raw-query.d.ts +27 -0
  233. package/dist/query-interface/alter-planner.d.ts +40 -0
  234. package/dist/query-interface/bulk-data.d.ts +44 -0
  235. package/dist/query-interface/column-commands.d.ts +52 -0
  236. package/dist/query-interface/column-describer.d.ts +17 -0
  237. package/dist/query-interface/enum-commands.d.ts +36 -0
  238. package/dist/query-interface/index-commands.d.ts +57 -0
  239. package/dist/query-interface/model-tables.d.ts +58 -0
  240. package/dist/query-interface/object-commands.d.ts +71 -0
  241. package/dist/query-interface/partition-commands.d.ts +43 -0
  242. package/dist/query-interface/policy-commands.d.ts +54 -0
  243. package/dist/query-interface/query-interface-catalog.d.ts +180 -0
  244. package/dist/query-interface/query-interface-objects.d.ts +108 -0
  245. package/dist/query-interface/query-interface-partitions.d.ts +66 -0
  246. package/dist/query-interface/query-interface-policies.d.ts +86 -0
  247. package/dist/query-interface/query-interface-routines.d.ts +120 -0
  248. package/dist/query-interface/query-interface-tables.d.ts +179 -0
  249. package/dist/query-interface/query-interface-types.d.ts +62 -0
  250. package/dist/query-interface/query-interface-views.d.ts +84 -0
  251. package/dist/query-interface/query-interface.d.ts +256 -0
  252. package/dist/query-interface/routine-commands.d.ts +71 -0
  253. package/dist/query-interface/schema-synchronizer.d.ts +110 -0
  254. package/dist/query-interface/statement-runner.d.ts +40 -0
  255. package/dist/query-interface/sync-planner.d.ts +26 -0
  256. package/dist/query-interface/table-commands.d.ts +63 -0
  257. package/dist/query-interface/table-introspector.d.ts +58 -0
  258. package/dist/query-interface/view-commands.d.ts +47 -0
  259. package/dist/sequelize/instance-hook-adders.d.ts +72 -0
  260. package/dist/sequelize/sequelize-base.d.ts +196 -0
  261. package/dist/sequelize/sequelize-constructor.d.ts +7 -0
  262. package/dist/sequelize/sequelize-helpers.d.ts +133 -0
  263. package/dist/sequelize/sequelize-hooks.d.ts +99 -0
  264. package/dist/sequelize/sequelize-internals.d.ts +87 -0
  265. package/dist/sequelize/sequelize-notifications.d.ts +66 -0
  266. package/dist/sequelize/sequelize-schema.d.ts +125 -0
  267. package/dist/sequelize/sequelize-transactions.d.ts +96 -0
  268. package/dist/sequelize.d.ts +1175 -0
  269. package/dist/sql/ast-clauses.d.ts +137 -0
  270. package/dist/sql/ast-expressions.d.ts +88 -0
  271. package/dist/sql/ast-statements.d.ts +80 -0
  272. package/dist/sql/ast.d.ts +21 -0
  273. package/dist/sql/compile.d.ts +21 -0
  274. package/dist/sql/dml-compiler.d.ts +54 -0
  275. package/dist/sql/expression-compiler.d.ts +56 -0
  276. package/dist/sql/from-compiler.d.ts +39 -0
  277. package/dist/sql/identifier-quoter.d.ts +15 -0
  278. package/dist/sql/merge-compiler.d.ts +20 -0
  279. package/dist/sql/order.d.ts +15 -0
  280. package/dist/sql/query-compiler.d.ts +45 -0
  281. package/dist/sql/sql-chunks.d.ts +50 -0
  282. package/dist/sql/with-compiler.d.ts +19 -0
  283. package/dist/transaction/advisory-locks.d.ts +28 -0
  284. package/dist/transaction/cls-namespace.d.ts +44 -0
  285. package/dist/transaction/transaction-constants.d.ts +35 -0
  286. package/dist/transaction/transaction-runner.d.ts +78 -0
  287. package/dist/transaction/transaction-starter.d.ts +25 -0
  288. package/dist/transaction/transaction-statements.d.ts +29 -0
  289. package/dist/transaction/transaction.d.ts +201 -0
  290. package/dist/validation/attribute-validators.d.ts +23 -0
  291. package/dist/validation/builtin-attribute-validator.d.ts +19 -0
  292. package/dist/validation/builtin-validators.d.ts +16 -0
  293. package/dist/validation/core-validator.d.ts +16 -0
  294. package/dist/validation/custom-validators.d.ts +13 -0
  295. package/dist/validation/instance-validator.d.ts +25 -0
  296. package/dist/validation/schema-items.d.ts +22 -0
  297. package/dist/validation/standard-schema-validator.d.ts +30 -0
  298. package/dist/validation/standard-schema.d.ts +39 -0
  299. package/dist/validation/types.d.ts +36 -0
  300. package/dist/validation/validation-target.d.ts +13 -0
  301. package/dist/where/comparison-compiler.d.ts +27 -0
  302. package/dist/where/condition-compiler.d.ts +18 -0
  303. package/dist/where/operand-resolver.d.ts +10 -0
  304. package/dist/where/operator-allowlist.d.ts +14 -0
  305. package/dist/where/where-support.d.ts +52 -0
  306. package/dist/where/where.d.ts +46 -0
  307. package/dist/where/window-compiler.d.ts +14 -0
  308. package/llm/USAGE.md +423 -0
  309. package/package.json +103 -4
  310. package/skills/postgrelize/SKILL.md +57 -0
  311. package/skills/postgrelize/reference/associations.md +108 -0
  312. package/skills/postgrelize/reference/errors.md +37 -0
  313. package/skills/postgrelize/reference/migrating-from-sequelize.md +15 -0
  314. package/skills/postgrelize/reference/postgresql-features.md +157 -0
  315. package/skills/postgrelize/reference/querying.md +111 -0
  316. package/skills/postgrelize/reference/schema.md +135 -0
  317. package/skills/postgrelize/reference/security.md +34 -0
  318. package/skills/postgrelize/reference/transactions-and-sessions.md +122 -0
  319. package/skills/postgrelize/reference/writing.md +198 -0
@@ -0,0 +1,54 @@
1
+ import { ModelDefinition } from '../model/model-definition.ts';
2
+ import { ExprNode, JoinNode, SelectNode } from '../sql/ast.ts';
3
+ import { IncludeNode } from './include.ts';
4
+ /** Options of the main query that affect the include joins. */
5
+ export type IncludeQueryOptions = Readonly<{
6
+ /** `order` option (may reference includes). */
7
+ order?: unknown;
8
+ /** `limit` option. */
9
+ limit?: number | null;
10
+ /** `offset` option. */
11
+ offset?: number | null;
12
+ /** `subQuery: false` disables the sub-query form. */
13
+ subQuery?: boolean;
14
+ }>;
15
+ /**
16
+ * Adds include joins, columns and ordering to a SELECT of the main model (ADR-009): decides the
17
+ * v6 sub-query form for `limit` with multi includes, turns required includes into `EXISTS`
18
+ * filters there, and builds the joins of `count` with includes.
19
+ */
20
+ export declare class IncludeQueryBuilder {
21
+ #private;
22
+ /**
23
+ * Adds joins, include columns and include ordering to a SELECT built for the main model.
24
+ *
25
+ * @param definition - Main model definition.
26
+ * @param base - SELECT of the main model.
27
+ * @param includes - Include tree.
28
+ * @param options - Order / limit / offset / subQuery of the find.
29
+ * @returns SELECT with the includes.
30
+ */
31
+ build(definition: ModelDefinition, base: SelectNode, includes: readonly IncludeNode[], options: IncludeQueryOptions): SelectNode;
32
+ /**
33
+ * Whether `limit`/`offset` must go into a subquery of the main table (v6 rules). A top-level
34
+ * `where` that references a joined include cannot run inside that subquery, so it disables it.
35
+ *
36
+ * @param includes - Joined includes.
37
+ * @param options - Limit / offset / subQuery of the find.
38
+ * @param where - Compiled top-level condition.
39
+ * @returns True for the sub-query form.
40
+ */
41
+ needsSubQuery(includes: readonly IncludeNode[], options: Readonly<{
42
+ limit?: number | null;
43
+ offset?: number | null;
44
+ subQuery?: boolean;
45
+ }>, where?: ExprNode): boolean;
46
+ /**
47
+ * Joins for `count` with includes (no include columns).
48
+ *
49
+ * @param definition - Main model definition.
50
+ * @param includes - Include tree.
51
+ * @returns Join nodes.
52
+ */
53
+ countJoins(definition: ModelDefinition, includes: readonly IncludeNode[]): readonly JoinNode[];
54
+ }
@@ -0,0 +1,29 @@
1
+ import { AnyModel, ModelStatic } from '../model/options.ts';
2
+ import { IncludeNode, IncludeOption, IncludeOptions } from './include.ts';
3
+ type Model = ModelStatic<AnyModel>;
4
+ /**
5
+ * Normalizes the `include` option into an include tree: resolves associations by model, alias or
6
+ * association object, expands `{ all: true }` and injects the scope of the included model.
7
+ */
8
+ export declare class IncludeResolver {
9
+ #private;
10
+ /**
11
+ * Normalizes the `include` option of `source` into an include tree.
12
+ *
13
+ * @param source - Model the includes are resolved on.
14
+ * @param option - `include` option.
15
+ * @param parentAlias - Table alias of the parent include (`''` for the main model).
16
+ * @param parentPath - Result path of the parent include (`''` for the main model).
17
+ * @returns Include nodes.
18
+ * @throws EagerLoadingError when a model is not associated to `source`.
19
+ */
20
+ normalize(source: Model, option: IncludeOption | undefined, parentAlias?: string, parentPath?: string): readonly IncludeNode[];
21
+ /**
22
+ * Converts an include node back to include options.
23
+ *
24
+ * @param node - Include node.
25
+ * @returns Include options resolving to the same node.
26
+ */
27
+ toOptions(node: IncludeNode): IncludeOptions;
28
+ }
29
+ export {};
@@ -0,0 +1,47 @@
1
+ import { AttributeDefinition, ModelDefinition } from '../model/model-definition.ts';
2
+ import { AnyModel, ModelStatic } from '../model/options.ts';
3
+ import { IncludeNode } from './include.ts';
4
+ type Model = ModelStatic<AnyModel>;
5
+ /** Result row keyed by column alias (`Posts.title` for included columns). */
6
+ export type IncludeRow = Readonly<Record<string, unknown>>;
7
+ /** Builds an instance of `model` from loaded values. */
8
+ export type InstanceBuilder = (model: Model, values: Readonly<Record<string, unknown>>) => AnyModel;
9
+ /** Reads and parses the values of included models out of joined result rows. */
10
+ export declare class IncludeRows {
11
+ #private;
12
+ /**
13
+ * Value parsed with an attribute's data type.
14
+ *
15
+ * @param attribute - Attribute definition, if known.
16
+ * @param value - Raw value.
17
+ * @returns Parsed value (`null` / `undefined` are kept).
18
+ */
19
+ parseValue(attribute: AttributeDefinition | undefined, value: unknown): unknown;
20
+ /**
21
+ * Values of the columns directly under `path` (`Posts.title` → `title`), parsed.
22
+ *
23
+ * @param definition - Definition of the included model.
24
+ * @param row - Joined row.
25
+ * @param path - Result path of the include.
26
+ * @returns Attribute values.
27
+ */
28
+ valuesAt(definition: ModelDefinition, row: IncludeRow, path: string): Record<string, unknown>;
29
+ /**
30
+ * Identity of an instance for de-duplication: its primary key, else all values.
31
+ *
32
+ * @param definition - Model definition.
33
+ * @param values - Attribute values.
34
+ * @returns Identity, or `undefined` when every value is `null` (no row joined).
35
+ */
36
+ identity(definition: ModelDefinition, values: Readonly<Record<string, unknown>>): string | number | undefined;
37
+ /**
38
+ * Parses a joined raw row: included keys are parsed with the included model's data types.
39
+ *
40
+ * @param includes - Include tree.
41
+ * @param row - Joined row.
42
+ * @param parseMain - Parses a row with the main model's data types; must return a new object.
43
+ * @returns Parsed row.
44
+ */
45
+ parseRaw(includes: readonly IncludeNode[], row: IncludeRow, parseMain: (row: IncludeRow) => Readonly<Record<string, unknown>>): Record<string, unknown>;
46
+ }
47
+ export {};
@@ -0,0 +1,35 @@
1
+ import { ModelDefinition } from '../model/model-definition.ts';
2
+ import { ExprNode } from '../sql/ast.ts';
3
+ import { IncludeNode } from './include.ts';
4
+ import { IncludeJoins } from './include-joins.ts';
5
+ /** Decides the v6 sub-query form of a find with includes and builds its `EXISTS` filters. */
6
+ export declare class IncludeSubQuery {
7
+ #private;
8
+ /**
9
+ * @param joins - Builds the joins the `EXISTS` filters are made of.
10
+ */
11
+ constructor(joins: IncludeJoins);
12
+ /**
13
+ * Whether `limit`/`offset` must go into a subquery of the main table (v6 rules). A top-level
14
+ * `where` that references a joined include cannot run inside that subquery, so it disables it.
15
+ *
16
+ * @param includes - Joined includes.
17
+ * @param options - Limit / offset / subQuery of the find.
18
+ * @param where - Compiled top-level condition.
19
+ * @returns True for the sub-query form.
20
+ */
21
+ needsSubQuery(includes: readonly IncludeNode[], options: Readonly<{
22
+ limit?: number | null;
23
+ offset?: number | null;
24
+ subQuery?: boolean;
25
+ }>, where?: ExprNode): boolean;
26
+ /**
27
+ * `EXISTS` condition that keeps the rows of the main table having a matching required include.
28
+ *
29
+ * @param parent - Main model definition.
30
+ * @param parentAlias - Main table alias.
31
+ * @param node - Required include.
32
+ * @returns Condition.
33
+ */
34
+ existsFilter(parent: ModelDefinition, parentAlias: string, node: IncludeNode): ExprNode;
35
+ }
@@ -0,0 +1,112 @@
1
+ import { ModelDefinition } from '../model/model-definition.ts';
2
+ import { AnyModel, ModelStatic } from '../model/options.ts';
3
+ import { FindAttributeOptions } from '../model/select-query-builder.ts';
4
+ import { Association } from './types.ts';
5
+ type Model = ModelStatic<AnyModel>;
6
+ /**
7
+ * Options of the junction table of an included belongsToMany association.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const through: IncludeThroughOptions = { attributes: ['role'], where: { role: 'owner' } };
12
+ * const rows = await Project.findAll({ include: [{ model: User, through }] });
13
+ * ```
14
+ */
15
+ export type IncludeThroughOptions = Readonly<{
16
+ /** Junction attributes to select (`[]` for none). Default: all. */
17
+ attributes?: FindAttributeOptions;
18
+ /** Filter on junction rows; see {@link WhereOptions}. */
19
+ where?: unknown;
20
+ }>;
21
+ /**
22
+ * One `include` entry (Sequelize v6 `IncludeOptions`): which association to load and how.
23
+ *
24
+ * Name the association with `model`, `as` or `association`. Eager loading uses JOINs (see the guide), except `separate`, which runs another query.
25
+ *
26
+ * @see {@link FindOptions}
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const opts: IncludeOptions = {
31
+ * model: Post,
32
+ * as: 'posts',
33
+ * where: { published: true },
34
+ * required: false,
35
+ * attributes: ['id', 'title'],
36
+ * include: [{ model: Tag }],
37
+ * };
38
+ * const users = await User.findAll({ include: [opts] });
39
+ * ```
40
+ */
41
+ export type IncludeOptions = Readonly<{
42
+ /** Associated model; the association is looked up by model (and `as`). */
43
+ model?: Model;
44
+ /** Alias of the association, as given when it was defined. */
45
+ as?: string;
46
+ /** Association object or alias. */
47
+ association?: Association | string;
48
+ /** Filter on the included rows; makes the include required unless `required: false`. See {@link WhereOptions}. */
49
+ where?: unknown;
50
+ /** `INNER JOIN` (true) or `LEFT OUTER JOIN` (false). */
51
+ required?: boolean;
52
+ /** Use `RIGHT OUTER JOIN`.
53
+ * @defaultValue false */
54
+ right?: boolean;
55
+ /** Selected attributes. */
56
+ attributes?: FindAttributeOptions;
57
+ /** Nested includes. */
58
+ include?: IncludeOption;
59
+ /** Load a hasMany association with a separate query instead of a JOIN.
60
+ * @defaultValue false */
61
+ separate?: boolean;
62
+ /** Junction options for belongsToMany. */
63
+ through?: IncludeThroughOptions;
64
+ /**
65
+ * Fetch only the first `limit` rows per parent in the database (`JOIN LATERAL` over the parent
66
+ * keys) instead of loading every child and trimming in memory. Needs `separate` and `limit`.
67
+ * PostgreSQL extension.
68
+ *
69
+ * @defaultValue false
70
+ */
71
+ lateral?: boolean;
72
+ /** Order of a separate include. */
73
+ order?: unknown;
74
+ /** Maximum rows per include of a separate include. */
75
+ limit?: number;
76
+ /** For paranoid targets: `false` includes soft-deleted rows.
77
+ * @defaultValue true */
78
+ paranoid?: boolean;
79
+ /** Include every association of the model (`{ all: true }`).
80
+ * @defaultValue false */
81
+ all?: boolean;
82
+ }>;
83
+ /** `include` option: a model, an alias, include options, or a list of them. */
84
+ export type IncludeOption = Model | string | IncludeOptions | readonly (Model | string | IncludeOptions)[];
85
+ /** Normalized include. */
86
+ export type IncludeNode = Readonly<{
87
+ association: Association;
88
+ model: Model;
89
+ definition: ModelDefinition;
90
+ as: string;
91
+ alias: string;
92
+ path: string;
93
+ where: unknown;
94
+ required: boolean;
95
+ right: boolean;
96
+ attributes: FindAttributeOptions | undefined;
97
+ separate: boolean;
98
+ lateral: boolean;
99
+ paranoid: boolean;
100
+ order: unknown;
101
+ limit: number | undefined;
102
+ through: Readonly<{
103
+ model: Model;
104
+ definition: ModelDefinition;
105
+ alias: string;
106
+ path: string;
107
+ attributes: FindAttributeOptions | undefined;
108
+ where: unknown;
109
+ }> | undefined;
110
+ children: readonly IncludeNode[];
111
+ }>;
112
+ export {};
@@ -0,0 +1,23 @@
1
+ import { AnyModel, ModelStatic } from '../model/options.ts';
2
+ import { AssociationKeys, TargetKeys } from './association-keys.ts';
3
+ import { BelongsToManyOptions } from './types.ts';
4
+ type Model = ModelStatic<AnyModel>;
5
+ /** Resolves alias and keys of belongsToMany and defines the junction model's key attributes. */
6
+ export declare class JunctionKeys {
7
+ #private;
8
+ /**
9
+ * @param keys - Naming and foreign key attribute rules.
10
+ */
11
+ constructor(keys: AssociationKeys);
12
+ /**
13
+ * Resolves the alias and keys of a belongsToMany association, creating the junction model
14
+ * when given by name and adding both foreign key attributes to it.
15
+ *
16
+ * @param source - Model the association is defined on.
17
+ * @param target - Associated model.
18
+ * @param options - Association options with `through`.
19
+ * @returns Alias forms and keys (including the junction).
20
+ */
21
+ resolve(source: Model, target: Model, options: BelongsToManyOptions): TargetKeys;
22
+ }
23
+ export {};
@@ -0,0 +1,44 @@
1
+ import { AnyModel, SaveOptions } from '../model/options.ts';
2
+ import { IncludeNode } from './include.ts';
3
+ import { IncludeResolver } from './include-resolver.ts';
4
+ import { InstanceCheck } from './nested-saver.ts';
5
+ export type { InstanceCheck } from './nested-saver.ts';
6
+ /**
7
+ * Nested creation (`Model.create(values, { include })`, Sequelize v6): builds nested instances
8
+ * from the values, saves belongsTo parents before the instance and hasOne / hasMany /
9
+ * belongsToMany children (with their junction rows) after it.
10
+ */
11
+ export declare class NestedCreator {
12
+ #private;
13
+ /**
14
+ * @param resolver - Converts include nodes back to options for the nested builds.
15
+ * @param isInstance - Checks whether a value is a model instance.
16
+ */
17
+ constructor(resolver: IncludeResolver, isInstance: InstanceCheck);
18
+ /**
19
+ * Builds the nested instance(s) of an include from the given values; instances are kept.
20
+ *
21
+ * @param node - Include node.
22
+ * @param value - Values (a list for multi associations), an instance, or `null`.
23
+ * @returns Nested instance(s), or `null`.
24
+ */
25
+ build(node: IncludeNode, value: unknown): unknown;
26
+ /**
27
+ * Saves nested belongsTo parents and sets the foreign keys on the instance.
28
+ *
29
+ * @param instance - Instance being created.
30
+ * @param includes - Include tree of the instance.
31
+ * @param options - Save options (query options are passed on).
32
+ * @returns Resolves when the parents are saved.
33
+ */
34
+ saveBelongsTo(instance: AnyModel, includes: readonly IncludeNode[], options: SaveOptions): Promise<void>;
35
+ /**
36
+ * Saves nested hasOne / hasMany / belongsToMany children after the instance, one at a time.
37
+ *
38
+ * @param instance - Saved instance.
39
+ * @param includes - Include tree of the instance.
40
+ * @param options - Save options (query options are passed on).
41
+ * @returns Resolves when the children are saved.
42
+ */
43
+ saveChildren(instance: AnyModel, includes: readonly IncludeNode[], options: SaveOptions): Promise<void>;
44
+ }
@@ -0,0 +1,30 @@
1
+ import { AnyModel, SaveOptions } from '../model/options.ts';
2
+ import { IncludeNode } from './include.ts';
3
+ /** Tells model instances apart from plain values (injected to avoid importing `Model`). */
4
+ export type InstanceCheck = (value: unknown) => value is AnyModel;
5
+ /** Saves the nested instances of a nested creation, in the order Sequelize v6 does. */
6
+ export declare class NestedSaver {
7
+ #private;
8
+ /**
9
+ * @param isInstance - Checks whether a value is a model instance.
10
+ */
11
+ constructor(isInstance: InstanceCheck);
12
+ /**
13
+ * Saves nested belongsTo parents and sets the foreign keys on the instance.
14
+ *
15
+ * @param instance - Instance being created.
16
+ * @param includes - Include tree of the instance.
17
+ * @param options - Save options (query options are passed on).
18
+ * @returns Resolves when the parents are saved.
19
+ */
20
+ saveBelongsTo(instance: AnyModel, includes: readonly IncludeNode[], options: SaveOptions): Promise<void>;
21
+ /**
22
+ * Saves nested hasOne / hasMany / belongsToMany children after the instance, one at a time.
23
+ *
24
+ * @param instance - Saved instance.
25
+ * @param includes - Include tree of the instance.
26
+ * @param options - Save options (query options are passed on).
27
+ * @returns Resolves when the children are saved.
28
+ */
29
+ saveChildren(instance: AnyModel, includes: readonly IncludeNode[], options: SaveOptions): Promise<void>;
30
+ }
@@ -0,0 +1,34 @@
1
+ import { AnyModel, ModelStatic } from '../model/options.ts';
2
+ import { AssociationKeys, TargetKeys } from './association-keys.ts';
3
+ import { AssociationOptions } from './types.ts';
4
+ type Model = ModelStatic<AnyModel>;
5
+ /** Resolves alias and keys of belongsTo / hasOne / hasMany and adds the foreign key attribute. */
6
+ export declare class OwnerKeys {
7
+ #private;
8
+ /**
9
+ * @param keys - Naming and foreign key attribute rules.
10
+ */
11
+ constructor(keys: AssociationKeys);
12
+ /**
13
+ * Resolves the alias and keys of a belongsTo association and adds the foreign key attribute
14
+ * to the source.
15
+ *
16
+ * @param source - Model the association is defined on.
17
+ * @param target - Associated model.
18
+ * @param options - Association options.
19
+ * @returns Alias forms and keys.
20
+ */
21
+ belongsTo(source: Model, target: Model, options: AssociationOptions): TargetKeys;
22
+ /**
23
+ * Resolves the alias and keys of a hasOne / hasMany association and adds the foreign key
24
+ * attribute to the target.
25
+ *
26
+ * @param multi - True for hasMany.
27
+ * @param source - Model the association is defined on.
28
+ * @param target - Associated model.
29
+ * @param options - Association options.
30
+ * @returns Alias forms and keys.
31
+ */
32
+ hasOneOrMany(multi: boolean, source: Model, target: Model, options: AssociationOptions): TargetKeys;
33
+ }
34
+ export {};
@@ -0,0 +1,24 @@
1
+ import { AnyModel } from '../model/options.ts';
2
+ import { IncludeNode } from './include.ts';
3
+ import { IncludeResolver } from './include-resolver.ts';
4
+ type Instance = AnyModel;
5
+ type FindOptions = Readonly<Record<string, unknown>>;
6
+ /** Loads `separate: true` includes with one extra query each. */
7
+ export declare class SeparateIncludeLoader {
8
+ #private;
9
+ /**
10
+ * @param resolver - Converts include nodes back to options for the separate queries.
11
+ */
12
+ constructor(resolver: IncludeResolver);
13
+ /**
14
+ * Loads `separate: true` includes with one extra query each and attaches them, keeping at most
15
+ * `limit` rows per parent.
16
+ *
17
+ * @param parents - Instances the includes belong to.
18
+ * @param includes - Include tree.
19
+ * @param options - Find options (`transaction` is passed on).
20
+ * @returns Resolves when all separate includes are attached.
21
+ */
22
+ load(parents: readonly Instance[], includes: readonly IncludeNode[], options: FindOptions): Promise<void>;
23
+ }
24
+ export {};
@@ -0,0 +1,139 @@
1
+ import { AnyModel, ModelStatic } from '../model/options.ts';
2
+ /** Kind of association (Sequelize v6 `associationType`). */
3
+ export type AssociationType = 'BelongsTo' | 'HasOne' | 'HasMany' | 'BelongsToMany';
4
+ /** Singular and plural names of an association alias. */
5
+ export type AssociationName = Readonly<{
6
+ /** Singular form, used by single-item accessors (`addPost`). */
7
+ singular: string;
8
+ /** Plural form, used by multi-item accessors (`getPosts`). */
9
+ plural: string;
10
+ }>;
11
+ /**
12
+ * Foreign key given as an object instead of a plain name.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const fk: ForeignKeyOptions = { name: 'authorId', field: 'author_id', allowNull: false };
17
+ * User.hasMany(Post, { foreignKey: fk });
18
+ * ```
19
+ */
20
+ export type ForeignKeyOptions = Readonly<{
21
+ /** Attribute name. */
22
+ name?: string;
23
+ /** Column name. */
24
+ field?: string;
25
+ /** Whether the key may be `NULL`. */
26
+ allowNull?: boolean;
27
+ }>;
28
+ /**
29
+ * Options shared by all association methods (Sequelize v6 `AssociationOptions`).
30
+ *
31
+ * Used by `hasOne`, `hasMany`, `belongsTo` and (extended) `belongsToMany`.
32
+ *
33
+ * @see {@link Model.hasMany}
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const opts: AssociationOptions = {
38
+ * as: 'posts',
39
+ * foreignKey: { name: 'authorId', allowNull: false },
40
+ * onDelete: 'CASCADE',
41
+ * };
42
+ * User.hasMany(Post, opts);
43
+ * ```
44
+ */
45
+ export type AssociationOptions = Readonly<{
46
+ /** Alias: string, or `{ singular, plural }` for multi associations. Default: the target model name. */
47
+ as?: string | AssociationName;
48
+ /** Foreign key attribute name or options. */
49
+ foreignKey?: string | ForeignKeyOptions;
50
+ /** Attribute of the source referenced by the foreign key (hasOne / hasMany / belongsToMany). */
51
+ sourceKey?: string;
52
+ /** Attribute of the target referenced by the foreign key (belongsTo / belongsToMany). */
53
+ targetKey?: string;
54
+ /** Attribute values applied to associated rows (filter on read, values on write). */
55
+ scope?: Readonly<Record<string, unknown>>;
56
+ /** Create foreign key constraints on `sync()`.
57
+ * @defaultValue true */
58
+ constraints?: boolean;
59
+ /** `ON DELETE` action of the foreign key constraint, e.g. `'CASCADE'`. */
60
+ onDelete?: string;
61
+ /** `ON UPDATE` action of the foreign key constraint, e.g. `'CASCADE'`. */
62
+ onUpdate?: string;
63
+ }>;
64
+ /**
65
+ * Junction table of a belongsToMany association given as an object.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * const through: ThroughOptions = { model: 'ProjectTask', scope: { kind: 'member' } };
70
+ * Project.belongsToMany(Task, { through });
71
+ * ```
72
+ */
73
+ export type ThroughOptions = Readonly<{
74
+ /** Junction model, or the name of an implicit junction model to create. */
75
+ model: string | ModelStatic<AnyModel>;
76
+ /** Attribute values applied to junction rows. */
77
+ scope?: Readonly<Record<string, unknown>>;
78
+ }>;
79
+ /**
80
+ * Options of `belongsToMany`.
81
+ *
82
+ * Extends {@link AssociationOptions}; `foreignKey` is the junction column pointing at the source, `otherKey` the one pointing at the target.
83
+ *
84
+ * @see {@link Model.belongsToMany}
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * const opts: BelongsToManyOptions = { through: 'ProjectTask', foreignKey: 'projectId', otherKey: 'taskId' };
89
+ * Project.belongsToMany(Task, opts);
90
+ * ```
91
+ */
92
+ export type BelongsToManyOptions = AssociationOptions & Readonly<{
93
+ /** Junction model, its name, or options. */
94
+ through: string | ModelStatic<AnyModel> | ThroughOptions;
95
+ /** Junction foreign key pointing at the target. Default: derived from the target model name. */
96
+ otherKey?: string | ForeignKeyOptions;
97
+ }>;
98
+ /** Resolved junction of a belongsToMany association. */
99
+ export type AssociationThrough = Readonly<{
100
+ /** Junction model. */
101
+ model: ModelStatic<AnyModel>;
102
+ /** Attribute values applied to junction rows. */
103
+ scope?: Readonly<Record<string, unknown>>;
104
+ }>;
105
+ /** Association between two models (Sequelize v6 association object). */
106
+ export type Association = Readonly<{
107
+ /** Kind of association. */
108
+ associationType: AssociationType;
109
+ /** Model the association is defined on. */
110
+ source: ModelStatic<AnyModel>;
111
+ /** Associated model. */
112
+ target: ModelStatic<AnyModel>;
113
+ /** Alias used in `include` and as the instance property. */
114
+ as: string;
115
+ /** Singular and plural alias forms. */
116
+ name: AssociationName;
117
+ /** Whether `as` was given explicitly. */
118
+ isAliased: boolean;
119
+ /** Foreign key attribute (on the source for belongsTo, on the target for hasOne/hasMany, on the junction for belongsToMany). */
120
+ foreignKey: string;
121
+ /** Column of the foreign key. */
122
+ identifierField: string;
123
+ /** Source attribute referenced by the foreign key. */
124
+ sourceKey: string;
125
+ /** Target attribute referenced by the foreign key (belongsTo) or by `otherKey` (belongsToMany). */
126
+ targetKey: string;
127
+ /** Junction foreign key pointing at the target (belongsToMany). */
128
+ otherKey: string | undefined;
129
+ /** Junction model (belongsToMany). */
130
+ through: AssociationThrough | undefined;
131
+ /** Association scope. */
132
+ scope: Readonly<Record<string, unknown>> | undefined;
133
+ /** True for belongsTo / hasOne. */
134
+ isSingleAssociation: boolean;
135
+ /** True for hasMany / belongsToMany. */
136
+ isMultiAssociation: boolean;
137
+ /** Names of the instance methods added to the source model. */
138
+ accessors: Readonly<Record<string, string>>;
139
+ }>;
@@ -0,0 +1,24 @@
1
+ import { Client as PgClient, PoolConfig } from 'pg';
2
+ type PoolClientClass = NonNullable<PoolConfig['Client']>;
3
+ /** Errors thrown by an `afterConnect` hook; v6 surfaces them unchanged, so they skip connection error mapping. */
4
+ export declare const hookFailures: WeakSet<object>;
5
+ /**
6
+ * Runs the `afterConnect` hook on every new pooled connection, before the pool hands it out.
7
+ * `pg` has no portable async connect hook (`onConnect` needs a recent `pg-pool`), so the pool
8
+ * is given a `pg.Client` subclass whose `connect()` runs the hook once the client is connected;
9
+ * when the hook throws the client is closed and the error reaches the caller of the query.
10
+ */
11
+ export declare class AfterConnectHook {
12
+ #private;
13
+ /**
14
+ * @param run - Hook runner; receives the connected client.
15
+ */
16
+ constructor(run: (client: PgClient) => Promise<void>);
17
+ /**
18
+ * Client class for the `Client` pool option.
19
+ *
20
+ * @returns `pg.Client` subclass that runs the hook after connecting.
21
+ */
22
+ clientClass(): PoolClientClass;
23
+ }
24
+ export {};
@@ -0,0 +1,26 @@
1
+ import { PoolConfig } from 'pg';
2
+ import { HookRegistry } from '../hooks/hooks.ts';
3
+ import { ConnectionConfig as ConnectionSettings } from './options.ts';
4
+ /**
5
+ * Runs the connection hooks of a `Sequelize` instance: `beforeConnect` (may replace the password)
6
+ * and `afterConnect` (session setup on each new pooled connection).
7
+ *
8
+ * @internal
9
+ */
10
+ export declare class ConnectHooks {
11
+ #private;
12
+ /**
13
+ * @param hooks - Current hook registry of the instance.
14
+ * @param owner - The `Sequelize` instance (hook context and connection settings).
15
+ */
16
+ constructor(hooks: () => HookRegistry, owner: Readonly<{
17
+ config: ConnectionSettings;
18
+ }>);
19
+ /**
20
+ * Adds the hook handling to a pool configuration.
21
+ *
22
+ * @param config - Pool configuration.
23
+ * @returns Configuration whose password is resolved through `beforeConnect` and whose clients run `afterConnect`.
24
+ */
25
+ apply(config: PoolConfig): PoolConfig;
26
+ }
@@ -0,0 +1,33 @@
1
+ import { PoolConfig } from 'pg';
2
+ import { ConnectionConfig as ConnectionSettings, SequelizeOptions } from './options.ts';
3
+ type ConstructorArgs = readonly [SequelizeOptions?] | readonly [string, SequelizeOptions?] | readonly [string, string | null | undefined, (string | null | undefined)?, SequelizeOptions?];
4
+ /**
5
+ * Connection configuration of a `Sequelize` instance: normalizes the overloaded Sequelize v6
6
+ * constructor arguments and derives the `pg` pool configurations (writer and read replicas).
7
+ */
8
+ export declare class ConnectionConfig {
9
+ #private;
10
+ /** Normalized constructor options. */
11
+ readonly options: SequelizeOptions;
12
+ /**
13
+ * @param args - Arguments of the `Sequelize` constructor (URI, database / username / password, options).
14
+ * @throws Error for a non-postgres URI or dialect.
15
+ */
16
+ constructor(args: ConstructorArgs);
17
+ /**
18
+ * Connection settings exposed as `sequelize.config`.
19
+ *
20
+ * @returns Database, user name, password, host and port.
21
+ */
22
+ settings(): ConnectionSettings;
23
+ /**
24
+ * Pool configurations of the writer and the readers (no readers without `replication`).
25
+ *
26
+ * @returns Writer and reader `pg` pool configurations.
27
+ */
28
+ replicationPoolConfigs(): Readonly<{
29
+ write: PoolConfig;
30
+ read: readonly PoolConfig[];
31
+ }>;
32
+ }
33
+ export {};