@prisma/orm-target-postgres 8.0.0-rc.23-dev.13 → 8.0.0-rc.24-dev.1

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 (63) hide show
  1. package/dist/{adapter-BRTXHtXv-DBeQuJnG.mjs → adapter-R3ShWuwi-ByT6BEs3.mjs} +4 -4
  2. package/dist/{adapter-BRTXHtXv-DBeQuJnG.mjs.map → adapter-R3ShWuwi-ByT6BEs3.mjs.map} +1 -1
  3. package/dist/{adapter-D6S0To9M.d.mts → adapter-dMZYwONo.d.mts} +11 -11
  4. package/dist/{adapter-D6S0To9M.d.mts.map → adapter-dMZYwONo.d.mts.map} +1 -1
  5. package/dist/adapter.d.mts +1 -1
  6. package/dist/adapter.mjs +3 -3
  7. package/dist/adapter__adapter.d.mts +1 -1
  8. package/dist/adapter__adapter.mjs +2 -2
  9. package/dist/adapter__control.mjs +2 -2
  10. package/dist/adapter__control.mjs.map +1 -1
  11. package/dist/adapter__runtime.mjs +2 -2
  12. package/dist/adapter__runtime.mjs.map +1 -1
  13. package/dist/adapter__sql-renderer.mjs +1 -1
  14. package/dist/{aggregates-C2c48ORM.d.mts → aggregates-0EfVySBb.d.mts} +11 -11
  15. package/dist/{aggregates-C2c48ORM.d.mts.map → aggregates-0EfVySBb.d.mts.map} +1 -1
  16. package/dist/{contract-contributions-n5CdvwA9-BgUoiuTT.mjs → contract-contributions-DW5M6ikc-xWfdvtpN.mjs} +3 -3
  17. package/dist/{contract-contributions-n5CdvwA9-BgUoiuTT.mjs.map → contract-contributions-DW5M6ikc-xWfdvtpN.mjs.map} +1 -1
  18. package/dist/{descriptor-meta-CKsHlt_c-DkP2ZqQd.mjs → descriptor-meta-H-q1zg89-WyJOQCb9.mjs} +3 -3
  19. package/dist/{descriptor-meta-CKsHlt_c-DkP2ZqQd.mjs.map → descriptor-meta-H-q1zg89-WyJOQCb9.mjs.map} +1 -1
  20. package/dist/driver.mjs +1 -1
  21. package/dist/driver__runtime.mjs +1 -1
  22. package/dist/{full-text-B1-jMF4Z.d.mts → full-text-BVczGhL-.d.mts} +3 -3
  23. package/dist/{full-text-B1-jMF4Z.d.mts.map → full-text-BVczGhL-.d.mts.map} +1 -1
  24. package/dist/{full-text-collection-method-BRDY-2p_-ihxqGzh-.d.mts → full-text-collection-method-DfUPCfLc-DsEWB7X7.d.mts} +3 -3
  25. package/dist/full-text-collection-method-DfUPCfLc-DsEWB7X7.d.mts.map +1 -0
  26. package/dist/{full-text-DGFJd1R3.mjs → full-text-oDBhUHI5.mjs} +2 -2
  27. package/dist/{full-text-DGFJd1R3.mjs.map → full-text-oDBhUHI5.mjs.map} +1 -1
  28. package/dist/{full-text-parsers-D-2uupNS-6woSZ16T.mjs → full-text-parsers-BZV74MUg-TfQ8rvPW.mjs} +11 -3
  29. package/dist/full-text-parsers-BZV74MUg-TfQ8rvPW.mjs.map +1 -0
  30. package/dist/operation-types-CdMQcokE.d.mts +1 -0
  31. package/dist/{operation-types-DxFsD0qF-Cu43r84y.d.mts → operation-types-DrbqAMZU-BMJy_GWl.d.mts} +7 -4
  32. package/dist/operation-types-DrbqAMZU-BMJy_GWl.d.mts.map +1 -0
  33. package/dist/{pack-BjD3oNln.d.mts → pack-DnAO8TDj.d.mts} +3 -3
  34. package/dist/{pack-BjD3oNln.d.mts.map → pack-DnAO8TDj.d.mts.map} +1 -1
  35. package/dist/{prisma7-binding-VYAlkSRR.d.mts → prisma7-binding-BskIu_uu.d.mts} +3 -3
  36. package/dist/{prisma7-binding-VYAlkSRR.d.mts.map → prisma7-binding-BskIu_uu.d.mts.map} +1 -1
  37. package/dist/{runtime-COkNK8R6.d.mts → runtime-DNHLyT94.d.mts} +14 -3
  38. package/dist/runtime-DNHLyT94.d.mts.map +1 -0
  39. package/dist/runtime-DPhbi9_3.mjs +230 -0
  40. package/dist/runtime-DPhbi9_3.mjs.map +1 -0
  41. package/dist/{runtime-y_2Hxv0c.mjs → runtime-DuP4WGEr.mjs} +61 -8
  42. package/dist/runtime-DuP4WGEr.mjs.map +1 -0
  43. package/dist/{sql-renderer-D6fBWtjL-BOe5jc4e.mjs → sql-renderer-Cvvt1C6K-Dt5L1PLK.mjs} +9 -6
  44. package/dist/sql-renderer-Cvvt1C6K-Dt5L1PLK.mjs.map +1 -0
  45. package/dist/target.d.mts +9 -9
  46. package/dist/target.mjs +4 -3
  47. package/dist/target__aggregates.d.mts +1 -1
  48. package/dist/target__full-text.d.mts +3 -3
  49. package/dist/target__full-text.mjs +2 -2
  50. package/dist/target__operation-types.d.mts +2 -2
  51. package/dist/target__pack.d.mts +2 -2
  52. package/dist/target__prisma7-binding.d.mts +1 -1
  53. package/dist/target__runtime.d.mts +3 -3
  54. package/dist/target__runtime.mjs +3 -209
  55. package/package.json +10 -10
  56. package/dist/full-text-collection-method-BRDY-2p_-ihxqGzh-.d.mts.map +0 -1
  57. package/dist/full-text-parsers-D-2uupNS-6woSZ16T.mjs.map +0 -1
  58. package/dist/operation-types-DExfW5kG.d.mts +0 -1
  59. package/dist/operation-types-DxFsD0qF-Cu43r84y.d.mts.map +0 -1
  60. package/dist/runtime-COkNK8R6.d.mts.map +0 -1
  61. package/dist/runtime-y_2Hxv0c.mjs.map +0 -1
  62. package/dist/sql-renderer-D6fBWtjL-BOe5jc4e.mjs.map +0 -1
  63. package/dist/target__runtime.mjs.map +0 -1
@@ -1,2 +1,2 @@
1
- import { t as prisma7PostgresBinding } from "./prisma7-binding-VYAlkSRR.mjs";
1
+ import { t as prisma7PostgresBinding } from "./prisma7-binding-BskIu_uu.mjs";
2
2
  export { prisma7PostgresBinding };
@@ -1,6 +1,6 @@
1
1
  import { t as decodePostgresListText } from "./list-decoder-BcrLExnx-DlCwavhu.mjs";
2
2
  import { n as postgresNowGenerators } from "./date-time-now-generators-C7om6MxZ-B9S-CnE_.mjs";
3
- import { t as PostgresFullTextMethods } from "./full-text-collection-method-BRDY-2p_-ihxqGzh-.mjs";
3
+ import { t as PostgresFullTextMethods } from "./full-text-collection-method-DfUPCfLc-DsEWB7X7.mjs";
4
4
  import { t as PostgresContractView } from "./postgres-contract-view-BFzIDwwN-hL3QLe_b.mjs";
5
- import { i as postgresRuntimeTargetDescriptor, n as PostgresListDecoder, r as PostgresRuntimeTargetInstance, t as PostgresContractSerializer } from "./runtime-COkNK8R6.mjs";
6
- export { PostgresContractSerializer, PostgresContractView, type PostgresFullTextMethods, PostgresListDecoder, PostgresRuntimeTargetInstance, decodePostgresListText, postgresRuntimeTargetDescriptor as default, postgresNowGenerators };
5
+ import { a as postgresIsolationLevelSchema, c as validatePostgresIsolationLevel, i as PostgresRuntimeTargetInstance, n as PostgresIsolationLevel, o as postgresIsolationLevels, r as PostgresListDecoder, s as postgresRuntimeTargetDescriptor, t as PostgresContractSerializer } from "./runtime-DNHLyT94.mjs";
6
+ export { PostgresContractSerializer, PostgresContractView, type PostgresFullTextMethods, type PostgresIsolationLevel, PostgresListDecoder, PostgresRuntimeTargetInstance, decodePostgresListText, postgresRuntimeTargetDescriptor as default, postgresIsolationLevelSchema, postgresIsolationLevels, postgresNowGenerators, validatePostgresIsolationLevel };
@@ -1,211 +1,5 @@
1
- import { I as PG_TSQUERY_CODEC_ID, T as PG_TEXT_CODEC_ID, c as PG_FLOAT4_CODEC_ID, n as PG_BOOL_CODEC_ID } from "./codec-ids-2htdtS66-CJPMZv1t.mjs";
2
- import { u as postgresError } from "./errors-C4-Dp3gI-B5jY5eJj.mjs";
3
1
  import { c as decodePostgresListText } from "./codecs-Bzj3M0Q3-C2oFSIGs.mjs";
4
- import { c as fullTextIndexOptions, n as FULL_TEXT_INDEX_TYPE } from "./full-text-index-definition-DzRCaPjb-0USKN1ZI.mjs";
5
- import { a as postgresNowGenerators, o as postgresTargetDescriptorMetaRuntime } from "./date-time-now-generators-BORO1_nc-BdCe3ppq.mjs";
6
- import { t as renderFullTextDocument } from "./full-text-search-document-BqqvjJoC-HaoeMaM5.mjs";
2
+ import { a as postgresNowGenerators } from "./date-time-now-generators-BORO1_nc-BdCe3ppq.mjs";
7
3
  import { n as PostgresContractView, t as PostgresContractSerializer } from "./postgres-contract-view-WtPiaMZp-C-CQAB1E.mjs";
8
- import { a as normalizationLiteral, c as toTsquery, i as languageLiteral, l as websearchToTsquery, o as phrasetoTsquery, r as headlineOptionsLiteral, s as plaintoTsquery, t as FullTextDocument } from "./full-text-parsers-D-2uupNS-6woSZ16T.mjs";
9
- import { blindCast } from "@prisma/orm-framework/utils/casts";
10
- import { type } from "arktype";
11
- import { assertDefined } from "@prisma/orm-framework/utils/assertions";
12
- import { buildOperation, isExpression, toExpr } from "@prisma/orm-family-sql/relational-core/expression";
13
- import { uniqueIndexNamesOfType } from "@prisma/orm-family-sql/relational-core/index-reference";
14
- //#region ../../../3-targets/postgres/1-target/dist/runtime.mjs
15
- function indexFunction(tools, name) {
16
- return blindCast(tools.fns[name]);
17
- }
18
- function fullTextMethod(indexName) {
19
- return (collection, ...args) => collection.where((_model, tools) => indexFunction(tools, "fullTextMatches")(tools.indexes[indexName], ...args)).orderBy((_model, tools) => indexFunction(tools, "fullTextRank")(tools.indexes[indexName], ...args).desc());
20
- }
21
- /** The run-time half of `PostgresFullTextMethods`. */
22
- const postgresFullTextMethods = {
23
- id: "postgres/fullText",
24
- methodsFor: (model) => Object.fromEntries(uniqueIndexNamesOfType(model.table.indexes, FULL_TEXT_INDEX_TYPE).map((name) => [name, fullTextMethod(name)]))
25
- };
26
- const TEXT_REF = { codecId: PG_TEXT_CODEC_ID };
27
- const TSQUERY_REF = { codecId: PG_TSQUERY_CODEC_ID };
28
- const languageOf = (options) => options.language ?? "english";
29
- function isIndexReference(value) {
30
- return typeof value === "object" && value !== null && !Array.isArray(value) && !isExpression(value) && "type" in value && "options" in value && "columns" in value;
31
- }
32
- function invalidDocument(method, argument, received, message, fix) {
33
- return postgresError("RUNTIME.ARGUMENT_INVALID", `${method}: ${message}`, {
34
- why: "Postgres uses a full-text index only for a query over the same search document, so the document comes from the index itself, from one column, or from `fullTextDocument`.",
35
- fix,
36
- meta: {
37
- helper: method,
38
- argument,
39
- received
40
- }
41
- });
42
- }
43
- /**
44
- * The weight groups and the language a search document stands for. A full-text index states both;
45
- * a column and a `fullTextDocument` take the language from the options.
46
- */
47
- function documentGroups(method, document, options) {
48
- if (document instanceof FullTextDocument) return {
49
- weightGroups: document.weightGroups,
50
- language: languageOf(options)
51
- };
52
- if (isExpression(document)) return {
53
- weightGroups: [[document]],
54
- language: languageOf(options)
55
- };
56
- if (!isIndexReference(document)) throw invalidDocument(method, "document", Array.isArray(document) ? "array" : typeof document, "the document must be a full-text index from a table's `indexes`, a column, or a document from `fullTextDocument`.", "Pass the index, as `table.indexes.<name>`, or wrap the weight groups in `fullTextDocument(...)`.");
57
- if (document.type !== "fullText") throw invalidDocument(method, "document", document.type, `the index is of type "${String(document.type)}", not a full-text index.`, "Pass an index declared with `@@fullTextIndex` or `fullTextIndex`.");
58
- if (options.language !== void 0) throw invalidDocument(method, "options", options.language, "a full-text index states its language, so the `language` option is not taken with one.", "Leave `language` out; the index decides it.");
59
- const definition = fullTextIndexOptions(document.options ?? {});
60
- if (definition instanceof type.errors) throw invalidDocument(method, "document", document.options, `the full-text index has invalid options: ${definition.summary}`, "Pass the index as the table gives it.");
61
- const columns = document.columns;
62
- const columnOf = (name) => {
63
- const column = typeof columns === "object" && columns !== null && Object.hasOwn(columns, name) ? Reflect.get(columns, name) : void 0;
64
- if (!isExpression(column)) throw invalidDocument(method, "document", name, `the full-text index has no column "${name}", which its weight groups name.`, "Pass the index as the table gives it.");
65
- return column;
66
- };
67
- return {
68
- weightGroups: definition.weightGroups.map((group) => group.map(columnOf)),
69
- language: definition.language
70
- };
71
- }
72
- /**
73
- * The search document an operation searches. The first column is the operation's `self`; the
74
- * others follow the `fixedArgs` the operation passes first, so the query, the language and any
75
- * further option keep their positions.
76
- */
77
- function searchDocument(method, document, options, fixedArgs) {
78
- const { weightGroups, language } = documentGroups(method, document, options);
79
- let position = 0;
80
- const template = renderFullTextDocument(weightGroups.map((group) => group.map(() => position++)), {
81
- column: (index) => index === 0 ? "{{self}}" : `{{arg${fixedArgs + index - 1}}}`,
82
- language: "{{arg1}}"
83
- });
84
- const [self, ...rest] = weightGroups.flat().map((column) => toExpr(column));
85
- assertDefined(self, `${method}: a checked document has a first column`);
86
- return {
87
- self,
88
- rest,
89
- template,
90
- language: languageLiteral(method, language)
91
- };
92
- }
93
- function postgresQueryOperations() {
94
- return {
95
- ilike: {
96
- self: { traits: ["textual"] },
97
- impl: (self, pattern) => buildOperation({
98
- method: "ilike",
99
- args: [toExpr(self), toExpr(pattern, TEXT_REF)],
100
- returns: {
101
- codecId: PG_BOOL_CODEC_ID,
102
- nullable: false
103
- },
104
- lowering: {
105
- targetFamily: "sql",
106
- template: "{{self}} ILIKE {{arg0}}"
107
- }
108
- })
109
- },
110
- fullTextMatches: {
111
- self: { traits: ["textual"] },
112
- impl: (document, query, options = {}) => {
113
- const searched = searchDocument("fullTextMatches", document, options, 2);
114
- return buildOperation({
115
- method: "fullTextMatches",
116
- args: [
117
- searched.self,
118
- toExpr(query, TSQUERY_REF),
119
- searched.language,
120
- ...searched.rest
121
- ],
122
- returns: {
123
- codecId: PG_BOOL_CODEC_ID,
124
- nullable: false
125
- },
126
- lowering: {
127
- targetFamily: "sql",
128
- template: `${searched.template} @@ {{arg0}}`
129
- }
130
- });
131
- }
132
- },
133
- fullTextRank: {
134
- self: { traits: ["textual"] },
135
- impl: (document, query, options = {}) => {
136
- const fn = options.coverDensity === true ? "ts_rank_cd" : "ts_rank";
137
- const normalization = options.normalization === void 0 ? void 0 : normalizationLiteral("fullTextRank", options.normalization);
138
- const searched = searchDocument("fullTextRank", document, options, normalization === void 0 ? 2 : 3);
139
- const fixed = normalization === void 0 ? [searched.language] : [searched.language, normalization];
140
- return buildOperation({
141
- method: "fullTextRank",
142
- args: [
143
- searched.self,
144
- toExpr(query, TSQUERY_REF),
145
- ...fixed,
146
- ...searched.rest
147
- ],
148
- returns: {
149
- codecId: PG_FLOAT4_CODEC_ID,
150
- nullable: false
151
- },
152
- lowering: {
153
- targetFamily: "sql",
154
- template: `${fn}(${searched.template}, {{arg0}}${normalization === void 0 ? "" : ", {{arg2}}"})`
155
- }
156
- });
157
- }
158
- },
159
- fullTextHeadline: {
160
- self: { traits: ["textual"] },
161
- impl: (self, query, options = {}) => {
162
- const headlineOptions = headlineOptionsLiteral("fullTextHeadline", options);
163
- const base = "ts_headline({{arg1}}, {{self}}, {{arg0}}";
164
- return buildOperation({
165
- method: "fullTextHeadline",
166
- args: [
167
- toExpr(self),
168
- toExpr(query, TSQUERY_REF),
169
- languageLiteral("fullTextHeadline", languageOf(options)),
170
- ...headlineOptions === void 0 ? [] : [headlineOptions]
171
- ],
172
- returns: {
173
- codecId: PG_TEXT_CODEC_ID,
174
- nullable: false
175
- },
176
- lowering: {
177
- targetFamily: "sql",
178
- template: `${base}${headlineOptions === void 0 ? "" : ", {{arg2}}"})`
179
- }
180
- });
181
- }
182
- },
183
- websearchToTsquery: { impl: websearchToTsquery },
184
- toTsquery: { impl: toTsquery },
185
- plaintoTsquery: { impl: plaintoTsquery },
186
- phrasetoTsquery: { impl: phrasetoTsquery }
187
- };
188
- }
189
- /**
190
- * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@internal/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that
191
- * `@internal/sql-runtime` consumers narrow to at composition time.
192
- *
193
- * The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).
194
- */
195
- const postgresRuntimeTargetDescriptor = {
196
- ...postgresTargetDescriptorMetaRuntime,
197
- codecs: () => [],
198
- listDecoder: () => decodePostgresListText,
199
- queryOperations: () => postgresQueryOperations(),
200
- collectionMethods: () => [postgresFullTextMethods],
201
- create() {
202
- return {
203
- familyId: "sql",
204
- targetId: "postgres"
205
- };
206
- }
207
- };
208
- //#endregion
209
- export { PostgresContractSerializer, PostgresContractView, decodePostgresListText, postgresRuntimeTargetDescriptor as default, postgresNowGenerators };
210
-
211
- //# sourceMappingURL=target__runtime.mjs.map
4
+ import { i as validatePostgresIsolationLevel, n as postgresIsolationLevels, r as postgresRuntimeTargetDescriptor, t as postgresIsolationLevelSchema } from "./runtime-DPhbi9_3.mjs";
5
+ export { PostgresContractSerializer, PostgresContractView, decodePostgresListText, postgresRuntimeTargetDescriptor as default, postgresIsolationLevelSchema, postgresIsolationLevels, postgresNowGenerators, validatePostgresIsolationLevel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/orm-target-postgres",
3
- "version": "8.0.0-rc.23-dev.13",
3
+ "version": "8.0.0-rc.24-dev.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -9,9 +9,9 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@prisma/orm-family-sql": "8.0.0-rc.23-dev.13",
13
- "@prisma/orm-framework": "8.0.0-rc.23-dev.13",
14
- "@prisma/orm-toolchain": "8.0.0-rc.23-dev.13",
12
+ "@prisma/orm-family-sql": "8.0.0-rc.24-dev.1",
13
+ "@prisma/orm-framework": "8.0.0-rc.24-dev.1",
14
+ "@prisma/orm-toolchain": "8.0.0-rc.24-dev.1",
15
15
  "@standard-schema/spec": "^1.1.0",
16
16
  "@types/node": "26.1.2",
17
17
  "@types/pg": "8.20.4",
@@ -24,12 +24,12 @@
24
24
  "temporal-spec": "1.0.1"
25
25
  },
26
26
  "devDependencies": {
27
- "@internal/adapter-postgres": "8.0.0-rc.23-dev.13",
28
- "@internal/driver-postgres": "8.0.0-rc.23-dev.13",
29
- "@internal/target-postgres": "8.0.0-rc.23-dev.13",
30
- "@repo/test-utils": "8.0.0-rc.23-dev.13",
31
- "@repo/tsconfig": "8.0.0-rc.23-dev.13",
32
- "@repo/tsdown": "8.0.0-rc.23-dev.13",
27
+ "@internal/adapter-postgres": "8.0.0-rc.24-dev.1",
28
+ "@internal/driver-postgres": "8.0.0-rc.24-dev.1",
29
+ "@internal/target-postgres": "8.0.0-rc.24-dev.1",
30
+ "@repo/test-utils": "8.0.0-rc.24-dev.1",
31
+ "@repo/tsconfig": "8.0.0-rc.24-dev.1",
32
+ "@repo/tsdown": "8.0.0-rc.24-dev.1",
33
33
  "tsdown": "0.22.14",
34
34
  "typescript": "5.9.3",
35
35
  "vitest": "5.0.0-rc.2"
@@ -1 +0,0 @@
1
- {"version":3,"file":"full-text-collection-method-BRDY-2p_-ihxqGzh-.d.mts","names":[],"sources":["../../../../3-targets/postgres/1-target/dist/full-text-collection-method-BRDY-2p_.d.mts"],"mappings":";;;;;;;;KAOK,0BAA0B,gBAAgB,QAAQ;UAC7C;WACC,sBAAsB,OAAO;WAC7B;WACA;;KAEN,oBAAoB,cAAc,6BAA6B,iDAAiD,QAAQ,uBAAuB,0CAA0C,wBAAwB,6BAA6B;;UAEzO,gCAAgC;WAC/B,SAAS;;;YAGR;aACC,qBAAqB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"full-text-parsers-D-2uupNS-6woSZ16T.mjs","names":[],"sources":["../../../../3-targets/postgres/1-target/dist/full-text-parsers-D-2uupNS.mjs"],"sourcesContent":["import { I as PG_TSQUERY_CODEC_ID, T as PG_TEXT_CODEC_ID } from \"./codec-ids-2htdtS66.mjs\";\nimport { u as postgresError } from \"./errors-C4-Dp3gI.mjs\";\nimport { d as FULL_TEXT_WEIGHTS, f as weightGroupsOf, l as POSTGRES_TEXT_SEARCH_LANGUAGES, o as fullTextIndexProblems, r as describeFullTextIndexProblem, u as isFullTextSearchLanguage } from \"./full-text-index-definition-DzRCaPjb.mjs\";\nimport { LiteralExpr } from \"@internal/sql-relational-core/ast\";\nimport { buildOperation, toExpr } from \"@internal/sql-relational-core/expression\";\n//#region src/core/full-text-document.ts\n/**\n* A search document built from columns in weight groups, for `fullTextMatches` and `fullTextRank`\n* to search without a full-text index. Postgres uses an index only for a query over the same\n* document, so to search an index, pass the index from the table's `indexes` instead.\n*/\nvar FullTextDocument = class FullTextDocument {\n\tweightGroups;\n\tconstructor(weightGroups) {\n\t\tthis.weightGroups = weightGroups;\n\t\tObject.freeze(this);\n\t}\n\tstatic of(groups) {\n\t\tconst weightGroups = weightGroupsOf(groups, (item) => !Array.isArray(item));\n\t\tlet position = 0;\n\t\tconst [problem] = fullTextIndexProblems({ weightGroups: weightGroups.map((group) => group.map(() => String(position++))) });\n\t\tif (problem !== void 0) throw postgresError(\"RUNTIME.ARGUMENT_INVALID\", describeFullTextIndexProblem(\"fullTextDocument: the document\", problem), {\n\t\t\twhy: `Each weight group takes one of the weights Postgres has, ${FULL_TEXT_WEIGHTS.join(\", \")}.`,\n\t\t\tfix: \"Pass one to four weight groups, none of them empty.\",\n\t\t\tmeta: {\n\t\t\t\thelper: \"fullTextDocument\",\n\t\t\t\targument: \"groups\",\n\t\t\t\treceived: weightGroups.length\n\t\t\t}\n\t\t});\n\t\treturn new FullTextDocument(weightGroups);\n\t}\n};\n/**\n* The search document of columns in weight groups, strongest first: `fullTextDocument([[f.title,\n* f.subtitle], [f.body]])`. Each group takes the next weight, `A` to `D`; a column named twice is\n* not refused, because column expressions have no name to compare.\n*/\nfunction fullTextDocument(groups) {\n\treturn FullTextDocument.of(groups);\n}\n//#endregion\n//#region src/core/full-text-options.ts\n/**\n* Options for the Postgres full-text operations, and the checks each one goes through.\n*\n* Every option here reaches the SQL as an inline literal rather than a bound parameter, because\n* Postgres accepts no parameter in these positions. Each is therefore validated before a statement\n* exists; anything unrecognized throws `RUNTIME.ARGUMENT_INVALID`.\n*\n* The headline markers are the only free text among them, and `checkMarker` restricts their\n* characters precisely so that the literal path never carries a quote or a backslash for\n* `escapeLiteral` to have to reason about.\n*/\nfunction invalid(method, argument, received, why, fix) {\n\treturn postgresError(\"RUNTIME.ARGUMENT_INVALID\", `${method}: ${why}`, {\n\t\twhy: \"The option is written into the SQL as an inline literal, not a bound parameter, so it is checked before the statement is built.\",\n\t\tfix,\n\t\tmeta: {\n\t\t\thelper: method,\n\t\t\targument,\n\t\t\treceived\n\t\t}\n\t});\n}\nfunction languageLiteral(method, language) {\n\tif (!isFullTextSearchLanguage(language)) throw invalid(method, \"language\", language, `'${language}' is not a PostgreSQL text-search configuration Prisma recognizes.`, `Pass one of: ${POSTGRES_TEXT_SEARCH_LANGUAGES.join(\", \")}.`);\n\treturn LiteralExpr.of(language);\n}\nfunction normalizationLiteral(method, normalization) {\n\tif (!Number.isInteger(normalization) || normalization < 0 || normalization > 63) throw invalid(method, \"normalization\", normalization, `normalization must be an integer between 0 and 63, received ${normalization}.`, \"Combine the flags documented for ts_rank, e.g. 32 to divide the rank by itself plus one.\");\n\treturn LiteralExpr.of(normalization);\n}\nfunction checkWordCount(method, argument, value) {\n\tif (!Number.isInteger(value) || value < 1) throw invalid(method, argument, value, `${argument} must be a positive integer, received ${value}.`, \"Pass a whole number of words, one or more.\");\n}\n/** Non-empty, and none of `\"` `,` `=` `\\` or whitespace. */\nconst MARKER = /^[^\"=,\\\\\\s]+$/;\nfunction checkMarker(method, argument, value) {\n\tif (!MARKER.test(value)) throw invalid(method, argument, value, `${argument} must be non-empty and free of \" , = \\\\ and whitespace, received ${JSON.stringify(value)}.`, \"ts_headline parses its options as a quoted, comma-separated list of Key=Value pairs, and the whole list reaches SQL as one literal, so a marker carrying those characters cannot survive either step. Use markup such as <mark> or <b>.\");\n}\n/**\n* The fourth `ts_headline` argument: one text literal of `Key=Value` pairs. Returns `undefined` when\n* nothing but the language was given, so the common call keeps rendering the three-argument form.\n*/\nfunction headlineOptionsLiteral(method, options) {\n\tconst pairs = [];\n\tif (options.startSel !== void 0) {\n\t\tcheckMarker(method, \"startSel\", options.startSel);\n\t\tpairs.push(`StartSel=${options.startSel}`);\n\t}\n\tif (options.stopSel !== void 0) {\n\t\tcheckMarker(method, \"stopSel\", options.stopSel);\n\t\tpairs.push(`StopSel=${options.stopSel}`);\n\t}\n\tif (options.maxWords !== void 0) {\n\t\tcheckWordCount(method, \"maxWords\", options.maxWords);\n\t\tpairs.push(`MaxWords=${options.maxWords}`);\n\t}\n\tif (options.minWords !== void 0) {\n\t\tcheckWordCount(method, \"minWords\", options.minWords);\n\t\tif (options.maxWords !== void 0 && options.minWords >= options.maxWords) throw invalid(method, \"minWords\", options.minWords, `minWords (${options.minWords}) must be below maxWords (${options.maxWords}).`, \"Postgres requires MinWords strictly below MaxWords. Lower minWords, or raise maxWords.\");\n\t\tpairs.push(`MinWords=${options.minWords}`);\n\t}\n\tif (options.highlightAll !== void 0) {\n\t\tif (typeof options.highlightAll !== \"boolean\") throw invalid(method, \"highlightAll\", options.highlightAll, `highlightAll must be a boolean, received ${JSON.stringify(options.highlightAll)}.`, \"Pass true to mark up the whole document, or false to extract fragments.\");\n\t\tpairs.push(`HighlightAll=${options.highlightAll}`);\n\t}\n\treturn pairs.length === 0 ? void 0 : LiteralExpr.of(pairs.join(\", \"));\n}\n//#endregion\n//#region src/core/full-text-parsers.ts\nconst TEXT_REF = { codecId: PG_TEXT_CODEC_ID };\nfunction parser(method, fn) {\n\treturn (text, options = {}) => buildOperation({\n\t\tmethod,\n\t\targs: [toExpr(text, TEXT_REF), languageLiteral(method, options.language ?? \"english\")],\n\t\treturns: {\n\t\t\tcodecId: PG_TSQUERY_CODEC_ID,\n\t\t\tnullable: false\n\t\t},\n\t\tlowering: {\n\t\t\ttargetFamily: \"sql\",\n\t\t\ttemplate: `${fn}({{arg0}}, {{self}})`\n\t\t}\n\t});\n}\n/** Postgres `websearch_to_tsquery`: search-box syntax with quotes, `or` and `-`. Never errors. */\nconst websearchToTsquery = parser(\"websearchToTsquery\", \"websearch_to_tsquery\");\n/**\n* Postgres `to_tsquery`: operator syntax (`'zebra' & !'graze'`, `zeb:*`), each word normalized.\n* Malformed input fails at execution, so pass only text the application wrote, never user input;\n* `tsquery` interpolates user input safely.\n*/\nconst toTsquery = parser(\"toTsquery\", \"to_tsquery\");\n/** Postgres `plainto_tsquery`: every word must match. */\nconst plaintoTsquery = parser(\"plaintoTsquery\", \"plainto_tsquery\");\n/** Postgres `phraseto_tsquery`: the words must match in order. */\nconst phrasetoTsquery = parser(\"phrasetoTsquery\", \"phraseto_tsquery\");\n//#endregion\nexport { headlineOptionsLiteral as a, FullTextDocument as c, websearchToTsquery as i, fullTextDocument as l, plaintoTsquery as n, languageLiteral as o, toTsquery as r, normalizationLiteral as s, phrasetoTsquery as t };\n\n//# sourceMappingURL=full-text-parsers-D-2uupNS.mjs.map"],"mappings":";;;;;;;;;;;AAWA,IAAI,mBAAmB,MAAM,iBAAiB;CAC7C;CACA,YAAY,cAAc;EACzB,KAAK,eAAe;EACpB,OAAO,OAAO,IAAI;CACnB;CACA,OAAO,GAAG,QAAQ;EACjB,MAAM,eAAe,eAAe,SAAS,SAAS,CAAC,MAAM,QAAQ,IAAI,CAAC;EAC1E,IAAI,WAAW;EACf,MAAM,CAAC,WAAW,sBAAsB,EAAE,cAAc,aAAa,KAAK,UAAU,MAAM,UAAU,OAAO,UAAU,CAAC,CAAC,EAAE,CAAC;EAC1H,IAAI,YAAY,KAAK,GAAG,MAAM,cAAc,4BAA4B,6BAA6B,kCAAkC,OAAO,GAAG;GAChJ,KAAK,4DAA4D,kBAAkB,KAAK,IAAI,EAAE;GAC9F,KAAK;GACL,MAAM;IACL,QAAQ;IACR,UAAU;IACV,UAAU,aAAa;GACxB;EACD,CAAC;EACD,OAAO,IAAI,iBAAiB,YAAY;CACzC;AACD;;;;;;AAMA,SAAS,iBAAiB,QAAQ;CACjC,OAAO,iBAAiB,GAAG,MAAM;AAClC;;;;;;;;;;;;AAcA,SAAS,QAAQ,QAAQ,UAAU,UAAU,KAAK,KAAK;CACtD,OAAO,cAAc,4BAA4B,GAAG,OAAO,IAAI,OAAO;EACrE,KAAK;EACL;EACA,MAAM;GACL,QAAQ;GACR;GACA;EACD;CACD,CAAC;AACF;AACA,SAAS,gBAAgB,Q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/G;QACA;;OAED,UAAU,YAAY,MAAM,kBAAkB,OAAO,gBAAgB,KAAK,UAAU,sBAAsB;QACzG;QACA;;;;WAIG;aACE,MAAM;aACN,OAAO,MAAM,YAAY,KAAK,OAAO,gBAAgB,KAAK,UAAU,4BAA4B;MACvG;MACA;;;WAGK,oBAAoB;WACpB,WAAW;WACX,gBAAgB;WAChB,iBAAiB;;;UAGlB,qCAAqC;WACpC,qBAAqB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-COkNK8R6.d.mts","names":[],"sources":["../../../../3-targets/postgres/1-target/dist/runtime.d.mts"],"mappings":";;;;;;;;;;;;;;;cAec,mCAAmC,0BAA0B,SAAS;EAClF,qBAAqB;EACrB,YAAY,gCAAgC;YAClC,yBAAyB,cAAc,KAAK,0BAA0B,YAAY;YAClF,kBAAkB,WAAW,SAAS,cAAc,SAAS;EACvE,kBAAkB,UAAU,SAAS,cAAc;;;;UAI3C,sCAAsC;KAC3C,uBAAuB,oBAAoB,gBAAgB,mBAAmB,qBAAqB;;;;;;;cAO1F,iCAAiC,2CAA2C;WAC/E,uBAAuB;WACvB,mBAAmB;WACnB,uBAAuB;WACvB,kCAAkC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-y_2Hxv0c.mjs","names":["#queue","#connection","#onRelease","#onDestroy","#txState","#onSettled","#onEnded","#settle","#sessionSettings","#ownedByDriver","#closed","suppressIdleConnectionErrors$1","#connectionMutex","#closeWhileHoldingLease","#giveUpSuppliedClient","#connectFailure","#connected","#rollbackUnderQueryLock","#connectDirectClient","#connectPromise","#connectClient","#cursorOpts","#preparedStatements","#delegate","#disconnectedState","#notConnectedError","#requireDelegate","#wrapConnection"],"sources":["../../../../3-targets/postgres/3-driver/dist/runtime.mjs"],"sourcesContent":["import { a as serverTextTypes, c as normalizePgConnectFailure, d as markClientAbandoned, f as watchClientLoss, l as hasLostConnection, n as createPgClient, o as isPostgresError, p as postgresDriverDescriptorMeta, r as createPgPool, s as normalizePgClientError, t as SessionSettingsGuard, u as hasStartedConnecting } from \"./session-settings-cHekxETj.mjs\";\nimport { SqlQueryError } from \"@internal/sql-errors\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { suppressIdleConnectionErrors, suppressIdleConnectionErrors as suppressIdleConnectionErrors$1 } from \"@internal/utils/suppress-idle-connection-errors\";\nimport Cursor from \"pg-cursor\";\n//#region src/driver-error.ts\nfunction driverError(code, message, details) {\n\tconst error = new Error(message);\n\tObject.defineProperty(error, \"name\", {\n\t\tvalue: \"RuntimeError\",\n\t\tconfigurable: true\n\t});\n\treturn details === void 0 ? Object.assign(error, {\n\t\tcode,\n\t\tcategory: \"DRIVER\",\n\t\tseverity: \"error\"\n\t}) : Object.assign(error, {\n\t\tcode,\n\t\tcategory: \"DRIVER\",\n\t\tseverity: \"error\",\n\t\tdetails\n\t});\n}\n//#endregion\n//#region src/callback-to-promise.ts\nfunction callbackToPromise(fn) {\n\treturn new Promise((resolve, reject) => {\n\t\tfn((err, result) => {\n\t\t\tif (err) {\n\t\t\t\treject(err);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolve(result);\n\t\t});\n\t});\n}\n//#endregion\n//#region src/named-cursor.ts\nlet nextNamedPortalId = 1;\n/** Streaming cursor for a server-side named prepared statement. */\nvar NamedCursor = class extends Cursor {\n\tname;\n\tconstructor(opts) {\n\t\tsuper(opts.text, [...opts.values], opts.config);\n\t\tthis.name = opts.name;\n\t\tthis.submit = this.submitNamed;\n\t}\n\tsubmitNamed(connection) {\n\t\tconst self = this;\n\t\tconst conn = connection;\n\t\tself.state = \"submitted\";\n\t\tself.connection = conn;\n\t\tself._portal = `np_${nextNamedPortalId++}`;\n\t\tif (!conn.parsedStatements[this.name]) {\n\t\t\tconst parseMessage = {\n\t\t\t\ttext: self.text,\n\t\t\t\tname: this.name,\n\t\t\t\ttypes: []\n\t\t\t};\n\t\t\tconn.parse(parseMessage, true);\n\t\t}\n\t\tconst bindMessage = {\n\t\t\tportal: self._portal,\n\t\t\tstatement: this.name,\n\t\t\tvalues: self.values ?? []\n\t\t};\n\t\tconn.bind(bindMessage, true);\n\t\tconn.describe({\n\t\t\ttype: \"P\",\n\t\t\tname: self._portal\n\t\t}, true);\n\t\tconn.flush();\n\t\tif (self._conf.types) self._result._getTypeParser = self._conf.types.getTypeParser;\n\t\tconn.once(\"noData\", self._ifNoData);\n\t\tconn.once(\"rowDescription\", self._rowDescription);\n\t}\n};\n//#endregion\n//#region src/postgres-driver.ts\nconst DEFAULT_BATCH_SIZE = 100;\nconst DEFAULT_PREPARED_STATEMENTS = true;\nfunction createHandleAllocator() {\n\tlet next = 1;\n\treturn { mint: () => `pn_${next++}` };\n}\nfunction buildConnectionOptions(options) {\n\treturn {\n\t\t...options.cursor?.disabled ? { cursorDisabled: true } : {\n\t\t\tcursorBatchSize: options.cursor?.batchSize ?? DEFAULT_BATCH_SIZE,\n\t\t\tcursorDisabled: false\n\t\t},\n\t\tpreparedStatementsEnabled: options.preparedStatements ?? DEFAULT_PREPARED_STATEMENTS,\n\t\thandleAllocator: createHandleAllocator()\n\t};\n}\n/** Reads the normalized error that runExecute and runQuery throw; a raw pg error is never stale. */\nfunction isStalePreparedStatementError(error) {\n\tif (!SqlQueryError.is(error)) return false;\n\tconst code = error.sqlState;\n\treturn code === \"26000\" || code === \"0A000\";\n}\nvar AsyncMutex = class {\n\t#queue = Promise.resolve();\n\tasync lock() {\n\t\tconst previous = this.#queue;\n\t\tlet releaseLock;\n\t\tthis.#queue = new Promise((resolve) => {\n\t\t\treleaseLock = resolve;\n\t\t});\n\t\tawait previous;\n\t\treturn () => {\n\t\t\treleaseLock?.();\n\t\t\treleaseLock = void 0;\n\t\t};\n\t}\n};\nconst clientQueryLocks = /* @__PURE__ */ new WeakMap();\nfunction acquireClientQueryLock(client) {\n\tlet mutex = clientQueryLocks.get(client);\n\tif (mutex === void 0) {\n\t\tmutex = new AsyncMutex();\n\t\tclientQueryLocks.set(client, mutex);\n\t}\n\treturn mutex.lock();\n}\nvar PostgresQueryable = class {\n\toptions;\n\tconstructor(options) {\n\t\tthis.options = options;\n\t}\n\tasync *query(request) {\n\t\tconst preparedStatementHandle = request.preparedStatementHandle;\n\t\tif (preparedStatementHandle === void 0 || !this.options.preparedStatementsEnabled) {\n\t\t\tyield* this.runQuery(request);\n\t\t\treturn;\n\t\t}\n\t\tconst name = this.preparedStatementName(preparedStatementHandle);\n\t\tyield* this.withStaleHandleStreamRetry(preparedStatementHandle, name, (name) => this.runQuery(request, name));\n\t}\n\tasync execute(request) {\n\t\tconst preparedStatementHandle = request.preparedStatementHandle;\n\t\tif (preparedStatementHandle === void 0 || !this.options.preparedStatementsEnabled) return await this.runExecute(request);\n\t\tconst name = this.preparedStatementName(preparedStatementHandle);\n\t\treturn await this.withStaleHandleRetry(preparedStatementHandle, name, (name) => this.runExecute(request, name));\n\t}\n\tpreparedStatementName(handle) {\n\t\tconst existingName = handle.get();\n\t\tif (typeof existingName === \"string\") return existingName;\n\t\tconst mintedName = this.options.handleAllocator.mint();\n\t\thandle.set(mintedName);\n\t\treturn mintedName;\n\t}\n\tasync withStaleHandleRetry(preparedStatementHandle, name, attempt) {\n\t\ttry {\n\t\t\treturn await attempt(name);\n\t\t} catch (error) {\n\t\t\tif (!isStalePreparedStatementError(error)) throw error;\n\t\t\tconst retryName = this.options.handleAllocator.mint();\n\t\t\tpreparedStatementHandle.set(retryName);\n\t\t\ttry {\n\t\t\t\treturn await attempt(retryName);\n\t\t\t} catch (retryError) {\n\t\t\t\tthrow prepareFailedError(retryError, retryName);\n\t\t\t}\n\t\t}\n\t}\n\tasync *withStaleHandleStreamRetry(preparedStatementHandle, name, attempt) {\n\t\tconst stream = await this.withStaleHandleRetry(preparedStatementHandle, name, async (name) => {\n\t\t\tconst iterator = attempt(name)[Symbol.asyncIterator]();\n\t\t\treturn {\n\t\t\t\titerator,\n\t\t\t\tfirst: await iterator.next()\n\t\t\t};\n\t\t});\n\t\tif (stream.first.done) return;\n\t\tlet streamCompleted = false;\n\t\ttry {\n\t\t\tyield stream.first.value;\n\t\t\twhile (true) {\n\t\t\t\tconst next = await stream.iterator.next();\n\t\t\t\tif (next.done) {\n\t\t\t\t\tstreamCompleted = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tyield next.value;\n\t\t\t}\n\t\t} finally {\n\t\t\tif (!streamCompleted) await stream.iterator.return?.();\n\t\t}\n\t}\n\tasync runExecute(request, name) {\n\t\tconst client = await this.acquireClient();\n\t\ttry {\n\t\t\tconst releaseLock = await acquireClientQueryLock(client);\n\t\t\ttry {\n\t\t\t\treturn { affectedRows: (await client.query({\n\t\t\t\t\tname,\n\t\t\t\t\ttext: request.sql,\n\t\t\t\t\tvalues: blindCast(request.params ?? [])\n\t\t\t\t})).rowCount ?? 0 };\n\t\t\t} finally {\n\t\t\t\treleaseLock();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow normalizePgClientError(client, error);\n\t\t} finally {\n\t\t\tawait this.releaseClient(client);\n\t\t}\n\t}\n\tinExplicitTransaction() {\n\t\treturn false;\n\t}\n\tasync *runQuery(request, name) {\n\t\tconst client = await this.acquireClient();\n\t\tlet rows;\n\t\ttry {\n\t\t\tif (!this.options.cursorDisabled) {\n\t\t\t\tconst releaseLock = await acquireClientQueryLock(client);\n\t\t\t\ttry {\n\t\t\t\t\tfor await (const row of this.streamWithPortalProtection(client, request, this.options.cursorBatchSize, name)) yield blindCast(row);\n\t\t\t\t\treturn;\n\t\t\t\t} catch (cursorError) {\n\t\t\t\t\tif (hasLostConnection(client) || !(cursorError instanceof Error) || isPostgresError(cursorError)) throw cursorError;\n\t\t\t\t} finally {\n\t\t\t\t\treleaseLock();\n\t\t\t\t}\n\t\t\t}\n\t\t\trows = await this.executeBuffered(client, request.sql, request.params, name);\n\t\t} catch (error) {\n\t\t\tthrow normalizePgClientError(client, error);\n\t\t} finally {\n\t\t\tawait this.releaseClient(client);\n\t\t}\n\t\tfor (const row of rows) yield blindCast(row);\n\t}\n\tasync explain(request) {\n\t\tconst text = `EXPLAIN (FORMAT JSON) ${request.sql}`;\n\t\tconst client = await this.acquireClient();\n\t\ttry {\n\t\t\tconst releaseLock = await acquireClientQueryLock(client);\n\t\t\ttry {\n\t\t\t\treturn { rows: blindCast((await client.query(text, request.params === void 0 ? void 0 : [...request.params]).catch(rethrowClientError(client))).rows) };\n\t\t\t} finally {\n\t\t\t\treleaseLock();\n\t\t\t}\n\t\t} finally {\n\t\t\tawait this.releaseClient(client);\n\t\t}\n\t}\n\tasync *streamWithPortalProtection(client, request, cursorBatchSize, name) {\n\t\tif (this.inExplicitTransaction()) {\n\t\t\tyield* this.executeWithCursor(client, request.sql, request.params, cursorBatchSize, name);\n\t\t\treturn;\n\t\t}\n\t\tawait client.query(\"BEGIN\");\n\t\tlet streamFailed = false;\n\t\ttry {\n\t\t\tyield* this.executeWithCursor(client, request.sql, request.params, cursorBatchSize, name);\n\t\t} catch (error) {\n\t\t\tstreamFailed = true;\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tawait this.commitStreamSpan(client, streamFailed);\n\t\t}\n\t}\n\tasync commitStreamSpan(client, streamFailed) {\n\t\ttry {\n\t\t\tawait client.query(\"COMMIT\");\n\t\t} catch (commitError) {\n\t\t\tif (!streamFailed) throw commitError;\n\t\t}\n\t}\n\tasync *executeWithCursor(client, sql, params, cursorBatchSize, name) {\n\t\tconst values = blindCast(params ?? []);\n\t\tconst config = { types: serverTextTypes };\n\t\tconst cursor = client.query(name === void 0 ? new Cursor(sql, values, config) : new NamedCursor({\n\t\t\tname,\n\t\t\ttext: sql,\n\t\t\tvalues,\n\t\t\tconfig\n\t\t}));\n\t\ttry {\n\t\t\twhile (true) {\n\t\t\t\tconst rows = await readCursor(cursor, cursorBatchSize);\n\t\t\t\tif (rows.length === 0) break;\n\t\t\t\tfor (const row of rows) yield row;\n\t\t\t}\n\t\t} finally {\n\t\t\tawait closeCursor(cursor);\n\t\t}\n\t}\n\tasync executeBuffered(client, sql, params, name) {\n\t\tconst config = {\n\t\t\tname,\n\t\t\ttext: sql,\n\t\t\tvalues: blindCast(params ?? []),\n\t\t\ttypes: serverTextTypes\n\t\t};\n\t\tconst releaseLock = await acquireClientQueryLock(client);\n\t\tlet result;\n\t\ttry {\n\t\t\tresult = await client.query(config);\n\t\t} finally {\n\t\t\treleaseLock();\n\t\t}\n\t\treturn blindCast(result.rows);\n\t}\n};\nvar PostgresConnectionImpl = class extends PostgresQueryable {\n\t#connection;\n\t#onRelease;\n\t#onDestroy;\n\t#txState;\n\tconstructor(connection, options, onRelease, onDestroy, txState) {\n\t\tsuper(options);\n\t\tthis.#connection = connection;\n\t\tthis.#onRelease = onRelease;\n\t\tthis.#onDestroy = onDestroy;\n\t\tthis.#txState = txState ?? {\n\t\t\topen: false,\n\t\t\tunfinishedOnServer: false\n\t\t};\n\t}\n\tacquireClient() {\n\t\treturn Promise.resolve(this.#connection);\n\t}\n\treleaseClient(_client) {\n\t\treturn Promise.resolve();\n\t}\n\tinExplicitTransaction() {\n\t\treturn this.#txState.open;\n\t}\n\tasync beginTransaction() {\n\t\tconst releaseLock = await acquireClientQueryLock(this.#connection);\n\t\ttry {\n\t\t\tawait this.#connection.query(\"BEGIN\").catch(rethrowClientError(this.#connection));\n\t\t} finally {\n\t\t\treleaseLock();\n\t\t}\n\t\tthis.#txState.open = true;\n\t\tthis.#txState.unfinishedOnServer = true;\n\t\treturn new PostgresTransactionImpl(this.#connection, this.options, () => {\n\t\t\tthis.#txState.open = false;\n\t\t}, () => {\n\t\t\tthis.#txState.unfinishedOnServer = false;\n\t\t});\n\t}\n\tasync release() {\n\t\tconst conn = this.#connection;\n\t\tif (\"release\" in conn) conn.release();\n\t\tconst onRelease = this.#onRelease;\n\t\tthis.#onRelease = void 0;\n\t\tthis.#onDestroy = void 0;\n\t\tonRelease?.();\n\t}\n\tasync destroy(reason) {\n\t\tconst onDestroy = this.#onDestroy;\n\t\tconst onRelease = this.#onRelease;\n\t\tthis.#onDestroy = void 0;\n\t\tthis.#onRelease = void 0;\n\t\tconst conn = this.#connection;\n\t\tif (\"release\" in conn) {\n\t\t\tconst releaseArg = reason instanceof Error ? reason : /* @__PURE__ */ new Error(\"Connection destroyed\");\n\t\t\tconn.release(releaseArg);\n\t\t}\n\t\tif (onDestroy) await onDestroy(reason);\n\t\telse onRelease?.();\n\t}\n};\nvar PostgresTransactionImpl = class extends PostgresQueryable {\n\t#connection;\n\t#onSettled;\n\t#onEnded;\n\tconstructor(connection, options, onSettled, onEnded) {\n\t\tsuper(options);\n\t\tthis.#connection = connection;\n\t\tthis.#onSettled = onSettled;\n\t\tthis.#onEnded = onEnded;\n\t}\n\tacquireClient() {\n\t\treturn Promise.resolve(this.#connection);\n\t}\n\treleaseClient(_client) {\n\t\treturn Promise.resolve();\n\t}\n\tinExplicitTransaction() {\n\t\treturn true;\n\t}\n\t#settle() {\n\t\tconst onSettled = this.#onSettled;\n\t\tthis.#onSettled = void 0;\n\t\tonSettled?.();\n\t}\n\tasync commit() {\n\t\tconst releaseLock = await acquireClientQueryLock(this.#connection);\n\t\ttry {\n\t\t\tawait this.#connection.query(\"COMMIT\").catch(rethrowClientError(this.#connection));\n\t\t\tthis.#onEnded();\n\t\t} finally {\n\t\t\treleaseLock();\n\t\t\tthis.#settle();\n\t\t}\n\t}\n\tasync rollback() {\n\t\tconst releaseLock = await acquireClientQueryLock(this.#connection);\n\t\ttry {\n\t\t\tawait this.#connection.query(\"ROLLBACK\").catch(rethrowClientError(this.#connection));\n\t\t\tthis.#onEnded();\n\t\t} finally {\n\t\t\treleaseLock();\n\t\t\tthis.#settle();\n\t\t}\n\t}\n};\nvar PostgresPoolDriverImpl = class extends PostgresQueryable {\n\tpool;\n\t#sessionSettings;\n\t#ownedByDriver;\n\t#closed = false;\n\tconstructor(options) {\n\t\tsuper(buildConnectionOptions(options));\n\t\tthis.pool = options.connect.pool;\n\t\tthis.#sessionSettings = new SessionSettingsGuard(options.sessionSettings ?? {}, this.pool);\n\t\tthis.#ownedByDriver = options.connect.ownedByDriver;\n\t}\n\tget state() {\n\t\treturn this.#closed ? \"closed\" : \"connected\";\n\t}\n\tasync connect(_binding) {}\n\tasync acquireConnection() {\n\t\tconst client = await this.acquireClient();\n\t\treturn new PostgresConnectionImpl(client, this.options, () => this.#sessionSettings.forget(client));\n\t}\n\tasync close() {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tif (this.#ownedByDriver) await this.pool.end();\n\t}\n\tasync acquireClient() {\n\t\tlet pooled;\n\t\ttry {\n\t\t\tpooled = await this.pool.connect();\n\t\t} catch (error) {\n\t\t\tthrow normalizePgConnectFailure(error);\n\t\t}\n\t\tconst client = watchClientLoss(suppressIdleConnectionErrors$1(pooled));\n\t\ttry {\n\t\t\tawait ensureSessionSettings(this.#sessionSettings, client);\n\t\t} catch (error) {\n\t\t\tconst normalized = normalizePgClientError(client, error);\n\t\t\tclient.release(true);\n\t\t\tthrow normalized;\n\t\t}\n\t\treturn client;\n\t}\n\tasync releaseClient(client) {\n\t\tclient.release();\n\t}\n};\nvar PostgresDirectDriverImpl = class extends PostgresQueryable {\n\tdirectClient;\n\t#sessionSettings;\n\t#ownedByDriver;\n\t#connectionMutex = new AsyncMutex();\n\t#closed = false;\n\t#connected = false;\n\t#connectPromise;\n\t#connectFailure;\n\t#txState = {\n\t\topen: false,\n\t\tunfinishedOnServer: false\n\t};\n\tconstructor(options) {\n\t\tsuper(buildConnectionOptions(options));\n\t\tthis.directClient = watchClientLoss(options.connect.client);\n\t\tthis.#ownedByDriver = options.connect.ownedByDriver;\n\t\tthis.#sessionSettings = new SessionSettingsGuard(options.sessionSettings ?? {}, this.directClient);\n\t}\n\tinExplicitTransaction() {\n\t\treturn this.#txState.open;\n\t}\n\tget state() {\n\t\treturn this.#closed || hasLostConnection(this.directClient) ? \"closed\" : \"connected\";\n\t}\n\tasync connect(_binding) {}\n\tasync acquireConnection() {\n\t\tconst releaseLease = await this.#connectionMutex.lock();\n\t\ttry {\n\t\t\tconst client = await this.acquireClient();\n\t\t\treturn new PostgresConnectionImpl(client, this.options, () => {\n\t\t\t\tthis.#sessionSettings.forget(client);\n\t\t\t\treleaseLease();\n\t\t\t}, async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.#closeWhileHoldingLease({ waitForStatement: false });\n\t\t\t\t} finally {\n\t\t\t\t\treleaseLease();\n\t\t\t\t}\n\t\t\t}, this.#txState);\n\t\t} catch (error) {\n\t\t\treleaseLease();\n\t\t\tthrow error;\n\t\t}\n\t}\n\tasync close() {\n\t\tconst releaseLease = await this.#connectionMutex.lock();\n\t\ttry {\n\t\t\tawait this.#closeWhileHoldingLease({ waitForStatement: true });\n\t\t} finally {\n\t\t\treleaseLease();\n\t\t}\n\t}\n\tasync #closeWhileHoldingLease(options) {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tif (!this.#ownedByDriver) {\n\t\t\tif (!options.waitForStatement) this.#giveUpSuppliedClient();\n\t\t\treturn;\n\t\t}\n\t\tif (this.#connectFailure !== void 0) {\n\t\t\tthis.directClient.end().catch(() => void 0);\n\t\t\treturn;\n\t\t}\n\t\tconst releaseQueryLock = options.waitForStatement ? await acquireClientQueryLock(this.directClient) : () => {};\n\t\ttry {\n\t\t\tawait this.directClient.end();\n\t\t} finally {\n\t\t\treleaseQueryLock();\n\t\t}\n\t\tthis.#connected = false;\n\t}\n\t#giveUpSuppliedClient() {\n\t\tmarkClientAbandoned(this.directClient);\n\t\tif (this.#txState.unfinishedOnServer) this.#rollbackUnderQueryLock().catch(() => void 0);\n\t}\n\tasync #rollbackUnderQueryLock() {\n\t\tconst releaseLock = await acquireClientQueryLock(this.directClient);\n\t\ttry {\n\t\t\tawait this.directClient.query(\"ROLLBACK\");\n\t\t} finally {\n\t\t\treleaseLock();\n\t\t}\n\t}\n\tasync acquireClient() {\n\t\tif (this.#connectFailure !== void 0) throw this.#connectFailure;\n\t\tif (this.#closed || hasLostConnection(this.directClient)) throw driverError(\"DRIVER.NOT_CONNECTED\", \"Postgres connection lost or closed. Create a new client to reconnect.\");\n\t\tif (!this.#connected) await this.#connectDirectClient();\n\t\tawait ensureSessionSettings(this.#sessionSettings, this.directClient).catch(rethrowClientError(this.directClient));\n\t\treturn this.directClient;\n\t}\n\tasync #connectDirectClient() {\n\t\tif (this.#connectPromise === void 0) {\n\t\t\tif (hasStartedConnecting(this.directClient)) {\n\t\t\t\tthis.#connected = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.#connectPromise = this.#connectClient();\n\t\t}\n\t\tawait this.#connectPromise;\n\t}\n\tasync #connectClient() {\n\t\ttry {\n\t\t\tawait this.directClient.connect();\n\t\t} catch (error) {\n\t\t\tthis.#connectFailure = normalizePgConnectFailure(error);\n\t\t\tthis.#connectPromise = void 0;\n\t\t\tthrow this.#connectFailure;\n\t\t}\n\t\tthis.#connected = true;\n\t}\n\tasync releaseClient(_client) {}\n};\nfunction createBoundDriverFromBinding(binding, cursorOpts, extraOpts) {\n\tconst preparedStatements = extraOpts?.preparedStatements;\n\tconst sessionSettings = extraOpts?.sessionSettings;\n\tswitch (binding.kind) {\n\t\tcase \"url\": return new PostgresPoolDriverImpl({\n\t\t\tconnect: {\n\t\t\t\tpool: suppressIdleConnectionErrors$1(createPgPool({\n\t\t\t\t\tconnectionString: binding.url,\n\t\t\t\t\tconnectionTimeoutMillis: 2e4,\n\t\t\t\t\tidleTimeoutMillis: 3e4\n\t\t\t\t}, sessionSettings ?? {})),\n\t\t\t\townedByDriver: true\n\t\t\t},\n\t\t\tcursor: cursorOpts,\n\t\t\tpreparedStatements,\n\t\t\tsessionSettings\n\t\t});\n\t\tcase \"pgPool\": return new PostgresPoolDriverImpl({\n\t\t\tconnect: {\n\t\t\t\tpool: suppressIdleConnectionErrors$1(binding.pool),\n\t\t\t\townedByDriver: binding.ownedByDriver\n\t\t\t},\n\t\t\tcursor: cursorOpts,\n\t\t\tpreparedStatements,\n\t\t\tsessionSettings\n\t\t});\n\t\tcase \"pgClient\":\n\t\t\tif (hasLostConnection(binding.client)) throw driverError(\"DRIVER.NOT_CONNECTED\", \"This pg client lost its connection or was given up by an earlier driver. Create a new client to reconnect.\");\n\t\t\treturn new PostgresDirectDriverImpl({\n\t\t\t\tconnect: {\n\t\t\t\t\tclient: suppressIdleConnectionErrors$1(binding.client),\n\t\t\t\t\townedByDriver: binding.ownedByDriver\n\t\t\t\t},\n\t\t\t\tcursor: cursorOpts,\n\t\t\t\tpreparedStatements,\n\t\t\t\tsessionSettings\n\t\t\t});\n\t}\n}\n/** Ensures the session settings on a client the driver is about to use, holding the client's query lock while it does. */\nasync function ensureSessionSettings(guard, client) {\n\tif (!guard.needs(client)) return;\n\tconst releaseLock = await acquireClientQueryLock(client);\n\ttry {\n\t\tawait guard.ensure(client);\n\t} finally {\n\t\treleaseLock();\n\t}\n}\nfunction readCursor(cursor, size) {\n\treturn callbackToPromise((cb) => {\n\t\tcursor.read(size, (err, rows) => cb(err, rows));\n\t});\n}\nfunction closeCursor(cursor) {\n\treturn callbackToPromise((cb) => cursor.close(cb));\n}\nfunction rethrowClientError(client) {\n\treturn (error) => {\n\t\tthrow normalizePgClientError(client, error);\n\t};\n}\nfunction prepareFailedError(retryError, handle) {\n\tconst cause = retryError instanceof Error ? retryError : new Error(String(retryError));\n\treturn Object.assign(driverError(\"DRIVER.PREPARE_FAILED\", `Prepared statement failed again after re-preparing with a fresh handle: ${cause.message}`, { handle }), { cause });\n}\n//#endregion\n//#region src/exports/runtime.ts\nconst USE_BEFORE_CONNECT_MESSAGE = \"Postgres driver not connected. Call connect(binding) before acquireConnection or execute.\";\nconst CLOSED_MESSAGE = \"Postgres driver is closed. Call connect(binding) to reconnect.\";\nconst CONNECTION_LOST_MESSAGE = \"Postgres connection lost or closed. Call connect(binding) to reconnect.\";\nconst ALREADY_CONNECTED_MESSAGE = \"Postgres driver already connected. Call close() before reconnecting with a new binding.\";\nfunction unboundQuery(notConnected) {\n\treturn { [Symbol.asyncIterator]() {\n\t\treturn { async next() {\n\t\t\tthrow notConnected();\n\t\t} };\n\t} };\n}\nconst notConnectedMessages = {\n\tunbound: USE_BEFORE_CONNECT_MESSAGE,\n\tclosed: CLOSED_MESSAGE,\n\tconnectionLost: CONNECTION_LOST_MESSAGE\n};\nvar PostgresUnboundDriverImpl = class {\n\tfamilyId = \"sql\";\n\ttargetId = \"postgres\";\n\t#delegate = null;\n\t#disconnectedState = \"unbound\";\n\t#cursorOpts;\n\t#preparedStatements;\n\t#sessionSettings;\n\tconstructor(options) {\n\t\tthis.#cursorOpts = options?.cursor;\n\t\tthis.#preparedStatements = options?.preparedStatements;\n\t\tthis.#sessionSettings = options?.sessionSettings;\n\t}\n\tget state() {\n\t\tif (this.#delegate !== null) return \"connected\";\n\t\treturn this.#disconnectedState === \"unbound\" ? \"unbound\" : \"closed\";\n\t}\n\t#notConnectedError() {\n\t\treturn driverError(\"DRIVER.NOT_CONNECTED\", notConnectedMessages[this.#disconnectedState]);\n\t}\n\t#requireDelegate() {\n\t\tconst delegate = this.#delegate;\n\t\tif (delegate === null) throw this.#notConnectedError();\n\t\treturn delegate;\n\t}\n\tasync connect(binding) {\n\t\tif (this.#delegate !== null) throw driverError(\"DRIVER.ALREADY_CONNECTED\", ALREADY_CONNECTED_MESSAGE, { bindingKind: binding.kind });\n\t\tthis.#delegate = createBoundDriverFromBinding(binding, this.#cursorOpts, {\n\t\t\tpreparedStatements: this.#preparedStatements,\n\t\t\tsessionSettings: this.#sessionSettings\n\t\t});\n\t\tthis.#disconnectedState = \"unbound\";\n\t}\n\tasync acquireConnection() {\n\t\tconst delegate = this.#requireDelegate();\n\t\tconst connection = await delegate.acquireConnection();\n\t\treturn this.#wrapConnection(connection, delegate);\n\t}\n\t/**\n\t* Wraps an acquired connection so that teardown paths which close the\n\t* underlying delegate (notably `destroy()` on a pgClient binding, where\n\t* the single socket means a destroyed connection invalidates the driver)\n\t* also reset our own `#delegate` reference. Without this, a failed\n\t* transaction rollback would leave the outer unbound wrapper reporting\n\t* `connected` while routing subsequent work to an already-ended delegate.\n\t*/\n\t#wrapConnection(connection, delegate) {\n\t\tconst syncDelegateState = () => {\n\t\t\tif (this.#delegate === delegate && delegate.state === \"closed\") {\n\t\t\t\tthis.#delegate = null;\n\t\t\t\tthis.#disconnectedState = \"connectionLost\";\n\t\t\t}\n\t\t};\n\t\tconst wrapped = {\n\t\t\tbeginTransaction: connection.beginTransaction.bind(connection),\n\t\t\tquery: connection.query.bind(connection),\n\t\t\texecute: connection.execute.bind(connection),\n\t\t\trelease: async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait connection.release();\n\t\t\t\t} finally {\n\t\t\t\t\tsyncDelegateState();\n\t\t\t\t}\n\t\t\t},\n\t\t\tdestroy: async (reason) => {\n\t\t\t\ttry {\n\t\t\t\t\tawait connection.destroy(reason);\n\t\t\t\t} finally {\n\t\t\t\t\tsyncDelegateState();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tif (connection.explain) wrapped.explain = connection.explain.bind(connection);\n\t\treturn wrapped;\n\t}\n\tasync close() {\n\t\tconst delegate = this.#delegate;\n\t\tthis.#delegate = null;\n\t\tthis.#disconnectedState = \"closed\";\n\t\tawait delegate?.close();\n\t}\n\tquery(request) {\n\t\tconst delegate = this.#delegate;\n\t\treturn delegate === null ? unboundQuery(() => this.#notConnectedError()) : delegate.query(request);\n\t}\n\tasync execute(request) {\n\t\treturn this.#requireDelegate().execute(request);\n\t}\n\tasync explain(request) {\n\t\tconst delegate = this.#requireDelegate();\n\t\tconst explain = delegate.explain;\n\t\tif (explain === void 0) throw driverError(\"DRIVER.NOT_CONNECTED\", USE_BEFORE_CONNECT_MESSAGE);\n\t\treturn explain.call(delegate, request);\n\t}\n};\nconst postgresRuntimeDriverDescriptor = {\n\t...postgresDriverDescriptorMeta,\n\tcreate(options, sessionSettings) {\n\t\treturn new PostgresUnboundDriverImpl({\n\t\t\t...options,\n\t\t\t...ifDefined(\"sessionSettings\", sessionSettings)\n\t\t});\n\t}\n};\n//#endregion\nexport { createPgClient, createPgPool, postgresRuntimeDriverDescriptor as default, suppressIdleConnectionErrors };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;AAOA,SAAS,YAAY,MAAM,SAAS,SAAS;CAC5C,MAAM,QAAQ,IAAI,MAAM,OAAO;CAC/B,OAAO,eAAe,OAAO,QAAQ;EACpC,OAAO;EACP,cAAc;CACf,CAAC;CACD,OAAO,YAAY,KAAK,IAAI,OAAO,OAAO,OAAO;EAChD;EACA,UAAU;EACV,UAAU;CACX,CAAC,IAAI,OAAO,OAAO,OAAO;EACzB;EACA,UAAU;EACV,UAAU;EACV;CACD,CAAC;AACF;AAGA,SAAS,kBAAkB,IAAI;CAC9B,OAAO,IAAI,SAAS,SAAS,WAAW;EACvC,IAAI,KAAK,WAAW;GACnB,IAAI,KAAK;IACR,OAAO,GAAG;IACV;GACD;GACA,QAAQ,MAAM;EACf,CAAC;CACF,CAAC;AACF;AAGA,IAAI,oBAAoB;;AAExB,IAAI,cAAc,cAAc,OAAO;CACtC;CACA,YAAY,MAAM;EACjB,MAAM,KAAK,MAAM,CAAC,GAAG,KAAK,MAAM,GAAG,KAAK,MAAM;EAC9C,KAAK,OAAO,KAAK;EACjB,KAAK,SAAS,KAAK;CACpB;CACA,YAAY,YAAY;EACvB,MAAM,OAAO;EACb,MAAM,OAAO;EACb,KAAK,QAAQ;EACb,KAAK,aAAa;EAClB,KAAK,UAAU,MAAM;EACrB,IAAI,CAAC,KAAK,iBAAiB,KAAK,OAAO;GACtC,MAAM,eAAe;IACpB,MAAM,KAAK;IACX,MAAM,KAAK;IACX,OAAO,CAAC;GACT;GACA,KAAK,MAAM,cAAc,IAAI;EAC9B;EACA,MAAM,cAAc;GACnB,QAAQ,KAAK;GACb,WAAW,KAAK;GAChB,QAAQ,KAAK,UAAU,CAAC;EACzB;EACA,KAAK,KAAK,aAAa,IAAI;EAC3B,KAAK,SAAS;GACb,MAAM;GACN,MAAM,KAAK;EACZ,GAAG,IAAI;EACP,KAA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AU,OAAO;CACtC;AACD;AACA,MAAM,kCAAkC;CACvC,GAAG;CACH,OAAO,SAAS,iBAAiB;EAChC,OAAO,IAAI,0BAA0B;GACpC,GAAG;GACH,GAAG,UAAU,mBAAmB,eAAe;EAChD,CAAC;CACF;AACD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sql-renderer-D6fBWtjL-BOe5jc4e.mjs","names":[],"sources":["../../../../3-targets/postgres/2-adapter/dist/sql-renderer-D6fBWtjL.mjs"],"sourcesContent":["import { dataTypeParams } from \"@internal/framework-components/codec\";\nimport { LiteralExpr, collectOrderedParamRefs, lockOptionCapabilities, lockStrengthCapabilities, missingCapability } from \"@internal/sql-relational-core/ast\";\nimport { pgBit, pgBool, pgChar, pgFloat4, pgFloat8, pgInt2, pgInt4, pgInt8, pgInterval, pgMoney, pgNumeric, pgText, pgTime, pgTimestamp, pgTimestamptz, pgTimetz, pgVarbit, pgVarchar } from \"@internal/target-postgres/data-types\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { escapeLiteral, quoteIdentifier } from \"@internal/target-postgres/sql-utils\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { InternalError, assertNever } from \"@internal/utils/internal-error\";\nimport { isPlainRecord } from \"@internal/contract/is-plain-record\";\nimport { runtimeError } from \"@internal/framework-components/runtime\";\nimport { nameIsCatalogText, sqlBaseName, sqlDataTypeOfCodec } from \"@internal/sql-contract/data-type\";\n//#region src/core/adapter-errors.ts\nfunction adapterError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n//#endregion\n//#region src/core/sql-renderer.ts\n/**\n* Data types whose unknown-OID parameter inference is reliable in arbitrary expression positions. A parameter whose codec represents one of these is emitted as plain `$N`; everything else (including `pg/json`, `pg/jsonb`, extension types like `pgvector/vector`, and enums) is emitted as `$N::<base name>` so the planner picks an unambiguous overload.\n*\n* `pg/json` / `pg/jsonb` are intentionally excluded: their operator overloads make context inference unreliable in expression positions (e.g. `$1 -> 'key'` is ambiguous between the two).\n*/\nconst POSTGRES_INFERRABLE_DATA_TYPES = /* @__PURE__ */ new Set([\n\tpgInt2.id,\n\tpgInt4.id,\n\tpgInt8.id,\n\tpgFloat4.id,\n\tpgFloat8.id,\n\tpgNumeric.id,\n\tpgBool.id,\n\tpgText.id,\n\tpgChar.id,\n\tpgVarchar.id,\n\tpgTimestamp.id,\n\tpgTimestamptz.id,\n\tpgTime.id,\n\tpgTimetz.id,\n\tpgInterval.id,\n\tpgBit.id,\n\tpgVarbit.id\n]);\n/**\n* Data types whose parameter PostgreSQL first reads as another type, because their own input function depends on a session setting. `money` input reads the decimal point and thousands separator of `lc_monetary`, so `12.50` is 1250.00 under `de_DE`; converting `numeric` to `money` reads no separators.\n*/\nconst POSTGRES_PARAMETER_READ_AS = /* @__PURE__ */ new Map([[pgMoney.id, sqlBaseName(pgNumeric, {})]]);\n/**\n* A parameter's cast names its data type's base name, which leaves out its parameters: an explicit\n* cast to `varchar(n)` truncates and to `numeric(p,s)` rounds. A data type whose name is its catalog\n* text has no base name, so its parameter is never cast, in any position, and the column's own input\n* function reads the value.\n*/\nfunction renderTypedParam(index, codecId, types, many, typeParams, forceCast = false) {\n\tif (codecId === void 0) return `$${index}`;\n\tif (types.codecDescriptorRegistry.descriptorFor(codecId) === void 0) throw adapterError(\"RUNTIME.PARAM_REF_MISSING_CODEC\", `Postgres lowering: ParamRef carries codecId \"${codecId}\" but the validated PostgreSQL codec registry has no entry for it. This usually indicates a missing extension pack in the runtime stack — register the pack that contributes this codec (e.g. \\`extensions: [pgvectorRuntime]\\`), or use the codec directly from \\`@internal/target-postgres/codecs\\` if it's a builtin.`, { meta: { codecId } });\n\tconst dataType = sqlDataTypeOfCodec(codecId, {\n\t\tcodecLookup: types.codecDescriptorRegistry,\n\t\tdataTypeLookup: types.dataTypeLookup\n\t});\n\tif (nameIsCatalogText(dataType)) return `$${index}`;\n\tconst arraySuffix = many ? \"[]\" : \"\";\n\tif (forceCast || !POSTGRES_INFERRABLE_DATA_TYPES.has(dataType.id) || many) {\n\t\tconst baseName = sqlBaseName(dataType, dataTypeParams(dataType, isPlainRecord(typeParams) ? typeParams : void 0));\n\t\tconst readAs = POSTGRES_PARAMETER_READ_AS.get(dataType.id);\n\t\treturn `$${index}${readAs === void 0 ? \"\" : `::${readAs}${arraySuffix}`}::${baseName}${arraySuffix}`;\n\t}\n\treturn `$${index}`;\n}\nfunction unreachableKind(value) {\n\tconst candidate = value;\n\tif (typeof candidate === \"object\" && candidate !== null && \"kind\" in candidate && typeof candidate.kind === \"string\") return candidate.kind;\n\treturn \"unknown\";\n}\n/**\n* Render a SQL query AST to a Postgres-flavored `{ sql, params }` payload.\n*\n* Shared between the runtime (`PostgresAdapterImpl.lower`) and control (`PostgresControlAdapter.lower`) entrypoints so emit-time and run-time paths produce byte-identical output for the same AST.\n*/\nfunction renderLoweredSql(ast, contract, codecDescriptorRegistry, dataTypeLookup, capabilities) {\n\tconst orderedRefs = collectOrderedParamRefs(ast);\n\tconst indexMap = /* @__PURE__ */ new Map();\n\tconst params = orderedRefs.map((ref, i) => {\n\t\tindexMap.set(ref, i + 1);\n\t\treturn ref.kind === \"prepared-param-ref\" ? {\n\t\t\tkind: \"bind\",\n\t\t\tname: ref.name\n\t\t} : {\n\t\t\tkind: \"literal\",\n\t\t\tvalue: ref.value\n\t\t};\n\t});\n\tconst pim = {\n\t\tindexMap,\n\t\ttypes: {\n\t\t\tcodecDescriptorRegistry,\n\t\t\tdataTypeLookup\n\t\t},\n\t\tcapabilities\n\t};\n\tconst node = ast;\n\tlet sql;\n\tswitch (node.kind) {\n\t\tcase \"select\":\n\t\t\tsql = renderSelect(node, contract, pim);\n\t\t\tbreak;\n\t\tcase \"insert\":\n\t\t\tsql = renderInsert(node, contract, pim);\n\t\t\tbreak;\n\t\tcase \"update\":\n\t\t\tsql = renderUpdate(node, contract, pim);\n\t\t\tbreak;\n\t\tcase \"delete\":\n\t\t\tsql = renderDelete(node, contract, pim);\n\t\t\tbreak;\n\t\tcase \"raw-query\":\n\t\t\tsql = renderParts(node.parts, contract, pim);\n\t\t\tbreak;\n\t\t// v8 ignore next 4\n\t\tdefault: assertNever(node, `Unsupported AST node kind: ${unreachableKind(node)}`);\n\t}\n\treturn Object.freeze({\n\t\tsql,\n\t\tparams: Object.freeze(params)\n\t});\n}\nfunction renderLimitOffset(keyword, value, contract, pim) {\n\tif (value === void 0) return \"\";\n\tif (typeof value === \"number\") return `${keyword} ${value}`;\n\treturn `${keyword} ${renderExpr(value, contract, pim)}`;\n}\nfunction renderSelect(ast, contract, pim) {\n\treturn [\n\t\t`SELECT ${renderDistinctPrefix(ast.distinct, ast.distinctOn, contract, pim)}${renderProjection(ast.projection, contract, pim)}`,\n\t\tast.from !== void 0 ? `FROM ${renderSource(ast.from, contract, pim)}` : \"\",\n\t\tast.joins?.length ? ast.joins.map((join) => renderJoin(join, contract, pim)).join(\" \") : \"\",\n\t\tast.where ? `WHERE ${renderWhere(ast.where, contract, pim)}` : \"\",\n\t\tast.groupBy?.length ? `GROUP BY ${ast.groupBy.map((expr) => renderExpr(expr, contract, pim)).join(\", \")}` : \"\",\n\t\tast.having ? `HAVING ${renderWhere(ast.having, contract, pim)}` : \"\",\n\t\tast.orderBy?.length ? `ORDER BY ${renderOrderByItems(ast.orderBy, contract, pim)}` : \"\",\n\t\trenderLimitOffset(\"LIMIT\", ast.limit, contract, pim),\n\t\trenderLimitOffset(\"OFFSET\", ast.offset, contract, pim),\n\t\t(ast.locking ?? []).map((clause) => renderLockingClause(clause, pim.capabilities)).join(\" \")\n\t].filter((part) => part.length > 0).join(\" \").trim();\n}\nfunction lockStrengthKeyword(strength) {\n\tswitch (strength) {\n\t\tcase \"forUpdate\": return \"FOR UPDATE\";\n\t\tcase \"forNoKeyUpdate\": return \"FOR NO KEY UPDATE\";\n\t\tcase \"forShare\": return \"FOR SHARE\";\n\t\tcase \"forKeyShare\": return \"FOR KEY SHARE\";\n\t\tdefault: return assertNever(strength, `Unsupported lock strength: ${String(strength)}`);\n\t}\n}\nfunction lockWaitPolicyKeyword(waitPolicy) {\n\tswitch (waitPolicy) {\n\t\tcase \"nowait\": return \"NOWAIT\";\n\t\tcase \"skipLocked\": return \"SKIP LOCKED\";\n\t\tdefault: return assertNever(waitPolicy, `Unsupported lock wait policy: ${String(waitPolicy)}`);\n\t}\n}\nfunction requireCapability(capabilities, requirement) {\n\tconst capability = missingCapability(capabilities, requirement);\n\tif (capability !== void 0) throw adapterError(\"RUNTIME.AST_UNSUPPORTED\", `Postgres adapter does not report capability ${capability}, which this locking clause needs`, { meta: {\n\t\ttarget: \"postgres\",\n\t\tfeature: \"locking-clause\",\n\t\tcapability\n\t} });\n}\nfunction renderLockingClause(clause, capabilities) {\n\trequireCapability(capabilities, lockStrengthCapabilities[clause.strength]);\n\tconst parts = [lockStrengthKeyword(clause.strength)];\n\tif (clause.of !== void 0) {\n\t\trequireCapability(capabilities, lockOptionCapabilities.of);\n\t\tparts.push(`OF ${clause.of.map((name) => quoteIdentifier(name)).join(\", \")}`);\n\t}\n\tif (clause.waitPolicy !== void 0) {\n\t\trequireCapability(capabilities, lockOptionCapabilities[clause.waitPolicy]);\n\t\tparts.push(lockWaitPolicyKeyword(clause.waitPolicy));\n\t}\n\treturn parts.join(\" \");\n}\nfunction renderProjection(projection, contract, pim) {\n\treturn projection.map((item) => {\n\t\tconst alias = quoteIdentifier(item.alias);\n\t\tif (item.expr.kind === \"literal\") return `${renderLiteral(item.expr)} AS ${alias}`;\n\t\tif (item.expr.kind === \"prepared-param-ref\") return `${renderParamRef(item.expr, pim, true)} AS ${alias}`;\n\t\treturn `${renderExpr(item.expr, contract, pim)} AS ${alias}`;\n\t}).join(\", \");\n}\nfunction renderReturning(items, contract, pim) {\n\treturn items.map((item) => {\n\t\tif (item.expr.kind === \"column-ref\") {\n\t\t\tconst rendered = renderColumn(item.expr);\n\t\t\treturn item.expr.column === item.alias ? rendered : `${rendered} AS ${quoteIdentifier(item.alias)}`;\n\t\t}\n\t\tif (item.expr.kind === \"literal\") return `${renderLiteral(item.expr)} AS ${quoteIdentifier(item.alias)}`;\n\t\treturn `${renderExpr(item.expr, contract, pim)} AS ${quoteIdentifier(item.alias)}`;\n\t}).join(\", \");\n}\nfunction renderDistinctPrefix(distinct, distinctOn, contract, pim) {\n\tif (distinctOn && distinctOn.length > 0) return `DISTINCT ON (${distinctOn.map((expr) => renderExpr(expr, contract, pim)).join(\", \")}) `;\n\tif (distinct) return \"DISTINCT \";\n\treturn \"\";\n}\nfunction hasExplicitSchema(table) {\n\treturn \"schema\" in table && typeof table.schema === \"string\";\n}\nfunction qualifyTableFromNamespaceCoordinate(table, contract) {\n\tif (hasExplicitSchema(table)) return `${quoteIdentifier(table.schema)}.${quoteIdentifier(table.name)}`;\n\tif (table.namespaceId === void 0) return quoteIdentifier(table.name);\n\tconst namespace = contract.storage.namespaces[table.namespaceId];\n\tif (namespace === void 0) throw adapterError(\"RUNTIME.NAMESPACE_UNKNOWN\", `Table \"${table.name}\" references namespace \"${table.namespaceId}\" which is not present as a Postgres schema on the contract`, { meta: {\n\t\ttable: table.name,\n\t\tnamespaceId: table.namespaceId,\n\t\treason: \"not-present\"\n\t} });\n\tconst qualifyTable = namespace.qualifyTable;\n\tif (qualifyTable === void 0) throw adapterError(\"RUNTIME.NAMESPACE_UNKNOWN\", `Table \"${table.name}\" references namespace \"${table.namespaceId}\" which is not materialised as a Postgres schema on the contract`, { meta: {\n\t\ttable: table.name,\n\t\tnamespaceId: table.namespaceId,\n\t\treason: \"not-materialised\"\n\t} });\n\treturn qualifyTable.call(namespace, table.name);\n}\nfunction renderTableSource(source, contract) {\n\tconst qualified = qualifyTableFromNamespaceCoordinate(source, contract);\n\tif (!source.alias) return qualified;\n\treturn `${qualified} AS ${quoteIdentifier(source.alias)}`;\n}\nfunction renderSource(source, contract, pim) {\n\tconst node = source;\n\tswitch (node.kind) {\n\t\tcase \"table-source\": return renderTableSource(node, contract);\n\t\tcase \"derived-table-source\": return `(${renderSelect(node.query, contract, pim)}) AS ${quoteIdentifier(node.alias)}`;\n\t\tcase \"function-source\": {\n\t\t\tconst args = node.args.map((arg) => renderExpr(arg, contract, pim)).join(\", \");\n\t\t\treturn `${`${node.fn}(${args})`}${node.ordinality ? \" WITH ORDINALITY\" : \"\"}${node.alias === void 0 ? \"\" : ` AS ${quoteIdentifier(node.alias)}`}${node.columnAliases === void 0 ? \"\" : `(${node.columnAliases.map((column) => quoteIdentifier(column)).join(\", \")})`}`;\n\t\t}\n\t\t// v8 ignore next 4\n\t\tdefault: assertNever(node, `Unsupported source node kind: ${unreachableKind(node)}`);\n\t}\n}\nfunction assertScalarSubquery(query) {\n\tif (query.projection.length !== 1) throw adapterError(\"RUNTIME.AST_INVALID\", \"Subquery expressions must project exactly one column\", { meta: { node: \"subquery-expr\" } });\n}\nfunction renderSubqueryExpr(expr, contract, pim) {\n\tassertScalarSubquery(expr.query);\n\treturn `(${renderSelect(expr.query, contract, pim)})`;\n}\nfunction renderWhere(expr, contract, pim) {\n\treturn renderExpr(expr, contract, pim);\n}\nfunction renderNullCheck(expr, contract, pim) {\n\tconst rendered = renderExpr(expr.expr, contract, pim);\n\tconst renderedExpr = isAtomicExpressionKind(expr.expr.kind) ? rendered : `(${rendered})`;\n\treturn expr.isNull ? `${renderedExpr} IS NULL` : `${renderedExpr} IS NOT NULL`;\n}\n/**\n* Atomic expression kinds whose rendered SQL is already self-delimited (a column reference, parameter, literal, function call, aggregate, etc.) and therefore does not need surrounding parentheses when used as the left operand of a postfix predicate like `IS NULL` or `IS NOT NULL`, or as either operand of a binary infix operator.\n*\n* Anything not in this set is treated as composite (binary, AND/OR/NOT, EXISTS, nested IS NULL, subqueries, operation templates) and gets wrapped to preserve grouping.\n*/\nfunction isAtomicExpressionKind(kind) {\n\tswitch (kind) {\n\t\tcase \"column-ref\":\n\t\tcase \"identifier-ref\":\n\t\tcase \"param-ref\":\n\t\tcase \"prepared-param-ref\":\n\t\tcase \"literal\":\n\t\tcase \"aggregate\":\n\t\tcase \"window-func\":\n\t\tcase \"function-call\":\n\t\tcase \"cast\":\n\t\tcase \"case\":\n\t\tcase \"json-object\":\n\t\tcase \"json-array-agg\":\n\t\tcase \"list\": return true;\n\t\tcase \"subquery\":\n\t\tcase \"operation\":\n\t\tcase \"binary\":\n\t\tcase \"and\":\n\t\tcase \"or\":\n\t\tcase \"exists\":\n\t\tcase \"null-check\":\n\t\tcase \"not\":\n\t\tcase \"raw-expr\": return false;\n\t}\n}\nfunction renderBinary(expr, contract, pim) {\n\tif (expr.right.kind === \"list\" && expr.right.values.length === 0) {\n\t\tif (expr.op === \"in\") return \"FALSE\";\n\t\tif (expr.op === \"notIn\") return \"TRUE\";\n\t}\n\tconst leftExpr = expr.left;\n\tconst left = renderExpr(leftExpr, contract, pim);\n\tconst leftRendered = leftExpr.kind === \"operation\" || leftExpr.kind === \"subquery\" ? `(${left})` : left;\n\tconst rightNode = expr.right;\n\tlet right;\n\tswitch (rightNode.kind) {\n\t\tcase \"list\":\n\t\t\tright = renderListLiteral(rightNode, contract, pim);\n\t\t\tbreak;\n\t\tcase \"literal\":\n\t\t\tright = renderLiteral(rightNode);\n\t\t\tbreak;\n\t\tcase \"column-ref\":\n\t\t\tright = renderColumn(rightNode);\n\t\t\tbreak;\n\t\tcase \"param-ref\":\n\t\tcase \"prepared-param-ref\":\n\t\t\tright = renderParamRef(rightNode, pim);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tright = renderExpr(rightNode, contract, pim);\n\t\t\tbreak;\n\t}\n\treturn `${leftRendered} ${{\n\t\teq: \"=\",\n\t\tneq: \"!=\",\n\t\tisNotDistinctFrom: \"IS NOT DISTINCT FROM\",\n\t\tisDistinctFrom: \"IS DISTINCT FROM\",\n\t\tgt: \">\",\n\t\tlt: \"<\",\n\t\tgte: \">=\",\n\t\tlte: \"<=\",\n\t\tlike: \"LIKE\",\n\t\tin: \"IN\",\n\t\tnotIn: \"NOT IN\"\n\t}[expr.op]} ${right}`;\n}\nfunction renderListLiteral(expr, contract, pim) {\n\tif (expr.values.length === 0) return \"(NULL)\";\n\treturn `(${expr.values.map((v) => {\n\t\tif (v.kind === \"param-ref\" || v.kind === \"prepared-param-ref\") return renderParamRef(v, pim);\n\t\tif (v.kind === \"literal\") return renderLiteral(v);\n\t\treturn renderExpr(v, contract, pim);\n\t}).join(\", \")})`;\n}\nfunction renderColumn(ref) {\n\tif (ref.table === \"excluded\") return `excluded.${quoteIdentifier(ref.column)}`;\n\treturn `${quoteIdentifier(ref.table)}.${quoteIdentifier(ref.column)}`;\n}\nfunction renderAggregateExpr(expr, contract, pim) {\n\tconst fn = expr.fn.toUpperCase();\n\tif (!expr.expr) return `${fn}(*)`;\n\treturn `${fn}(${renderExpr(expr.expr, contract, pim)})`;\n}\nfunction renderWindowFuncExpr(expr, contract, pim) {\n\treturn `${expr.fn.toUpperCase()}(${expr.args.map((arg) => renderExpr(arg, contract, pim)).join(\", \")}) OVER (${[expr.partitionBy && expr.partitionBy.length > 0 ? `PARTITION BY ${expr.partitionBy.map((e) => renderExpr(e, contract, pim)).join(\", \")}` : \"\", expr.orderBy && expr.orderBy.length > 0 ? `ORDER BY ${renderOrderByItems(expr.orderBy, contract, pim)}` : \"\"].filter((part) => part.length > 0).join(\" \")})`;\n}\nfunction renderFunctionCallExpr(expr, contract, pim) {\n\tconst args = expr.args.map((arg) => renderExpr(arg, contract, pim)).join(\", \");\n\treturn `${expr.fn}(${args})`;\n}\nfunction renderCastExpr(expr, contract, pim) {\n\treturn `CAST(${renderExpr(expr.expr, contract, pim)} AS ${expr.targetType})`;\n}\nfunction renderCaseExpr(expr, contract, pim) {\n\treturn `CASE ${expr.branches.map((branch) => `WHEN ${renderExpr(branch.condition, contract, pim)} THEN ${renderExpr(branch.value, contract, pim)}`).join(\" \")}${expr.elseExpr === void 0 ? \"\" : ` ELSE ${renderExpr(expr.elseExpr, contract, pim)}`} END`;\n}\nfunction renderJsonValueProjection(projection, contract, pim) {\n\treturn projection.accept({\n\t\tcodec: ({ value, codec }) => renderExpr(projectJsonThroughCodec(value, codec, pim), contract, pim),\n\t\tnative: ({ value }) => renderExpr(value, contract, pim),\n\t\tdocument: ({ value }) => renderExpr(value, contract, pim)\n\t});\n}\nfunction projectJsonThroughCodec(value, codec, pim) {\n\tconst descriptor = pim.types.codecDescriptorRegistry.descriptorFor(codec.codecId);\n\tif (descriptor === void 0) throw adapterError(\"RUNTIME.PARAM_REF_MISSING_CODEC\", `Postgres lowering: a JSON projection carries codecId \"${codec.codecId}\" but the validated PostgreSQL codec registry has no entry for it. This usually indicates a missing extension pack in the runtime stack — register the pack that contributes this codec (e.g. \\`extensions: [pgvectorRuntime]\\`), or use the codec directly from \\`@internal/target-postgres/codecs\\` if it's a builtin.`, { meta: { codecId: codec.codecId } });\n\treturn descriptor.projectJson(value, codec);\n}\nfunction renderJsonObjectExpr(expr, contract, pim) {\n\treturn `json_build_object(${expr.entries.flatMap((entry) => {\n\t\treturn [`'${escapeLiteral(entry.key)}'`, renderJsonValueProjection(entry.value, contract, pim)];\n\t}).join(\", \")})`;\n}\nfunction renderOrderByItems(items, contract, pim) {\n\treturn items.map((item) => `${renderExpr(item.expr, contract, pim)}${ORDER_DIRECTION_SQL[item.dir]}${renderNullsPlacement(item)}`).join(\", \");\n}\nconst ORDER_DIRECTION_SQL = {\n\tasc: \" ASC\",\n\tdesc: \" DESC\"\n};\nconst ORDER_NULLS_SQL = {\n\tfirst: \" NULLS FIRST\",\n\tlast: \" NULLS LAST\"\n};\nfunction renderNullsPlacement(item) {\n\treturn item.nulls === void 0 ? \"\" : ORDER_NULLS_SQL[item.nulls];\n}\nfunction renderJsonArrayAggExpr(expr, contract, pim) {\n\tconst aggregateOrderBy = expr.orderBy && expr.orderBy.length > 0 ? ` ORDER BY ${renderOrderByItems(expr.orderBy, contract, pim)}` : \"\";\n\tconst aggregated = `json_agg(${renderJsonValueProjection(expr.expr, contract, pim)}${aggregateOrderBy})`;\n\tif (expr.onEmpty === \"emptyArray\") return `coalesce(${aggregated}, json_build_array())`;\n\treturn aggregated;\n}\nfunction renderExpr(expr, contract, pim) {\n\tconst node = expr;\n\tswitch (node.kind) {\n\t\tcase \"column-ref\": return renderColumn(node);\n\t\tcase \"identifier-ref\": return quoteIdentifier(node.name);\n\t\tcase \"operation\": return renderOperation(node, contract, pim);\n\t\tcase \"subquery\": return renderSubqueryExpr(node, contract, pim);\n\t\tcase \"aggregate\": return renderAggregateExpr(node, contract, pim);\n\t\tcase \"window-func\": return renderWindowFuncExpr(node, contract, pim);\n\t\tcase \"function-call\": return renderFunctionCallExpr(node, contract, pim);\n\t\tcase \"cast\": return renderCastExpr(node, contract, pim);\n\t\tcase \"case\": return renderCaseExpr(node, contract, pim);\n\t\tcase \"json-object\": return renderJsonObjectExpr(node, contract, pim);\n\t\tcase \"json-array-agg\": return renderJsonArrayAggExpr(node, contract, pim);\n\t\tcase \"binary\": return renderBinary(node, contract, pim);\n\t\tcase \"and\":\n\t\t\tif (node.exprs.length === 0) return \"TRUE\";\n\t\t\treturn `(${node.exprs.map((part) => renderExpr(part, contract, pim)).join(\" AND \")})`;\n\t\tcase \"or\":\n\t\t\tif (node.exprs.length === 0) return \"FALSE\";\n\t\t\treturn `(${node.exprs.map((part) => renderExpr(part, contract, pim)).join(\" OR \")})`;\n\t\tcase \"exists\": return `${node.notExists ? \"NOT \" : \"\"}EXISTS (${renderSelect(node.subquery, contract, pim)})`;\n\t\tcase \"null-check\": return renderNullCheck(node, contract, pim);\n\t\tcase \"not\": return `NOT (${renderExpr(node.expr, contract, pim)})`;\n\t\tcase \"param-ref\":\n\t\tcase \"prepared-param-ref\": return renderParamRef(node, pim);\n\t\tcase \"literal\": return renderLiteral(node);\n\t\tcase \"list\": return renderListLiteral(node, contract, pim);\n\t\tcase \"raw-expr\": return renderRawExpr(node, contract, pim);\n\t\t// v8 ignore next 4\n\t\tdefault: assertNever(node, `Unsupported expression node kind: ${unreachableKind(node)}`);\n\t}\n}\nfunction renderParamRef(ref, pim, forceCast = false) {\n\tconst index = pim.indexMap.get(ref);\n\tif (index === void 0) throw new InternalError(\"ParamRef not found in index map\");\n\tif (ref.kind === \"prepared-param-ref\") return renderTypedParam(index, ref.codec.codecId, pim.types, ref.codec.many, ref.codec.typeParams, forceCast);\n\tif (ref.codec === void 0) throw runtimeError(\"RUNTIME.PARAM_REF_MISSING_CODEC\", \"Postgres renderer: ParamRef reached lowering without a bound CodecRef. Every column-bound ParamRef must carry a codec under the AST-bound codec contract. This usually indicates a builder path that constructed a ParamRef without threading the column codec.\", {\n\t\tparamIndex: index,\n\t\t...ifDefined(\"name\", ref.name)\n\t});\n\treturn renderTypedParam(index, ref.codec.codecId, pim.types, ref.codec.many, ref.codec.typeParams);\n}\nfunction renderLiteral(expr) {\n\tif (typeof expr.value === \"string\") return `'${escapeLiteral(expr.value)}'`;\n\tif (typeof expr.value === \"number\" || typeof expr.value === \"boolean\") return String(expr.value);\n\tif (typeof expr.value === \"bigint\") return String(expr.value);\n\tif (expr.value === null) return \"NULL\";\n\tif (expr.value === void 0) return \"NULL\";\n\tif (expr.value instanceof Date) return `'${escapeLiteral(expr.value.toISOString())}'`;\n\tif (Array.isArray(expr.value)) return `ARRAY[${expr.value.map((v) => renderLiteral(new LiteralExpr(v))).join(\", \")}]`;\n\tconst json = JSON.stringify(expr.value);\n\tif (json === void 0) return \"NULL\";\n\treturn `'${escapeLiteral(json)}'`;\n}\nfunction renderOperation(expr, contract, pim) {\n\tconst self = renderExpr(expr.self, contract, pim);\n\tconst args = expr.args.map((arg) => {\n\t\treturn renderExpr(arg, contract, pim);\n\t});\n\treturn expr.lowering.template.replace(/\\{\\{self\\}\\}|\\{\\{arg(\\d+)\\}\\}/g, (token, argIndex) => {\n\t\tif (token === \"{{self}}\") return self;\n\t\tconst arg = args[Number(argIndex)];\n\t\tif (arg === void 0) throw adapterError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `Operation lowering template for \"${expr.method}\" referenced missing argument {{arg${argIndex}}}; template has ${args.length} arg(s)`, { meta: { method: expr.method } });\n\t\treturn arg;\n\t});\n}\nfunction renderJoin(join, contract, pim) {\n\treturn `${join.joinType.toUpperCase()} JOIN ${join.lateral ? \"LATERAL \" : \"\"}${renderSource(join.source, contract, pim)} ON ${renderJoinOn(join.on, contract, pim)}`;\n}\nfunction renderJoinOn(on, contract, pim) {\n\tif (on.kind === \"eq-col-join-on\") return `${renderColumn(on.left)} = ${renderColumn(on.right)}`;\n\treturn renderWhere(on, contract, pim);\n}\nfunction getInsertColumnOrder(rows, contract, tableRef) {\n\tconst tableName = tableRef.name;\n\tconst orderedColumns = [];\n\tconst seenColumns = /* @__PURE__ */ new Set();\n\tfor (const row of rows) for (const column of Object.keys(row)) {\n\t\tif (seenColumns.has(column)) continue;\n\t\tseenColumns.add(column);\n\t\torderedColumns.push(column);\n\t}\n\tif (orderedColumns.length > 0) return orderedColumns;\n\tlet table;\n\tif (tableRef.namespaceId !== void 0) {\n\t\tconst ns = contract.storage.namespaces[tableRef.namespaceId];\n\t\ttable = ns !== void 0 ? ns.entries.table?.[tableName] : void 0;\n\t}\n\tif (table === void 0) for (const ns of Object.values(contract.storage.namespaces)) {\n\t\tconst found = ns.entries.table?.[tableName];\n\t\tif (found !== void 0) {\n\t\t\ttable = found;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (!table) throw adapterError(\"RUNTIME.AST_INVALID\", `INSERT target table not found in contract storage: ${tableName}`, { meta: {\n\t\tnode: \"insert\",\n\t\ttable: tableName\n\t} });\n\treturn Object.keys(table.columns);\n}\nfunction renderInsertValue(value, contract, pim) {\n\tif (!value || value.kind === \"default-value\") return \"DEFAULT\";\n\tswitch (value.kind) {\n\t\tcase \"param-ref\":\n\t\tcase \"prepared-param-ref\": return renderParamRef(value, pim);\n\t\tcase \"column-ref\": return renderColumn(value);\n\t\tcase \"raw-expr\": return renderExpr(value, contract, pim);\n\t\t// v8 ignore next 4\n\t\tdefault: assertNever(value, `Unsupported value node in INSERT: ${unreachableKind(value)}`);\n\t}\n}\nfunction renderInsert(ast, contract, pim) {\n\tconst table = renderTableSource(ast.table, contract);\n\tconst rows = ast.rows;\n\tif (rows.length === 0) throw adapterError(\"RUNTIME.AST_INVALID\", \"INSERT requires at least one row\", { meta: { node: \"insert\" } });\n\tconst hasExplicitValues = rows.some((row) => Object.keys(row).length > 0);\n\treturn `${(() => {\n\t\tif (!hasExplicitValues) {\n\t\t\tif (rows.length === 1) return `INSERT INTO ${table} DEFAULT VALUES`;\n\t\t\tconst defaultColumns = getInsertColumnOrder(rows, contract, ast.table);\n\t\t\tif (defaultColumns.length === 0) return `INSERT INTO ${table} VALUES ${rows.map(() => \"()\").join(\", \")}`;\n\t\t\tconst quotedColumns = defaultColumns.map((column) => quoteIdentifier(column));\n\t\t\tconst defaultRow = `(${defaultColumns.map(() => \"DEFAULT\").join(\", \")})`;\n\t\t\treturn `INSERT INTO ${table} (${quotedColumns.join(\", \")}) VALUES ${rows.map(() => defaultRow).join(\", \")}`;\n\t\t}\n\t\tconst columnOrder = getInsertColumnOrder(rows, contract, ast.table);\n\t\tconst columns = columnOrder.map((column) => quoteIdentifier(column));\n\t\tconst values = rows.map((row) => {\n\t\t\treturn `(${columnOrder.map((column) => renderInsertValue(row[column], contract, pim)).join(\", \")})`;\n\t\t}).join(\", \");\n\t\treturn `INSERT INTO ${table} (${columns.join(\", \")}) VALUES ${values}`;\n\t})()}${ast.onConflict ? (() => {\n\t\tconst conflictColumns = ast.onConflict.columns.map((col) => quoteIdentifier(col.column));\n\t\tconst target = conflictColumns.length === 0 ? \"\" : ` (${conflictColumns.join(\", \")})`;\n\t\tconst action = ast.onConflict.action;\n\t\tswitch (action.kind) {\n\t\t\tcase \"do-nothing\": return ` ON CONFLICT${target} DO NOTHING`;\n\t\t\tcase \"do-update-set\": {\n\t\t\t\tif (conflictColumns.length === 0) throw adapterError(\"RUNTIME.AST_INVALID\", \"INSERT onConflict requires at least one conflict column\", { meta: { node: \"insert-on-conflict\" } });\n\t\t\t\tconst updateEntries = Object.entries(action.set);\n\t\t\t\tif (updateEntries.length === 0) throw adapterError(\"RUNTIME.AST_INVALID\", \"INSERT onConflict do-update-set requires at least one assignment\", { meta: { node: \"insert-on-conflict\" } });\n\t\t\t\treturn ` ON CONFLICT${target} DO UPDATE SET ${updateEntries.map(([colName, value]) => {\n\t\t\t\t\treturn `${quoteIdentifier(colName)} = ${renderExpr(value, contract, pim)}`;\n\t\t\t\t}).join(\", \")}`;\n\t\t\t}\n\t\t\t// v8 ignore next 4\n\t\t\tdefault: assertNever(action, `Unsupported onConflict action: ${unreachableKind(action)}`);\n\t\t}\n\t})() : \"\"}${ast.returning?.length ? ` RETURNING ${renderReturning(ast.returning, contract, pim)}` : \"\"}`;\n}\nfunction renderUpdate(ast, contract, pim) {\n\tconst table = renderTableSource(ast.table, contract);\n\tconst setEntries = Object.entries(ast.set);\n\tif (setEntries.length === 0) throw adapterError(\"RUNTIME.AST_INVALID\", \"UPDATE requires at least one SET assignment\", { meta: { node: \"update\" } });\n\tconst setClauses = setEntries.map(([col, val]) => {\n\t\treturn `${quoteIdentifier(col)} = ${renderExpr(val, contract, pim)}`;\n\t});\n\tconst whereClause = ast.where ? ` WHERE ${renderWhere(ast.where, contract, pim)}` : \"\";\n\tconst returningClause = ast.returning?.length ? ` RETURNING ${renderReturning(ast.returning, contract, pim)}` : \"\";\n\treturn `UPDATE ${table} SET ${setClauses.join(\", \")}${whereClause}${returningClause}`;\n}\nfunction renderDelete(ast, contract, pim) {\n\treturn `DELETE FROM ${renderTableSource(ast.table, contract)}${ast.where ? ` WHERE ${renderWhere(ast.where, contract, pim)}` : \"\"}${ast.returning?.length ? ` RETURNING ${renderReturning(ast.returning, contract, pim)}` : \"\"}`;\n}\nfunction renderParts(parts, contract, pim) {\n\treturn parts.map((part) => {\n\t\tif (typeof part === \"string\") return part;\n\t\tswitch (part.kind) {\n\t\t\tcase \"select\": return renderSelect(part, contract, pim);\n\t\t\tcase \"insert\": return renderInsert(part, contract, pim);\n\t\t\tcase \"update\": return renderUpdate(part, contract, pim);\n\t\t\tcase \"delete\": return renderDelete(part, contract, pim);\n\t\t\tdefault: return renderExpr(part, contract, pim);\n\t\t}\n\t}).join(\"\");\n}\nfunction renderRawExpr(node, contract, pim) {\n\treturn renderParts(node.parts, contract, pim);\n}\n//#endregion\nexport { adapterError as n, renderLoweredSql as t };\n\n//# sourceMappingURL=sql-renderer-D6fBWtjL.mjs.map"],"mappings":";;;;;;;;;;;AAWA,SAAS,aAAa,MAAM,SAAS,SAAS;CAC7C,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC9C;;;;;;AAQA,MAAM,iDAAiD,IAAI,IAAI;CAC9D,OAAO;CACP,OAAO;CACP,OAAO;CACP,SAAS;CACT,SAAS;CACT,UAAU;CACV,OAAO;CACP,OAAO;CACP,OAAO;CACP,UAAU;CACV,YAAY;CACZ,cAAc;CACd,OAAO;CACP,SAAS;CACT,WAAW;CACX,MAAM;CACN,SAAS;AACV,CAAC;;;;AAID,MAAM,6CAA6C,IAAI,IAAI,CAAC,CAAC,QAAQ,IAAI,YAAY,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;;AAOrG,SAAS,iBAAiB,OAAO,SAAS,OAAO,MAAM,YAAY,YAAY,OAAO;CACrF,IAAI,YAAY,KAAK,GAAG,OAAO,IAAI;CACnC,IAAI,MAAM,wBAAwB,cAAc,OAAO,MAAM,KAAK,GAAG,MAAM,aAAa,mCAAmC,gDAAgD,QAAQ,2TAA2T,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;CACngB,MAAM,WAAW,mBAAmB,SAAS;EAC5C,aAAa,MAAM;EACnB,gBAAgB,MAAM;CACvB,CAAC;CACD,IAAI,kBAAkB,QAAQ,GAAG,OAAO,IAAI;CAC5C,MAAM,cAAc,OAAO,OAAO;CAClC,IAAI,aAAa,CAAC,+BAA+B,IAAI,SAAS,EAAE,KAAK,MAAM;EAC1E,MAAM,WAAW,YAAY,UAAU,eAAe,UAAU,cAAc,UAAU,IAAI,aAAa,KAAK,CAAC,CAAC;EAChH,MAAM,SAAS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GAAG;GACtD,KAAK,UAAU,OAAO,aAAa,MAAM,UAAU,GAAG;GACtD,SAAS,OAAO,WAAW,MAAM,UAAU,GAAG;EAC/C;CACD,CAAC,CAAC,CAAC,KAAK,EAAE;AACX;AACA,SAAS,cAAc,MAAM,UAAU,KAAK;CAC3C,OAAO,YAAY,KAAK,OAAO,UAAU,GAAG;AAC7C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"target__runtime.mjs","names":[],"sources":["../../../../3-targets/postgres/1-target/dist/runtime.mjs"],"sourcesContent":["import { I as PG_TSQUERY_CODEC_ID, T as PG_TEXT_CODEC_ID, c as PG_FLOAT4_CODEC_ID, n as PG_BOOL_CODEC_ID } from \"./codec-ids-2htdtS66.mjs\";\nimport { u as postgresError } from \"./errors-C4-Dp3gI.mjs\";\nimport { A as decodePostgresListText } from \"./codecs-Bzj3M0Q3.mjs\";\nimport { a as fullTextIndexOptions, t as FULL_TEXT_INDEX_TYPE } from \"./full-text-index-definition-DzRCaPjb.mjs\";\nimport { a as postgresNowGenerators, o as postgresTargetDescriptorMetaRuntime } from \"./date-time-now-generators-BORO1_nc.mjs\";\nimport { t as renderFullTextDocument } from \"./full-text-search-document-BqqvjJoC.mjs\";\nimport { n as PostgresContractSerializer, t as PostgresContractView } from \"./postgres-contract-view-WtPiaMZp.mjs\";\nimport { a as headlineOptionsLiteral, c as FullTextDocument, i as websearchToTsquery, n as plaintoTsquery, o as languageLiteral, r as toTsquery, s as normalizationLiteral, t as phrasetoTsquery } from \"./full-text-parsers-D-2uupNS.mjs\";\nimport { type } from \"arktype\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { buildOperation, isExpression, toExpr } from \"@internal/sql-relational-core/expression\";\nimport { uniqueIndexNamesOfType } from \"@internal/sql-relational-core/index-reference\";\n//#region src/core/full-text-collection-method.ts\nfunction indexFunction(tools, name) {\n\treturn blindCast(tools.fns[name]);\n}\nfunction fullTextMethod(indexName) {\n\treturn (collection, ...args) => collection.where((_model, tools) => indexFunction(tools, \"fullTextMatches\")(tools.indexes[indexName], ...args)).orderBy((_model, tools) => indexFunction(tools, \"fullTextRank\")(tools.indexes[indexName], ...args).desc());\n}\n/** The run-time half of `PostgresFullTextMethods`. */\nconst postgresFullTextMethods = {\n\tid: \"postgres/fullText\",\n\tmethodsFor: (model) => Object.fromEntries(uniqueIndexNamesOfType(model.table.indexes, FULL_TEXT_INDEX_TYPE).map((name) => [name, fullTextMethod(name)]))\n};\n//#endregion\n//#region src/core/query-operations.ts\nconst TEXT_REF = { codecId: PG_TEXT_CODEC_ID };\nconst TSQUERY_REF = { codecId: PG_TSQUERY_CODEC_ID };\nconst languageOf = (options) => options.language ?? \"english\";\nfunction isIndexReference(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value) && !isExpression(value) && \"type\" in value && \"options\" in value && \"columns\" in value;\n}\nfunction invalidDocument(method, argument, received, message, fix) {\n\treturn postgresError(\"RUNTIME.ARGUMENT_INVALID\", `${method}: ${message}`, {\n\t\twhy: \"Postgres uses a full-text index only for a query over the same search document, so the document comes from the index itself, from one column, or from `fullTextDocument`.\",\n\t\tfix,\n\t\tmeta: {\n\t\t\thelper: method,\n\t\t\targument,\n\t\t\treceived\n\t\t}\n\t});\n}\n/**\n* The weight groups and the language a search document stands for. A full-text index states both;\n* a column and a `fullTextDocument` take the language from the options.\n*/\nfunction documentGroups(method, document, options) {\n\tif (document instanceof FullTextDocument) return {\n\t\tweightGroups: document.weightGroups,\n\t\tlanguage: languageOf(options)\n\t};\n\tif (isExpression(document)) return {\n\t\tweightGroups: [[document]],\n\t\tlanguage: languageOf(options)\n\t};\n\tif (!isIndexReference(document)) throw invalidDocument(method, \"document\", Array.isArray(document) ? \"array\" : typeof document, \"the document must be a full-text index from a table's `indexes`, a column, or a document from `fullTextDocument`.\", \"Pass the index, as `table.indexes.<name>`, or wrap the weight groups in `fullTextDocument(...)`.\");\n\tif (document.type !== \"fullText\") throw invalidDocument(method, \"document\", document.type, `the index is of type \"${String(document.type)}\", not a full-text index.`, \"Pass an index declared with `@@fullTextIndex` or `fullTextIndex`.\");\n\tif (options.language !== void 0) throw invalidDocument(method, \"options\", options.language, \"a full-text index states its language, so the `language` option is not taken with one.\", \"Leave `language` out; the index decides it.\");\n\tconst definition = fullTextIndexOptions(document.options ?? {});\n\tif (definition instanceof type.errors) throw invalidDocument(method, \"document\", document.options, `the full-text index has invalid options: ${definition.summary}`, \"Pass the index as the table gives it.\");\n\tconst columns = document.columns;\n\tconst columnOf = (name) => {\n\t\tconst column = typeof columns === \"object\" && columns !== null && Object.hasOwn(columns, name) ? Reflect.get(columns, name) : void 0;\n\t\tif (!isExpression(column)) throw invalidDocument(method, \"document\", name, `the full-text index has no column \"${name}\", which its weight groups name.`, \"Pass the index as the table gives it.\");\n\t\treturn column;\n\t};\n\treturn {\n\t\tweightGroups: definition.weightGroups.map((group) => group.map(columnOf)),\n\t\tlanguage: definition.language\n\t};\n}\n/**\n* The search document an operation searches. The first column is the operation's `self`; the\n* others follow the `fixedArgs` the operation passes first, so the query, the language and any\n* further option keep their positions.\n*/\nfunction searchDocument(method, document, options, fixedArgs) {\n\tconst { weightGroups, language } = documentGroups(method, document, options);\n\tlet position = 0;\n\tconst template = renderFullTextDocument(weightGroups.map((group) => group.map(() => position++)), {\n\t\tcolumn: (index) => index === 0 ? \"{{self}}\" : `{{arg${fixedArgs + index - 1}}}`,\n\t\tlanguage: \"{{arg1}}\"\n\t});\n\tconst [self, ...rest] = weightGroups.flat().map((column) => toExpr(column));\n\tassertDefined(self, `${method}: a checked document has a first column`);\n\treturn {\n\t\tself,\n\t\trest,\n\t\ttemplate,\n\t\tlanguage: languageLiteral(method, language)\n\t};\n}\nfunction postgresQueryOperations() {\n\treturn {\n\t\tilike: {\n\t\t\tself: { traits: [\"textual\"] },\n\t\t\timpl: (self, pattern) => buildOperation({\n\t\t\t\tmethod: \"ilike\",\n\t\t\t\targs: [toExpr(self), toExpr(pattern, TEXT_REF)],\n\t\t\t\treturns: {\n\t\t\t\t\tcodecId: PG_BOOL_CODEC_ID,\n\t\t\t\t\tnullable: false\n\t\t\t\t},\n\t\t\t\tlowering: {\n\t\t\t\t\ttargetFamily: \"sql\",\n\t\t\t\t\ttemplate: \"{{self}} ILIKE {{arg0}}\"\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t\tfullTextMatches: {\n\t\t\tself: { traits: [\"textual\"] },\n\t\t\timpl: (document, query, options = {}) => {\n\t\t\t\tconst searched = searchDocument(\"fullTextMatches\", document, options, 2);\n\t\t\t\treturn buildOperation({\n\t\t\t\t\tmethod: \"fullTextMatches\",\n\t\t\t\t\targs: [\n\t\t\t\t\t\tsearched.self,\n\t\t\t\t\t\ttoExpr(query, TSQUERY_REF),\n\t\t\t\t\t\tsearched.language,\n\t\t\t\t\t\t...searched.rest\n\t\t\t\t\t],\n\t\t\t\t\treturns: {\n\t\t\t\t\t\tcodecId: PG_BOOL_CODEC_ID,\n\t\t\t\t\t\tnullable: false\n\t\t\t\t\t},\n\t\t\t\t\tlowering: {\n\t\t\t\t\t\ttargetFamily: \"sql\",\n\t\t\t\t\t\ttemplate: `${searched.template} @@ {{arg0}}`\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tfullTextRank: {\n\t\t\tself: { traits: [\"textual\"] },\n\t\t\timpl: (document, query, options = {}) => {\n\t\t\t\tconst fn = options.coverDensity === true ? \"ts_rank_cd\" : \"ts_rank\";\n\t\t\t\tconst normalization = options.normalization === void 0 ? void 0 : normalizationLiteral(\"fullTextRank\", options.normalization);\n\t\t\t\tconst searched = searchDocument(\"fullTextRank\", document, options, normalization === void 0 ? 2 : 3);\n\t\t\t\tconst fixed = normalization === void 0 ? [searched.language] : [searched.language, normalization];\n\t\t\t\treturn buildOperation({\n\t\t\t\t\tmethod: \"fullTextRank\",\n\t\t\t\t\targs: [\n\t\t\t\t\t\tsearched.self,\n\t\t\t\t\t\ttoExpr(query, TSQUERY_REF),\n\t\t\t\t\t\t...fixed,\n\t\t\t\t\t\t...searched.rest\n\t\t\t\t\t],\n\t\t\t\t\treturns: {\n\t\t\t\t\t\tcodecId: PG_FLOAT4_CODEC_ID,\n\t\t\t\t\t\tnullable: false\n\t\t\t\t\t},\n\t\t\t\t\tlowering: {\n\t\t\t\t\t\ttargetFamily: \"sql\",\n\t\t\t\t\t\ttemplate: `${fn}(${searched.template}, {{arg0}}${normalization === void 0 ? \"\" : \", {{arg2}}\"})`\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tfullTextHeadline: {\n\t\t\tself: { traits: [\"textual\"] },\n\t\t\timpl: (self, query, options = {}) => {\n\t\t\t\tconst headlineOptions = headlineOptionsLiteral(\"fullTextHeadline\", options);\n\t\t\t\tconst base = \"ts_headline({{arg1}}, {{self}}, {{arg0}}\";\n\t\t\t\treturn buildOperation({\n\t\t\t\t\tmethod: \"fullTextHeadline\",\n\t\t\t\t\targs: [\n\t\t\t\t\t\ttoExpr(self),\n\t\t\t\t\t\ttoExpr(query, TSQUERY_REF),\n\t\t\t\t\t\tlanguageLiteral(\"fullTextHeadline\", languageOf(options)),\n\t\t\t\t\t\t...headlineOptions === void 0 ? [] : [headlineOptions]\n\t\t\t\t\t],\n\t\t\t\t\treturns: {\n\t\t\t\t\t\tcodecId: PG_TEXT_CODEC_ID,\n\t\t\t\t\t\tnullable: false\n\t\t\t\t\t},\n\t\t\t\t\tlowering: {\n\t\t\t\t\t\ttargetFamily: \"sql\",\n\t\t\t\t\t\ttemplate: `${base}${headlineOptions === void 0 ? \"\" : \", {{arg2}}\"})`\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\twebsearchToTsquery: { impl: websearchToTsquery },\n\t\ttoTsquery: { impl: toTsquery },\n\t\tplaintoTsquery: { impl: plaintoTsquery },\n\t\tphrasetoTsquery: { impl: phrasetoTsquery }\n\t};\n}\n//#endregion\n//#region src/exports/runtime.ts\n/**\n* Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@internal/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that\n* `@internal/sql-runtime` consumers narrow to at composition time.\n*\n* The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).\n*/\nconst postgresRuntimeTargetDescriptor = {\n\t...postgresTargetDescriptorMetaRuntime,\n\tcodecs: () => [],\n\tlistDecoder: () => decodePostgresListText,\n\tqueryOperations: () => postgresQueryOperations(),\n\tcollectionMethods: () => [postgresFullTextMethods],\n\tcreate() {\n\t\treturn {\n\t\t\tfamilyId: \"sql\",\n\t\t\ttargetId: \"postgres\"\n\t\t};\n\t}\n};\n//#endregion\nexport { PostgresContractSerializer, PostgresContractView, decodePostgresListText, postgresRuntimeTargetDescriptor as default, postgresNowGenerators };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,cAAc,OAAO,MAAM;CACnC,OAAO,UAAU,MAAM,IAAI,KAAK;AACjC;AACA,SAAS,eAAe,WAAW;CAClC,QAAQ,YAAY,GAAG,SAAS,WAAW,OAAO,QAAQ,UAAU,cAAc,OAAO,iBAAiB,CAAC,CAAC,MAAM,QAAQ,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,QAAQ,UAAU,cAAc,OAAO,cAAc,CAAC,CAAC,MAAM,QAAQ,YAAY,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC;AAC1P;;AAEA,MAAM,0BAA0B;CAC/B,IAAI;CACJ,aAAa,UAAU,OAAO,YAAY,uBAAuB,MAAM,MAAM,SAAS,oBAAoB,CAAC,CAAC,KAAK,SAAS,CAAC,MAAM,eAAe,IAAI,CAAC,CAAC,CAAC;AACxJ;AAGA,MAAM,WAAW,EAAE,SAAS,iBAAiB;AAC7C,M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