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,188 @@
1
+ import { Cast, Col, Fn } from './call-expressions.ts';
2
+ import { Excluded, Json, Where } from './condition-expressions.ts';
3
+ import { SqlExpression, SqlExpressionVisitor } from './expression.ts';
4
+ import { Exists, Subquery } from './query-expressions.ts';
5
+ import { Over, Tuple } from './row-expressions.ts';
6
+ export { Cast, Col, Fn } from './call-expressions.ts';
7
+ export { Excluded, Json, Where } from './condition-expressions.ts';
8
+ export { SqlExpression, type SqlExpressionVisitor } from './expression.ts';
9
+ export { Exists, Subquery, WriteStatement, type SetOperationOptions } from './query-expressions.ts';
10
+ export { Over, Tuple } from './row-expressions.ts';
11
+ /** Raw SQL fragment inserted into a query as-is. Created by {@link literal}. */
12
+ export declare class Literal extends SqlExpression {
13
+ /** @internal */
14
+ static readonly kind = "Literal";
15
+ /** SQL text. */
16
+ readonly val: string;
17
+ /**
18
+ * @param val - SQL text.
19
+ */
20
+ constructor(val: string);
21
+ /** @internal */
22
+ accept<R>(visitor: SqlExpressionVisitor<R>): R;
23
+ }
24
+ /**
25
+ * Creates a raw SQL fragment. The text is not escaped — never pass user input.
26
+ *
27
+ * @param val - SQL text.
28
+ * @returns Literal expression.
29
+ * @example
30
+ * ```ts
31
+ * await Post.findAll({ order: [literal('"createdAt" DESC NULLS LAST')] });
32
+ * ```
33
+ */
34
+ export declare const literal: (val: string) => Literal;
35
+ /**
36
+ * Creates an SQL function call. Arguments are bound as parameters unless they are expressions.
37
+ *
38
+ * @param name - Function name, e.g. `'lower'`.
39
+ * @param args - Function arguments.
40
+ * @returns Function call expression.
41
+ * @example
42
+ * ```ts
43
+ * await User.findAll({ where: where(fn('lower', col('email')), 'a@b.c') });
44
+ * ```
45
+ */
46
+ export declare const fn: (name: string, ...args: readonly unknown[]) => Fn;
47
+ /**
48
+ * Creates a column reference. Dots separate table and column: `'user.id'`.
49
+ *
50
+ * @param name - Column name, optionally prefixed with a table alias.
51
+ * @returns Column expression.
52
+ * @example
53
+ * ```ts
54
+ * await Post.findAll({ attributes: [[fn('count', col('Post.id')), 'total']], group: [col('Post.userId')] });
55
+ * ```
56
+ */
57
+ export declare const col: (name: string) => Col;
58
+ /**
59
+ * Creates a type cast `CAST(value AS type)`.
60
+ *
61
+ * @param val - Value or expression to cast.
62
+ * @param type - PostgreSQL type name, e.g. `'integer'`.
63
+ * @returns Cast expression.
64
+ * @example
65
+ * ```ts
66
+ * await Product.findAll({ attributes: [[cast(col('price'), 'integer'), 'rounded']] });
67
+ * ```
68
+ */
69
+ export declare const cast: (val: unknown, type: string) => Cast;
70
+ /**
71
+ * Accesses a JSON(B) value by path (`json('meta.a.b')`) or builds JSON conditions
72
+ * (`json({ meta: { a: 1 } })`).
73
+ *
74
+ * @param conditionsOrPath - Dot-separated path, starting with the attribute name, or a conditions object.
75
+ * @param value - Value to compare with when a path is given.
76
+ * @returns JSON expression.
77
+ * @example
78
+ * ```ts
79
+ * await User.findAll({ where: json('meta.address.city', 'Berlin') });
80
+ * await User.findAll({ where: json({ meta: { active: true } }) });
81
+ * ```
82
+ */
83
+ export declare const json: (conditionsOrPath: string | object, value?: unknown) => Json;
84
+ /** Call signatures of {@link where}. */
85
+ export type WhereFactory = {
86
+ /**
87
+ * @param attribute - Left-hand expression.
88
+ * @param logic - Right-hand value or condition object, compared with `=`.
89
+ */
90
+ (attribute: unknown, logic: unknown): Where;
91
+ /**
92
+ * @param attribute - Left-hand expression.
93
+ * @param comparator - `Op.*` symbol or SQL operator string such as `'>='`.
94
+ * @param logic - Right-hand value.
95
+ */
96
+ (attribute: unknown, comparator: string | symbol, logic: unknown): Where;
97
+ };
98
+ /**
99
+ * Compares an expression with a value: `where(fn('lower', col('name')), 'bob')` or
100
+ * `where(col('age'), Op.gt, 18)`.
101
+ *
102
+ * @returns Where expression.
103
+ * @example
104
+ * ```ts
105
+ * await User.findAll({ where: where(fn('lower', col('name')), 'bob') });
106
+ * await User.findAll({ where: where(col('age'), Op.gt, 18) });
107
+ * ```
108
+ */
109
+ export declare const where: WhereFactory;
110
+ /**
111
+ * References the value proposed for insertion (`EXCLUDED."column"`) inside an `onConflict`
112
+ * update. PostgreSQL extension.
113
+ *
114
+ * @param attribute - Model attribute name.
115
+ * @returns Excluded column expression.
116
+ * @example
117
+ * ```ts
118
+ * const rows = [{ key: 'home', hits: 1 }];
119
+ * await Product.bulkCreate(rows, {
120
+ * onConflict: { target: ['key'], action: { update: { hits: excluded('hits') } } },
121
+ * });
122
+ * ```
123
+ */
124
+ export declare const excluded: (attribute: string) => Excluded;
125
+ /**
126
+ * `EXISTS (subquery)`. PostgreSQL extension.
127
+ *
128
+ * @param subquery - Subquery from `Model.subquery()`.
129
+ * @returns Condition usable as `where`.
130
+ * @example
131
+ * ```ts
132
+ * await User.findAll({ where: exists(Post.subquery({ where: { userId: col('User.id') } })) });
133
+ * ```
134
+ */
135
+ export declare const exists: (subquery: Subquery) => Exists;
136
+ /**
137
+ * `NOT EXISTS (subquery)`. PostgreSQL extension.
138
+ *
139
+ * @param subquery - Subquery from `Model.subquery()`.
140
+ * @returns Condition usable as `where`.
141
+ * @example
142
+ * ```ts
143
+ * await User.findAll({ where: notExists(Post.subquery({ where: { userId: col('User.id') } })) });
144
+ * ```
145
+ */
146
+ export declare const notExists: (subquery: Subquery) => Exists;
147
+ /**
148
+ * Window definition of {@link over}.
149
+ *
150
+ * @example
151
+ * ```ts
152
+ * const window: WindowOptions = { partitionBy: ['userId'], orderBy: [['createdAt', 'DESC']] };
153
+ * ```
154
+ */
155
+ export type WindowOptions = Readonly<{
156
+ /** `PARTITION BY` attributes or expressions. */
157
+ partitionBy?: readonly unknown[];
158
+ /** `ORDER BY` items: attribute, `[attribute, direction]` or expression. */
159
+ orderBy?: readonly unknown[];
160
+ }>;
161
+ /**
162
+ * Window function call: `over(fn('row_number'), { partitionBy: ['userId'], orderBy: [['createdAt', 'DESC']] })`.
163
+ * PostgreSQL extension.
164
+ *
165
+ * @param windowFunction - Function call, e.g. `fn('rank')`.
166
+ * @param window - Partition and order.
167
+ * @returns Expression usable in `attributes` and `order`.
168
+ * @example
169
+ * ```ts
170
+ * await Post.findAll({
171
+ * attributes: ['id', [over(fn('row_number'), { partitionBy: ['userId'], orderBy: [['createdAt', 'DESC']] }), 'rank']],
172
+ * });
173
+ * ```
174
+ */
175
+ export declare const over: (windowFunction: Fn | Literal, window?: WindowOptions) => Over;
176
+ /**
177
+ * Row constructor for row comparisons: `where(tuple(col('createdAt'), col('id')), Op.lt, tuple(date, id))`.
178
+ * PostgreSQL extension.
179
+ *
180
+ * @param items - Row items (values or expressions).
181
+ * @returns Row expression.
182
+ * @example
183
+ * ```ts
184
+ * const cursor = new Date();
185
+ * await Post.findAll({ where: where(tuple(col('createdAt'), col('id')), Op.lt, tuple(cursor, 100)) });
186
+ * ```
187
+ */
188
+ export declare const tuple: (...items: readonly unknown[]) => Tuple;
@@ -0,0 +1,182 @@
1
+ declare const eq: unique symbol;
2
+ declare const ne: unique symbol;
3
+ declare const gte: unique symbol;
4
+ declare const gt: unique symbol;
5
+ declare const lte: unique symbol;
6
+ declare const lt: unique symbol;
7
+ declare const not: unique symbol;
8
+ declare const is: unique symbol;
9
+ declare const inOp: unique symbol;
10
+ declare const notIn: unique symbol;
11
+ declare const like: unique symbol;
12
+ declare const notLike: unique symbol;
13
+ declare const iLike: unique symbol;
14
+ declare const notILike: unique symbol;
15
+ declare const startsWith: unique symbol;
16
+ declare const endsWith: unique symbol;
17
+ declare const substring: unique symbol;
18
+ declare const regexp: unique symbol;
19
+ declare const notRegexp: unique symbol;
20
+ declare const iRegexp: unique symbol;
21
+ declare const notIRegexp: unique symbol;
22
+ declare const between: unique symbol;
23
+ declare const notBetween: unique symbol;
24
+ declare const overlap: unique symbol;
25
+ declare const contains: unique symbol;
26
+ declare const contained: unique symbol;
27
+ declare const adjacent: unique symbol;
28
+ declare const strictLeft: unique symbol;
29
+ declare const strictRight: unique symbol;
30
+ declare const noExtendRight: unique symbol;
31
+ declare const noExtendLeft: unique symbol;
32
+ declare const and: unique symbol;
33
+ declare const or: unique symbol;
34
+ declare const any: unique symbol;
35
+ declare const all: unique symbol;
36
+ declare const values: unique symbol;
37
+ declare const col: unique symbol;
38
+ declare const placeholder: unique symbol;
39
+ declare const join: unique symbol;
40
+ declare const match: unique symbol;
41
+ declare const isDistinctFrom: unique symbol;
42
+ declare const isNotDistinctFrom: unique symbol;
43
+ declare const hasKey: unique symbol;
44
+ declare const hasAnyKeys: unique symbol;
45
+ declare const hasAllKeys: unique symbol;
46
+ declare const similarTo: unique symbol;
47
+ declare const notSimilarTo: unique symbol;
48
+ declare const jsonPathExists: unique symbol;
49
+ declare const containedOrEqual: unique symbol;
50
+ declare const containsOrEqual: unique symbol;
51
+ declare const trigramSimilar: unique symbol;
52
+ declare const trigramWordSimilar: unique symbol;
53
+ declare const trigramStrictWordSimilar: unique symbol;
54
+ declare const trigramHasSimilarWord: unique symbol;
55
+ declare const trigramHasSimilarStrictWord: unique symbol;
56
+ /**
57
+ * Query operators for `where` clauses.
58
+ *
59
+ * Symbols are created with `Symbol.for(name)` exactly like Sequelize v6, so operators imported
60
+ * from `sequelize` and from `postgrelize` are interchangeable. Operators marked "PostgreSQL
61
+ * extension" do not exist in Sequelize v6.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * await User.findAll({ where: { age: { [Op.gte]: 18 }, name: { [Op.iLike]: 'a%' } } });
66
+ * ```
67
+ */
68
+ export declare const Op: {
69
+ /** `= value`; `IS NULL` when the value is `null`. */
70
+ readonly eq: typeof eq;
71
+ /** `<> value`; `IS NOT NULL` when the value is `null`. */
72
+ readonly ne: typeof ne;
73
+ /** `>= value`. */
74
+ readonly gte: typeof gte;
75
+ /** `> value`. */
76
+ readonly gt: typeof gt;
77
+ /** `<= value`. */
78
+ readonly lte: typeof lte;
79
+ /** `< value`. */
80
+ readonly lt: typeof lt;
81
+ /** `IS NOT value` for `null`/booleans, otherwise negates a nested condition. */
82
+ readonly not: typeof not;
83
+ /** `IS value`, for `null`, `true` or `false`. */
84
+ readonly is: typeof is;
85
+ /** `IN (...)`; long lists compile to `= ANY($n)`. */
86
+ readonly in: typeof inOp;
87
+ /** `NOT IN (...)`; long lists compile to `<> ALL($n)`. */
88
+ readonly notIn: typeof notIn;
89
+ /** `LIKE pattern`. */
90
+ readonly like: typeof like;
91
+ /** `NOT LIKE pattern`. */
92
+ readonly notLike: typeof notLike;
93
+ /** `ILIKE pattern`. */
94
+ readonly iLike: typeof iLike;
95
+ /** `NOT ILIKE pattern`. */
96
+ readonly notILike: typeof notILike;
97
+ /** `LIKE 'value%'`. */
98
+ readonly startsWith: typeof startsWith;
99
+ /** `LIKE '%value'`. */
100
+ readonly endsWith: typeof endsWith;
101
+ /** `LIKE '%value%'`. */
102
+ readonly substring: typeof substring;
103
+ /** `~ pattern` (POSIX regular expression). */
104
+ readonly regexp: typeof regexp;
105
+ /** `!~ pattern`. */
106
+ readonly notRegexp: typeof notRegexp;
107
+ /** `~* pattern` (case-insensitive regular expression). */
108
+ readonly iRegexp: typeof iRegexp;
109
+ /** `!~* pattern`. */
110
+ readonly notIRegexp: typeof notIRegexp;
111
+ /** `BETWEEN a AND b`, value is `[a, b]`. */
112
+ readonly between: typeof between;
113
+ /** `NOT BETWEEN a AND b`, value is `[a, b]`. */
114
+ readonly notBetween: typeof notBetween;
115
+ /** `&&` — arrays or ranges overlap. */
116
+ readonly overlap: typeof overlap;
117
+ /** `@>` — array, range or jsonb contains the value. */
118
+ readonly contains: typeof contains;
119
+ /** `<@` — array, range or jsonb is contained by the value. */
120
+ readonly contained: typeof contained;
121
+ /** `-|-` — ranges are adjacent. */
122
+ readonly adjacent: typeof adjacent;
123
+ /** `<<` — range is strictly left of the value. */
124
+ readonly strictLeft: typeof strictLeft;
125
+ /** `>>` — range is strictly right of the value. */
126
+ readonly strictRight: typeof strictRight;
127
+ /** `&<` — range does not extend to the right of the value. */
128
+ readonly noExtendRight: typeof noExtendRight;
129
+ /** `&>` — range does not extend to the left of the value. */
130
+ readonly noExtendLeft: typeof noExtendLeft;
131
+ /** Logical AND of nested conditions. */
132
+ readonly and: typeof and;
133
+ /** Logical OR of nested conditions. */
134
+ readonly or: typeof or;
135
+ /** `ANY (ARRAY[...])`, combined with a comparison operator. */
136
+ readonly any: typeof any;
137
+ /** `ALL (ARRAY[...])`, combined with a comparison operator. */
138
+ readonly all: typeof all;
139
+ /** `VALUES (...)` list for `Op.any` / `Op.all`. */
140
+ readonly values: typeof values;
141
+ /** Compares with another column, value is a column reference such as `'user.id'`. */
142
+ readonly col: typeof col;
143
+ /** Reserved by Sequelize v6 for internal use. */
144
+ readonly placeholder: typeof placeholder;
145
+ /** Reserved by Sequelize v6 for internal use. */
146
+ readonly join: typeof join;
147
+ /** `@@` — tsvector matches tsquery. */
148
+ readonly match: typeof match;
149
+ /** `IS DISTINCT FROM value` (null-safe `<>`). PostgreSQL extension. */
150
+ readonly isDistinctFrom: typeof isDistinctFrom;
151
+ /** `IS NOT DISTINCT FROM value` (null-safe `=`). PostgreSQL extension. */
152
+ readonly isNotDistinctFrom: typeof isNotDistinctFrom;
153
+ /** jsonb `?` — top-level key exists. PostgreSQL extension. */
154
+ readonly hasKey: typeof hasKey;
155
+ /** jsonb `?|` — any of the keys exist. PostgreSQL extension. */
156
+ readonly hasAnyKeys: typeof hasAnyKeys;
157
+ /** jsonb `?&` — all of the keys exist. PostgreSQL extension. */
158
+ readonly hasAllKeys: typeof hasAllKeys;
159
+ /** `SIMILAR TO pattern` (SQL regular expression). PostgreSQL extension. */
160
+ readonly similarTo: typeof similarTo;
161
+ /** `NOT SIMILAR TO pattern`. PostgreSQL extension. */
162
+ readonly notSimilarTo: typeof notSimilarTo;
163
+ /** jsonb `@?` — the jsonpath returns any item; the value is a jsonpath string. PostgreSQL extension. */
164
+ readonly jsonPathExists: typeof jsonPathExists;
165
+ /** `<<=` — inet/cidr subnet is contained within or equals the value. PostgreSQL extension. */
166
+ readonly containedOrEqual: typeof containedOrEqual;
167
+ /** `>>=` — inet/cidr subnet contains or equals the value. PostgreSQL extension. */
168
+ readonly containsOrEqual: typeof containsOrEqual;
169
+ /** `%` — `pg_trgm` trigram similarity above `pg_trgm.similarity_threshold`. PostgreSQL extension. */
170
+ readonly trigramSimilar: typeof trigramSimilar;
171
+ /** `<%` — `pg_trgm`: the column is similar to a part of the value (word similarity above the threshold). PostgreSQL extension. */
172
+ readonly trigramWordSimilar: typeof trigramWordSimilar;
173
+ /** `<<%` — `pg_trgm`: the column is strictly similar to a word of the value. PostgreSQL extension. */
174
+ readonly trigramStrictWordSimilar: typeof trigramStrictWordSimilar;
175
+ /** `%>` — `pg_trgm`: the column has a part similar to the value (commutator of `<%`). PostgreSQL extension. */
176
+ readonly trigramHasSimilarWord: typeof trigramHasSimilarWord;
177
+ /** `%>>` — `pg_trgm`: the column has a strictly similar word of the value. PostgreSQL extension. */
178
+ readonly trigramHasSimilarStrictWord: typeof trigramHasSimilarStrictWord;
179
+ };
180
+ /** Union of all operator symbols in {@link Op}. */
181
+ export type OpSymbol = (typeof Op)[keyof typeof Op];
182
+ export {};
@@ -0,0 +1,110 @@
1
+ import { ModifyingNode, QueryNode } from '../sql/ast.ts';
2
+ import { SqlExpression, SqlExpressionVisitor } from './expression.ts';
3
+ /**
4
+ * Options of {@link Subquery.union}, {@link Subquery.intersect} and {@link Subquery.except}.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const opts: SetOperationOptions = { all: true };
9
+ * const rows = Post.subquery({ attributes: ['userId'] }).union(Task.subquery({ attributes: ['userId'] }), opts);
10
+ * ```
11
+ */
12
+ export type SetOperationOptions = Readonly<{
13
+ /**
14
+ * Keep duplicate rows (`UNION ALL`, `INTERSECT ALL`, `EXCEPT ALL`).
15
+ *
16
+ * @defaultValue false
17
+ */
18
+ all?: boolean;
19
+ }>;
20
+ /**
21
+ * SELECT embedded in another statement. Created by `Model.subquery()`, or by combining subqueries
22
+ * with a set operation. PostgreSQL extension.
23
+ */
24
+ export declare class Subquery extends SqlExpression {
25
+ #private;
26
+ /** @internal */
27
+ static readonly kind = "Subquery";
28
+ /** Builds the query AST (called when the outer statement is compiled). */
29
+ readonly build: () => QueryNode;
30
+ /**
31
+ * @param build - Builds the query AST.
32
+ */
33
+ constructor(build: () => QueryNode);
34
+ /**
35
+ * Rows of this query or of `other`, without duplicates unless `all` is set (`UNION`).
36
+ *
37
+ * Both queries must select the same number of columns of compatible types. Use the result
38
+ * wherever a subquery fits: `source`, `with`, `Op.in`, `insertFrom`, `merge`.
39
+ *
40
+ * @param other - Query to combine with.
41
+ * @param options - `all` keeps duplicates.
42
+ * @returns Combined subquery.
43
+ * @example
44
+ * ```ts
45
+ * const ids = Post.subquery({ attributes: ['userId'] }).union(Task.subquery({ attributes: ['userId'] }));
46
+ * const users = await User.findAll({ where: { id: { [Op.in]: ids } } });
47
+ * ```
48
+ */
49
+ union(other: Subquery, options?: SetOperationOptions): Subquery;
50
+ /**
51
+ * Rows that are in both this query and `other` (`INTERSECT`).
52
+ *
53
+ * @param other - Query to intersect with.
54
+ * @param options - `all` keeps duplicates.
55
+ * @returns Combined subquery.
56
+ * @example
57
+ * ```ts
58
+ * const both = Post.subquery({ attributes: ['userId'] }).intersect(Task.subquery({ attributes: ['userId'] }));
59
+ * ```
60
+ */
61
+ intersect(other: Subquery, options?: SetOperationOptions): Subquery;
62
+ /**
63
+ * Rows of this query that are not in `other` (`EXCEPT`).
64
+ *
65
+ * @param other - Query whose rows are removed.
66
+ * @param options - `all` keeps duplicates.
67
+ * @returns Combined subquery.
68
+ * @example
69
+ * ```ts
70
+ * const quiet = User.subquery({ attributes: ['id'] }).except(Post.subquery({ attributes: ['userId'] }));
71
+ * ```
72
+ */
73
+ except(other: Subquery, options?: SetOperationOptions): Subquery;
74
+ /** @internal */
75
+ accept<R>(visitor: SqlExpressionVisitor<R>): R;
76
+ }
77
+ /** `EXISTS (subquery)` / `NOT EXISTS (subquery)`. Created by {@link exists} / {@link notExists}. */
78
+ export declare class Exists extends SqlExpression {
79
+ /** @internal */
80
+ static readonly kind = "Exists";
81
+ /** The wrapped `SELECT` that `EXISTS` tests for rows. */
82
+ readonly subquery: Subquery;
83
+ /** `NOT EXISTS`. */
84
+ readonly negated: boolean;
85
+ /**
86
+ * @param subquery - Subquery.
87
+ * @param negated - `NOT EXISTS`.
88
+ */
89
+ constructor(subquery: Subquery, negated: boolean);
90
+ /** @internal */
91
+ accept<R>(visitor: SqlExpressionVisitor<R>): R;
92
+ }
93
+ /**
94
+ * INSERT, UPDATE or DELETE statement for a data-modifying CTE. Created by `Model.insertStatement()`,
95
+ * `Model.updateStatement()` and `Model.deleteStatement()`; not executed on its own. PostgreSQL extension.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * const moved = Task.deleteStatement({ where: { done: true }, returning: true });
100
+ * const rows = await Task.findAll({ with: { moved }, source: 'moved' });
101
+ * ```
102
+ */
103
+ export declare class WriteStatement {
104
+ /** Builds the statement AST (called when the outer statement is compiled). */
105
+ readonly build: () => ModifyingNode;
106
+ /**
107
+ * @param build - Builds the statement AST.
108
+ */
109
+ constructor(build: () => ModifyingNode);
110
+ }
@@ -0,0 +1,35 @@
1
+ import { Fn } from './call-expressions.ts';
2
+ import { SqlExpression, SqlExpressionVisitor } from './expression.ts';
3
+ import { Literal } from './methods.ts';
4
+ /** Window function call `fn OVER (...)`. Created by {@link over}. */
5
+ export declare class Over extends SqlExpression {
6
+ /** @internal */
7
+ static readonly kind = "Over";
8
+ /** Window function, e.g. `fn('row_number')`. */
9
+ readonly fn: Fn | Literal;
10
+ /** `PARTITION BY` attributes or expressions. */
11
+ readonly partitionBy: readonly unknown[];
12
+ /** `ORDER BY` items: attribute, `[attribute, direction]` or expression. */
13
+ readonly orderBy: readonly unknown[];
14
+ /**
15
+ * @param fn - Window function.
16
+ * @param partitionBy - `PARTITION BY` items.
17
+ * @param orderBy - `ORDER BY` items.
18
+ */
19
+ constructor(fn: Fn | Literal, partitionBy: readonly unknown[], orderBy: readonly unknown[]);
20
+ /** @internal */
21
+ accept<R>(visitor: SqlExpressionVisitor<R>): R;
22
+ }
23
+ /** Row constructor `(a, b, ...)` for row comparisons. Created by {@link tuple}. */
24
+ export declare class Tuple extends SqlExpression {
25
+ /** @internal */
26
+ static readonly kind = "Tuple";
27
+ /** Row items. */
28
+ readonly items: readonly unknown[];
29
+ /**
30
+ * @param items - Row items.
31
+ */
32
+ constructor(items: readonly unknown[]);
33
+ /** @internal */
34
+ accept<R>(visitor: SqlExpressionVisitor<R>): R;
35
+ }
@@ -0,0 +1,138 @@
1
+ import { Fn } from './call-expressions.ts';
2
+ /**
3
+ * Options of {@link tsRank}.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const options: TsRankOptions = { cd: true, weights: [0.1, 0.2, 0.4, 1], normalization: 1 };
8
+ * ```
9
+ */
10
+ export type TsRankOptions = Readonly<{
11
+ /** Uses `ts_rank_cd` (cover density) instead of `ts_rank`. */
12
+ cd?: boolean;
13
+ /** Weights of the labels `D`, `C`, `B`, `A`, in this order. */
14
+ weights?: readonly [number, number, number, number];
15
+ /** Normalization bit mask, an integer from 0 to 63. */
16
+ normalization?: number;
17
+ }>;
18
+ /**
19
+ * Options of {@link tsHeadline}.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * const options: TsHeadlineOptions = { config: 'english', options: 'StartSel=<b>, StopSel=</b>' };
24
+ * ```
25
+ */
26
+ export type TsHeadlineOptions = Readonly<{
27
+ /** Text search configuration, e.g. `'english'`. */
28
+ config?: string;
29
+ /** `ts_headline` options string, e.g. `'StartSel=<b>, StopSel=</b>'`. Bound as a parameter. */
30
+ options?: string;
31
+ }>;
32
+ /**
33
+ * `to_tsvector([config,] document)`: parses a document into a `tsvector`. PostgreSQL extension.
34
+ *
35
+ * @param document - Text value (bound as a parameter) or an expression such as `col('body')`.
36
+ * @param config - Text search configuration; the server default when omitted.
37
+ * @returns Function call expression.
38
+ * @throws Error when `config` is not a plain or schema-qualified identifier.
39
+ * @example
40
+ * ```ts
41
+ * await Post.findAll({ where: where(toTsVector(col('body'), 'english'), Op.match, websearchToTsQuery('cat -dog', 'english')) });
42
+ * ```
43
+ */
44
+ export declare const toTsVector: (document: unknown, config?: string) => Fn;
45
+ /**
46
+ * `to_tsquery([config,] query)`: parses `tsquery` syntax (`&`, `|`, `!`, `<->`). PostgreSQL extension.
47
+ *
48
+ * @param query - Query text in `tsquery` syntax, bound as a parameter. Invalid syntax is a database error.
49
+ * @param config - Text search configuration; the server default when omitted.
50
+ * @returns Function call expression.
51
+ * @throws Error when `config` is not a plain or schema-qualified identifier.
52
+ * @example
53
+ * ```ts
54
+ * await Post.findAll({ where: { search: { [Op.match]: toTsQuery('cat & !dog', 'english') } } });
55
+ * ```
56
+ */
57
+ export declare const toTsQuery: (query: unknown, config?: string) => Fn;
58
+ /**
59
+ * `plainto_tsquery([config,] text)`: ANDs all words of plain text. PostgreSQL extension.
60
+ *
61
+ * @param text - Plain text, bound as a parameter.
62
+ * @param config - Text search configuration; the server default when omitted.
63
+ * @returns Function call expression.
64
+ * @throws Error when `config` is not a plain or schema-qualified identifier.
65
+ * @example
66
+ * ```ts
67
+ * await Post.findAll({ where: { search: { [Op.match]: plainToTsQuery('fat cats', 'english') } } });
68
+ * ```
69
+ */
70
+ export declare const plainToTsQuery: (text: unknown, config?: string) => Fn;
71
+ /**
72
+ * `phraseto_tsquery([config,] text)`: words of plain text that must follow each other. PostgreSQL extension.
73
+ *
74
+ * @param text - Plain text, bound as a parameter.
75
+ * @param config - Text search configuration; the server default when omitted.
76
+ * @returns Function call expression.
77
+ * @throws Error when `config` is not a plain or schema-qualified identifier.
78
+ * @example
79
+ * ```ts
80
+ * await Post.findAll({ where: { search: { [Op.match]: phraseToTsQuery('fat cats', 'english') } } });
81
+ * ```
82
+ */
83
+ export declare const phraseToTsQuery: (text: unknown, config?: string) => Fn;
84
+ /**
85
+ * `websearch_to_tsquery([config,] text)`: web-search syntax (quotes, `or`, `-`) that never fails to parse. PostgreSQL extension.
86
+ *
87
+ * @param text - User search text, bound as a parameter.
88
+ * @param config - Text search configuration; the server default when omitted.
89
+ * @returns Function call expression.
90
+ * @throws Error when `config` is not a plain or schema-qualified identifier.
91
+ * @example
92
+ * ```ts
93
+ * await Post.findAll({ where: { search: { [Op.match]: websearchToTsQuery('"fat cat" -dog', 'english') } } });
94
+ * ```
95
+ */
96
+ export declare const websearchToTsQuery: (text: unknown, config?: string) => Fn;
97
+ /**
98
+ * `ts_rank` / `ts_rank_cd`: relevance of a `tsvector` for a `tsquery`, for `attributes` and `order`. PostgreSQL extension.
99
+ *
100
+ * @param vector - `tsvector` expression, e.g. `col('search')`.
101
+ * @param query - `tsquery` expression, e.g. {@link websearchToTsQuery}.
102
+ * @param options - `cd`, `weights` and `normalization`.
103
+ * @returns Function call expression.
104
+ * @throws Error when `weights` is not four finite numbers or `normalization` is not an integer from 0 to 63.
105
+ * @example
106
+ * ```ts
107
+ * const query = websearchToTsQuery('cat', 'english');
108
+ * await Post.findAll({ where: { search: { [Op.match]: query } }, order: [[tsRank(col('search'), query, { normalization: 1 }), 'DESC']] });
109
+ * ```
110
+ */
111
+ export declare const tsRank: (vector: unknown, query: unknown, options?: TsRankOptions) => Fn;
112
+ /**
113
+ * `ts_headline`: a document excerpt with the query terms highlighted. PostgreSQL extension.
114
+ *
115
+ * @param document - Text expression or value, bound as a parameter.
116
+ * @param query - `tsquery` expression.
117
+ * @param options - Configuration and `ts_headline` options string.
118
+ * @returns Function call expression.
119
+ * @throws Error when `config` is not a plain or schema-qualified identifier.
120
+ * @example
121
+ * ```ts
122
+ * await Post.findAll({ attributes: [[tsHeadline(col('body'), websearchToTsQuery('cat'), { options: 'StartSel=<b>, StopSel=</b>' }), 'excerpt']] });
123
+ * ```
124
+ */
125
+ export declare const tsHeadline: (document: unknown, query: unknown, options?: TsHeadlineOptions) => Fn;
126
+ /**
127
+ * `setweight(vector, weight)`: labels every lexeme of a `tsvector` `A`, `B`, `C` or `D`. PostgreSQL extension.
128
+ *
129
+ * @param vector - `tsvector` expression, e.g. {@link toTsVector}.
130
+ * @param weight - Label `'A'`, `'B'`, `'C'` or `'D'`.
131
+ * @returns Function call expression.
132
+ * @throws Error when `weight` is not one of the four labels.
133
+ * @example
134
+ * ```ts
135
+ * await Post.findAll({ attributes: [[setWeight(toTsVector(col('title'), 'english'), 'A'), 'titleVector']] });
136
+ * ```
137
+ */
138
+ export declare const setWeight: (vector: unknown, weight: "A" | "B" | "C" | "D") => Fn;