@prisma/orm-extension-postgis 0.16.0-dev.36
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.
- package/LICENSE +201 -0
- package/README.md +32 -0
- package/dist/codec-types-M7J4vkfS-DOzWmEmw.d.mts +49 -0
- package/dist/codec-types-M7J4vkfS-DOzWmEmw.d.mts.map +1 -0
- package/dist/codec-types.d.mts +2 -0
- package/dist/codec-types.mjs +1 -0
- package/dist/column-types.d.mts +27 -0
- package/dist/column-types.d.mts.map +1 -0
- package/dist/column-types.mjs +34 -0
- package/dist/column-types.mjs.map +1 -0
- package/dist/constants-CWW72xGt-hJye3Dua.mjs +6 -0
- package/dist/constants-CWW72xGt-hJye3Dua.mjs.map +1 -0
- package/dist/control.d.mts +7 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +143 -0
- package/dist/control.mjs.map +1 -0
- package/dist/descriptor-meta-deM0Qc_b-FRxKhllA.mjs +604 -0
- package/dist/descriptor-meta-deM0Qc_b-FRxKhllA.mjs.map +1 -0
- package/dist/errors-Bg6kDFR--BUzKMn1A.mjs +9 -0
- package/dist/errors-Bg6kDFR--BUzKMn1A.mjs.map +1 -0
- package/dist/geojson-L3qRlIZY-DLhY3CUa.d.mts +62 -0
- package/dist/geojson-L3qRlIZY-DLhY3CUa.d.mts.map +1 -0
- package/dist/geojson.d.mts +2 -0
- package/dist/geojson.mjs +89 -0
- package/dist/geojson.mjs.map +1 -0
- package/dist/operation-types-_DWme6Gj-DddnbZus.d.mts +123 -0
- package/dist/operation-types-_DWme6Gj-DddnbZus.d.mts.map +1 -0
- package/dist/operation-types.d.mts +2 -0
- package/dist/operation-types.mjs +1 -0
- package/dist/pack.d.mts +75 -0
- package/dist/pack.d.mts.map +1 -0
- package/dist/pack.mjs +2 -0
- package/dist/runtime.d.mts +19 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +22 -0
- package/dist/runtime.mjs.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
import { t as POSTGIS_GEOMETRY_CODEC_ID } from "./constants-CWW72xGt-hJye3Dua.mjs";
|
|
2
|
+
import { t as postgisError } from "./errors-Bg6kDFR--BUzKMn1A.mjs";
|
|
3
|
+
import { buildOperation, codecOf, toExpr } from "@prisma/orm-family-sql/relational-core/expression";
|
|
4
|
+
import { buildCodecDescriptorRegistry } from "@prisma/orm-family-sql/relational-core/codec-descriptor-registry";
|
|
5
|
+
import { CodecImpl } from "@prisma/orm-framework/components/codec";
|
|
6
|
+
import { PostgresCodecDescriptor, definePostgresCodecs } from "@prisma/orm-target-postgres/target/codec-descriptor";
|
|
7
|
+
import { type } from "arktype";
|
|
8
|
+
//#region ../../../3-extensions/postgis/dist/descriptor-meta-deM0Qc_b.mjs
|
|
9
|
+
const postgisAuthoringTypes = { postgis: { Geometry: {
|
|
10
|
+
kind: "typeConstructor",
|
|
11
|
+
args: [{
|
|
12
|
+
kind: "number",
|
|
13
|
+
name: "srid",
|
|
14
|
+
integer: true,
|
|
15
|
+
minimum: 0
|
|
16
|
+
}],
|
|
17
|
+
output: {
|
|
18
|
+
codecId: POSTGIS_GEOMETRY_CODEC_ID,
|
|
19
|
+
nativeType: "geometry",
|
|
20
|
+
typeParams: { srid: {
|
|
21
|
+
kind: "arg",
|
|
22
|
+
index: 0
|
|
23
|
+
} }
|
|
24
|
+
}
|
|
25
|
+
} } };
|
|
26
|
+
/**
|
|
27
|
+
* Minimal EWKB (Extended Well-Known Binary) reader for the PostGIS codec.
|
|
28
|
+
*
|
|
29
|
+
* `node-postgres` returns geometry columns as hex-encoded EWKB strings by
|
|
30
|
+
* default. This reader parses the subset we ship with the extension —
|
|
31
|
+
* Point, LineString, Polygon, and the Multi* counterparts — into GeoJSON
|
|
32
|
+
* objects. Z and M coordinates are not supported; if a wire value carries
|
|
33
|
+
* them, decoding throws so the caller can detect the mismatch instead of
|
|
34
|
+
* silently dropping data.
|
|
35
|
+
*/
|
|
36
|
+
const FLAG_Z = 2147483648;
|
|
37
|
+
const FLAG_M = 1073741824;
|
|
38
|
+
const FLAG_SRID = 536870912;
|
|
39
|
+
const TYPE_MASK = 536870911;
|
|
40
|
+
const TYPE_POINT = 1;
|
|
41
|
+
const TYPE_LINESTRING = 2;
|
|
42
|
+
const TYPE_POLYGON = 3;
|
|
43
|
+
const TYPE_MULTIPOINT = 4;
|
|
44
|
+
const TYPE_MULTILINESTRING = 5;
|
|
45
|
+
const TYPE_MULTIPOLYGON = 6;
|
|
46
|
+
const HEX_PAIR_RE = /^[0-9a-fA-F]{2}$/;
|
|
47
|
+
function hexToBytes(hex) {
|
|
48
|
+
if (hex.length % 2 !== 0) throw postgisError("RUNTIME.DECODE_FAILED", "Geometry wire value: odd-length hex string", { meta: { wirePreview: hex.slice(0, 32) } });
|
|
49
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
50
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
51
|
+
const pair = hex.slice(i * 2, i * 2 + 2);
|
|
52
|
+
if (!HEX_PAIR_RE.test(pair)) throw postgisError("RUNTIME.DECODE_FAILED", `Geometry wire value: invalid hex byte at offset ${i * 2}`, { meta: { wirePreview: hex.slice(0, 32) } });
|
|
53
|
+
bytes[i] = Number.parseInt(pair, 16);
|
|
54
|
+
}
|
|
55
|
+
return bytes;
|
|
56
|
+
}
|
|
57
|
+
var Reader = class {
|
|
58
|
+
offset = 0;
|
|
59
|
+
view;
|
|
60
|
+
constructor(bytes) {
|
|
61
|
+
this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
62
|
+
}
|
|
63
|
+
requireBytes(needed) {
|
|
64
|
+
if (this.offset + needed > this.view.byteLength) throw postgisError("RUNTIME.DECODE_FAILED", `Geometry wire value: unexpected end of buffer (need ${needed} bytes at offset ${this.offset}, ${this.view.byteLength - this.offset} available)`);
|
|
65
|
+
}
|
|
66
|
+
readUint8() {
|
|
67
|
+
this.requireBytes(1);
|
|
68
|
+
const v = this.view.getUint8(this.offset);
|
|
69
|
+
this.offset += 1;
|
|
70
|
+
return v;
|
|
71
|
+
}
|
|
72
|
+
readUint32(littleEndian) {
|
|
73
|
+
this.requireBytes(4);
|
|
74
|
+
const v = this.view.getUint32(this.offset, littleEndian);
|
|
75
|
+
this.offset += 4;
|
|
76
|
+
return v >>> 0;
|
|
77
|
+
}
|
|
78
|
+
readFloat64(littleEndian) {
|
|
79
|
+
this.requireBytes(8);
|
|
80
|
+
const v = this.view.getFloat64(this.offset, littleEndian);
|
|
81
|
+
this.offset += 8;
|
|
82
|
+
return v;
|
|
83
|
+
}
|
|
84
|
+
hasRemaining() {
|
|
85
|
+
return this.offset !== this.view.byteLength;
|
|
86
|
+
}
|
|
87
|
+
remainingBytes() {
|
|
88
|
+
return this.view.byteLength - this.offset;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
var Writer = class {
|
|
92
|
+
bytes = [];
|
|
93
|
+
writeUint8(value) {
|
|
94
|
+
this.bytes.push(value);
|
|
95
|
+
}
|
|
96
|
+
writeUint32(value) {
|
|
97
|
+
const buffer = /* @__PURE__ */ new ArrayBuffer(4);
|
|
98
|
+
new DataView(buffer).setUint32(0, value, true);
|
|
99
|
+
this.bytes.push(...new Uint8Array(buffer));
|
|
100
|
+
}
|
|
101
|
+
writeFloat64(value) {
|
|
102
|
+
const buffer = /* @__PURE__ */ new ArrayBuffer(8);
|
|
103
|
+
new DataView(buffer).setFloat64(0, value, true);
|
|
104
|
+
this.bytes.push(...new Uint8Array(buffer));
|
|
105
|
+
}
|
|
106
|
+
toHex() {
|
|
107
|
+
return this.bytes.map((byte) => byte.toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
function readHeader(reader) {
|
|
111
|
+
const byteOrder = reader.readUint8();
|
|
112
|
+
if (byteOrder !== 0 && byteOrder !== 1) throw postgisError("RUNTIME.DECODE_FAILED", `Geometry wire value: invalid byte order ${byteOrder}`);
|
|
113
|
+
const littleEndian = byteOrder === 1;
|
|
114
|
+
const typeCode = reader.readUint32(littleEndian);
|
|
115
|
+
if ((typeCode & FLAG_Z) !== 0 || (typeCode & FLAG_M) !== 0) throw postgisError("RUNTIME.DECODE_FAILED", "Geometry wire value: Z/M coordinates are not supported");
|
|
116
|
+
const geomType = typeCode & TYPE_MASK;
|
|
117
|
+
if ((typeCode & FLAG_SRID) !== 0) return {
|
|
118
|
+
geomType,
|
|
119
|
+
littleEndian,
|
|
120
|
+
srid: reader.readUint32(littleEndian)
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
geomType,
|
|
124
|
+
littleEndian
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function readPosition(reader, littleEndian) {
|
|
128
|
+
return [reader.readFloat64(littleEndian), reader.readFloat64(littleEndian)];
|
|
129
|
+
}
|
|
130
|
+
function readPoint(reader, header) {
|
|
131
|
+
const coords = readPosition(reader, header.littleEndian);
|
|
132
|
+
return header.srid !== void 0 ? {
|
|
133
|
+
type: "Point",
|
|
134
|
+
coordinates: coords,
|
|
135
|
+
srid: header.srid
|
|
136
|
+
} : {
|
|
137
|
+
type: "Point",
|
|
138
|
+
coordinates: coords
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function readLineString(reader, header) {
|
|
142
|
+
const n = reader.readUint32(header.littleEndian);
|
|
143
|
+
const coords = [];
|
|
144
|
+
for (let i = 0; i < n; i++) coords.push(readPosition(reader, header.littleEndian));
|
|
145
|
+
return header.srid !== void 0 ? {
|
|
146
|
+
type: "LineString",
|
|
147
|
+
coordinates: coords,
|
|
148
|
+
srid: header.srid
|
|
149
|
+
} : {
|
|
150
|
+
type: "LineString",
|
|
151
|
+
coordinates: coords
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function readPolygon(reader, header) {
|
|
155
|
+
const numRings = reader.readUint32(header.littleEndian);
|
|
156
|
+
const rings = [];
|
|
157
|
+
for (let r = 0; r < numRings; r++) {
|
|
158
|
+
const n = reader.readUint32(header.littleEndian);
|
|
159
|
+
const ring = [];
|
|
160
|
+
for (let i = 0; i < n; i++) ring.push(readPosition(reader, header.littleEndian));
|
|
161
|
+
rings.push(ring);
|
|
162
|
+
}
|
|
163
|
+
return header.srid !== void 0 ? {
|
|
164
|
+
type: "Polygon",
|
|
165
|
+
coordinates: rings,
|
|
166
|
+
srid: header.srid
|
|
167
|
+
} : {
|
|
168
|
+
type: "Polygon",
|
|
169
|
+
coordinates: rings
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function readSubGeometry(reader) {
|
|
173
|
+
const header = readHeader(reader);
|
|
174
|
+
switch (header.geomType) {
|
|
175
|
+
case TYPE_POINT: return readPoint(reader, header);
|
|
176
|
+
case TYPE_LINESTRING: return readLineString(reader, header);
|
|
177
|
+
case TYPE_POLYGON: return readPolygon(reader, header);
|
|
178
|
+
default: throw postgisError("RUNTIME.DECODE_FAILED", `Geometry wire value: unsupported sub-type ${header.geomType}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function readMultiPoint(reader, header) {
|
|
182
|
+
const n = reader.readUint32(header.littleEndian);
|
|
183
|
+
const coords = [];
|
|
184
|
+
for (let i = 0; i < n; i++) {
|
|
185
|
+
const sub = readSubGeometry(reader);
|
|
186
|
+
if (sub.type !== "Point") throw postgisError("RUNTIME.DECODE_FAILED", "Geometry wire value: MultiPoint contains non-Point sub-geometry");
|
|
187
|
+
coords.push(sub.coordinates);
|
|
188
|
+
}
|
|
189
|
+
return header.srid !== void 0 ? {
|
|
190
|
+
type: "MultiPoint",
|
|
191
|
+
coordinates: coords,
|
|
192
|
+
srid: header.srid
|
|
193
|
+
} : {
|
|
194
|
+
type: "MultiPoint",
|
|
195
|
+
coordinates: coords
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function readMultiLineString(reader, header) {
|
|
199
|
+
const n = reader.readUint32(header.littleEndian);
|
|
200
|
+
const lines = [];
|
|
201
|
+
for (let i = 0; i < n; i++) {
|
|
202
|
+
const sub = readSubGeometry(reader);
|
|
203
|
+
if (sub.type !== "LineString") throw postgisError("RUNTIME.DECODE_FAILED", "Geometry wire value: MultiLineString contains non-LineString sub-geometry");
|
|
204
|
+
lines.push(sub.coordinates);
|
|
205
|
+
}
|
|
206
|
+
return header.srid !== void 0 ? {
|
|
207
|
+
type: "MultiLineString",
|
|
208
|
+
coordinates: lines,
|
|
209
|
+
srid: header.srid
|
|
210
|
+
} : {
|
|
211
|
+
type: "MultiLineString",
|
|
212
|
+
coordinates: lines
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function readMultiPolygon(reader, header) {
|
|
216
|
+
const n = reader.readUint32(header.littleEndian);
|
|
217
|
+
const polys = [];
|
|
218
|
+
for (let i = 0; i < n; i++) {
|
|
219
|
+
const sub = readSubGeometry(reader);
|
|
220
|
+
if (sub.type !== "Polygon") throw postgisError("RUNTIME.DECODE_FAILED", "Geometry wire value: MultiPolygon contains non-Polygon sub-geometry");
|
|
221
|
+
polys.push(sub.coordinates);
|
|
222
|
+
}
|
|
223
|
+
return header.srid !== void 0 ? {
|
|
224
|
+
type: "MultiPolygon",
|
|
225
|
+
coordinates: polys,
|
|
226
|
+
srid: header.srid
|
|
227
|
+
} : {
|
|
228
|
+
type: "MultiPolygon",
|
|
229
|
+
coordinates: polys
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function decodeEWKBHex(hex) {
|
|
233
|
+
const reader = new Reader(hexToBytes(hex));
|
|
234
|
+
const geometry = readGeometryBody(reader, readHeader(reader));
|
|
235
|
+
if (reader.hasRemaining()) throw postgisError("RUNTIME.DECODE_FAILED", `Geometry wire value: trailing data after geometry (${reader.remainingBytes()} bytes)`, { meta: { wirePreview: hex.slice(0, 32) } });
|
|
236
|
+
return geometry;
|
|
237
|
+
}
|
|
238
|
+
function encodeEWKBHex(value) {
|
|
239
|
+
const writer = new Writer();
|
|
240
|
+
writeGeometry(writer, value);
|
|
241
|
+
return writer.toHex();
|
|
242
|
+
}
|
|
243
|
+
function writeHeader(writer, geomType, srid) {
|
|
244
|
+
writer.writeUint8(1);
|
|
245
|
+
writer.writeUint32(srid === void 0 ? geomType : geomType | FLAG_SRID);
|
|
246
|
+
if (srid !== void 0) writer.writeUint32(srid);
|
|
247
|
+
}
|
|
248
|
+
function writePosition(writer, position) {
|
|
249
|
+
if (!Number.isFinite(position[0]) || !Number.isFinite(position[1])) throw postgisError("RUNTIME.ENCODE_FAILED", "Geometry encode: coordinates must be finite numbers");
|
|
250
|
+
writer.writeFloat64(position[0]);
|
|
251
|
+
writer.writeFloat64(position[1]);
|
|
252
|
+
}
|
|
253
|
+
function writeLineStringBody(writer, positions) {
|
|
254
|
+
writer.writeUint32(positions.length);
|
|
255
|
+
for (const position of positions) writePosition(writer, position);
|
|
256
|
+
}
|
|
257
|
+
function writePolygonBody(writer, rings) {
|
|
258
|
+
writer.writeUint32(rings.length);
|
|
259
|
+
for (const ring of rings) writeLineStringBody(writer, ring);
|
|
260
|
+
}
|
|
261
|
+
function writeGeometry(writer, value) {
|
|
262
|
+
switch (value.type) {
|
|
263
|
+
case "Point":
|
|
264
|
+
writeHeader(writer, TYPE_POINT, value.srid);
|
|
265
|
+
writePosition(writer, value.coordinates);
|
|
266
|
+
break;
|
|
267
|
+
case "LineString":
|
|
268
|
+
writeHeader(writer, TYPE_LINESTRING, value.srid);
|
|
269
|
+
writeLineStringBody(writer, value.coordinates);
|
|
270
|
+
break;
|
|
271
|
+
case "Polygon":
|
|
272
|
+
writeHeader(writer, TYPE_POLYGON, value.srid);
|
|
273
|
+
writePolygonBody(writer, value.coordinates);
|
|
274
|
+
break;
|
|
275
|
+
case "MultiPoint":
|
|
276
|
+
writeHeader(writer, TYPE_MULTIPOINT, value.srid);
|
|
277
|
+
writer.writeUint32(value.coordinates.length);
|
|
278
|
+
for (const position of value.coordinates) {
|
|
279
|
+
writeHeader(writer, TYPE_POINT);
|
|
280
|
+
writePosition(writer, position);
|
|
281
|
+
}
|
|
282
|
+
break;
|
|
283
|
+
case "MultiLineString":
|
|
284
|
+
writeHeader(writer, TYPE_MULTILINESTRING, value.srid);
|
|
285
|
+
writer.writeUint32(value.coordinates.length);
|
|
286
|
+
for (const line of value.coordinates) {
|
|
287
|
+
writeHeader(writer, TYPE_LINESTRING);
|
|
288
|
+
writeLineStringBody(writer, line);
|
|
289
|
+
}
|
|
290
|
+
break;
|
|
291
|
+
case "MultiPolygon":
|
|
292
|
+
writeHeader(writer, TYPE_MULTIPOLYGON, value.srid);
|
|
293
|
+
writer.writeUint32(value.coordinates.length);
|
|
294
|
+
for (const polygon of value.coordinates) {
|
|
295
|
+
writeHeader(writer, TYPE_POLYGON);
|
|
296
|
+
writePolygonBody(writer, polygon);
|
|
297
|
+
}
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function readGeometryBody(reader, header) {
|
|
302
|
+
switch (header.geomType) {
|
|
303
|
+
case TYPE_POINT: return readPoint(reader, header);
|
|
304
|
+
case TYPE_LINESTRING: return readLineString(reader, header);
|
|
305
|
+
case TYPE_POLYGON: return readPolygon(reader, header);
|
|
306
|
+
case TYPE_MULTIPOINT: return readMultiPoint(reader, header);
|
|
307
|
+
case TYPE_MULTILINESTRING: return readMultiLineString(reader, header);
|
|
308
|
+
case TYPE_MULTIPOLYGON: return readMultiPolygon(reader, header);
|
|
309
|
+
default: throw postgisError("RUNTIME.DECODE_FAILED", `Geometry wire value: unsupported geometry type ${header.geomType}`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Encode a GeoJSON-shaped geometry to an EWKT string PostGIS understands
|
|
314
|
+
* via `'<ewkt>'::geometry`. We use EWKT (not EWKB) on the way in so the
|
|
315
|
+
* generated SQL stays human-readable.
|
|
316
|
+
*/
|
|
317
|
+
function encodeEWKT(value) {
|
|
318
|
+
const sridPrefix = value.srid !== void 0 ? `SRID=${value.srid};` : "";
|
|
319
|
+
switch (value.type) {
|
|
320
|
+
case "Point": return `${sridPrefix}POINT(${formatPosition(value.coordinates)})`;
|
|
321
|
+
case "LineString": return `${sridPrefix}LINESTRING(${value.coordinates.map(formatPosition).join(",")})`;
|
|
322
|
+
case "Polygon": return `${sridPrefix}POLYGON(${formatRings(value.coordinates)})`;
|
|
323
|
+
case "MultiPoint": return `${sridPrefix}MULTIPOINT(${value.coordinates.map(formatPosition).join(",")})`;
|
|
324
|
+
case "MultiLineString": return `${sridPrefix}MULTILINESTRING(${value.coordinates.map((line) => `(${line.map(formatPosition).join(",")})`).join(",")})`;
|
|
325
|
+
case "MultiPolygon": return `${sridPrefix}MULTIPOLYGON(${value.coordinates.map((poly) => `(${formatRings(poly)})`).join(",")})`;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function formatPosition(p) {
|
|
329
|
+
if (!Number.isFinite(p[0]) || !Number.isFinite(p[1])) throw postgisError("RUNTIME.ENCODE_FAILED", "Geometry encode: coordinates must be finite numbers");
|
|
330
|
+
return `${p[0]} ${p[1]}`;
|
|
331
|
+
}
|
|
332
|
+
function formatRings(rings) {
|
|
333
|
+
return rings.map((ring) => `(${ring.map(formatPosition).join(",")})`).join(",");
|
|
334
|
+
}
|
|
335
|
+
const geometryParamsSchema = type({ "srid?": "number" }).narrow((params, ctx) => {
|
|
336
|
+
const { srid } = params;
|
|
337
|
+
if (srid === void 0) return true;
|
|
338
|
+
if (!Number.isInteger(srid)) return ctx.mustBe("an integer");
|
|
339
|
+
if (srid < 0) return ctx.mustBe("a non-negative integer");
|
|
340
|
+
return true;
|
|
341
|
+
});
|
|
342
|
+
const POSTGIS_GEOMETRY_NATIVE_TYPE = "geometry";
|
|
343
|
+
const allowedGeometryTypes = /* @__PURE__ */ new Set([
|
|
344
|
+
"Point",
|
|
345
|
+
"LineString",
|
|
346
|
+
"Polygon",
|
|
347
|
+
"MultiPoint",
|
|
348
|
+
"MultiLineString",
|
|
349
|
+
"MultiPolygon"
|
|
350
|
+
]);
|
|
351
|
+
function assertGeometry(value) {
|
|
352
|
+
if (!value || typeof value !== "object") throw postgisError("RUNTIME.ENCODE_FAILED", "Geometry value must be a GeoJSON-shaped object", { meta: { codecId: POSTGIS_GEOMETRY_CODEC_ID } });
|
|
353
|
+
const type = value.type;
|
|
354
|
+
if (typeof type !== "string" || !allowedGeometryTypes.has(type)) throw postgisError("RUNTIME.ENCODE_FAILED", `Geometry value: unsupported type "${String(type)}" (expected Point, LineString, Polygon, MultiPoint, MultiLineString, or MultiPolygon)`, { meta: { codecId: POSTGIS_GEOMETRY_CODEC_ID } });
|
|
355
|
+
if (!Array.isArray(value.coordinates)) throw postgisError("RUNTIME.ENCODE_FAILED", "Geometry value: \"coordinates\" must be an array", { meta: { codecId: POSTGIS_GEOMETRY_CODEC_ID } });
|
|
356
|
+
}
|
|
357
|
+
var PostgisGeometryCodec = class extends CodecImpl {
|
|
358
|
+
constructor(descriptor) {
|
|
359
|
+
super(descriptor);
|
|
360
|
+
}
|
|
361
|
+
async encode(value, _ctx) {
|
|
362
|
+
assertGeometry(value);
|
|
363
|
+
return encodeEWKT(value);
|
|
364
|
+
}
|
|
365
|
+
async decode(wire, _ctx) {
|
|
366
|
+
if (typeof wire !== "string") throw postgisError("RUNTIME.DECODE_FAILED", "Geometry wire value must be a string", { meta: { codecId: POSTGIS_GEOMETRY_CODEC_ID } });
|
|
367
|
+
return decodeEWKBHex(wire);
|
|
368
|
+
}
|
|
369
|
+
encodeJson(value) {
|
|
370
|
+
assertGeometry(value);
|
|
371
|
+
return encodeEWKBHex(value);
|
|
372
|
+
}
|
|
373
|
+
decodeJson(json) {
|
|
374
|
+
if (typeof json !== "string") throw postgisError("RUNTIME.DECODE_FAILED", "Geometry database JSON value must be a HEXEWKB string", { meta: { codecId: POSTGIS_GEOMETRY_CODEC_ID } });
|
|
375
|
+
return decodeEWKBHex(json);
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
var PostgisGeometryDescriptor = class extends PostgresCodecDescriptor {
|
|
379
|
+
nativeType() {
|
|
380
|
+
return POSTGIS_GEOMETRY_NATIVE_TYPE;
|
|
381
|
+
}
|
|
382
|
+
jsonProjection(expression) {
|
|
383
|
+
return expression;
|
|
384
|
+
}
|
|
385
|
+
codecId = POSTGIS_GEOMETRY_CODEC_ID;
|
|
386
|
+
traits = ["equality"];
|
|
387
|
+
targetTypes = ["geometry"];
|
|
388
|
+
paramsSchema = geometryParamsSchema;
|
|
389
|
+
renderOutputType(params) {
|
|
390
|
+
const { srid } = params;
|
|
391
|
+
if (srid === void 0) return "Geometry";
|
|
392
|
+
return `Geometry<${srid}>`;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Runtime materialization uses an empty parameter object for the
|
|
396
|
+
* existing unparameterized `geometryColumn` variant and `{ srid }` for
|
|
397
|
+
* constrained columns. Both resolve to the same SRID-agnostic codec:
|
|
398
|
+
* the wire format already carries SRID inside the EWKT/EWKB payload,
|
|
399
|
+
* so codec behavior is parameter-independent.
|
|
400
|
+
*/
|
|
401
|
+
factory(_params) {
|
|
402
|
+
return () => new PostgisGeometryCodec(this);
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
const codecDescriptorMap = { geometry: new PostgisGeometryDescriptor() };
|
|
406
|
+
/**
|
|
407
|
+
* Registry of every codec descriptor shipped by `@internal/extension-postgis`.
|
|
408
|
+
*
|
|
409
|
+
* Public consumer surface for the postgis codec set. Currently a single
|
|
410
|
+
* entry (`pg/geometry@1`); the registry shape stays consistent with
|
|
411
|
+
* the other codec-shipping packages so consumers don't need to
|
|
412
|
+
* special-case extensions.
|
|
413
|
+
*/
|
|
414
|
+
const postgisCodecRegistry = buildCodecDescriptorRegistry(definePostgresCodecs(Object.values(codecDescriptorMap)));
|
|
415
|
+
const postgisTypeId = "pg/geometry@1";
|
|
416
|
+
/**
|
|
417
|
+
* Build the PostGIS query operations exposed on `geometry` columns.
|
|
418
|
+
*
|
|
419
|
+
* Each operation lowers to a function-template that the SQL renderer
|
|
420
|
+
* stitches into the surrounding statement (`{{self}}` is the receiver,
|
|
421
|
+
* `{{argN}}` are the call arguments). All templates rely on the implicit
|
|
422
|
+
* `geometry`/`float8`/`bool` casts already wired up by the SQL family —
|
|
423
|
+
* we only add the PostGIS-specific function names.
|
|
424
|
+
*/
|
|
425
|
+
function postgisQueryOperations() {
|
|
426
|
+
return {
|
|
427
|
+
distance: {
|
|
428
|
+
self: { codecId: postgisTypeId },
|
|
429
|
+
impl: (self, other) => {
|
|
430
|
+
const selfCodec = codecOf(self);
|
|
431
|
+
return buildOperation({
|
|
432
|
+
method: "distance",
|
|
433
|
+
args: [toExpr(self, selfCodec), toExpr(other, selfCodec)],
|
|
434
|
+
returns: {
|
|
435
|
+
codecId: "pg/float8@1",
|
|
436
|
+
nullable: false
|
|
437
|
+
},
|
|
438
|
+
lowering: {
|
|
439
|
+
targetFamily: "sql",
|
|
440
|
+
strategy: "function",
|
|
441
|
+
template: "ST_Distance({{self}}, {{arg0}})"
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
distanceSphere: {
|
|
447
|
+
self: { codecId: postgisTypeId },
|
|
448
|
+
impl: (self, other) => {
|
|
449
|
+
const selfCodec = codecOf(self);
|
|
450
|
+
return buildOperation({
|
|
451
|
+
method: "distanceSphere",
|
|
452
|
+
args: [toExpr(self, selfCodec), toExpr(other, selfCodec)],
|
|
453
|
+
returns: {
|
|
454
|
+
codecId: "pg/float8@1",
|
|
455
|
+
nullable: false
|
|
456
|
+
},
|
|
457
|
+
lowering: {
|
|
458
|
+
targetFamily: "sql",
|
|
459
|
+
strategy: "function",
|
|
460
|
+
template: "ST_DistanceSphere({{self}}, {{arg0}})"
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
dwithin: {
|
|
466
|
+
self: { codecId: postgisTypeId },
|
|
467
|
+
impl: (self, other, distance) => {
|
|
468
|
+
const selfCodec = codecOf(self);
|
|
469
|
+
return buildOperation({
|
|
470
|
+
method: "dwithin",
|
|
471
|
+
args: [
|
|
472
|
+
toExpr(self, selfCodec),
|
|
473
|
+
toExpr(other, selfCodec),
|
|
474
|
+
toExpr(distance, { codecId: "pg/float8@1" })
|
|
475
|
+
],
|
|
476
|
+
returns: {
|
|
477
|
+
codecId: "pg/bool@1",
|
|
478
|
+
nullable: false
|
|
479
|
+
},
|
|
480
|
+
lowering: {
|
|
481
|
+
targetFamily: "sql",
|
|
482
|
+
strategy: "function",
|
|
483
|
+
template: "ST_DWithin({{self}}, {{arg0}}, {{arg1}})"
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
},
|
|
488
|
+
contains: {
|
|
489
|
+
self: { codecId: postgisTypeId },
|
|
490
|
+
impl: (self, other) => {
|
|
491
|
+
const selfCodec = codecOf(self);
|
|
492
|
+
return buildOperation({
|
|
493
|
+
method: "contains",
|
|
494
|
+
args: [toExpr(self, selfCodec), toExpr(other, selfCodec)],
|
|
495
|
+
returns: {
|
|
496
|
+
codecId: "pg/bool@1",
|
|
497
|
+
nullable: false
|
|
498
|
+
},
|
|
499
|
+
lowering: {
|
|
500
|
+
targetFamily: "sql",
|
|
501
|
+
strategy: "function",
|
|
502
|
+
template: "ST_Contains({{self}}, {{arg0}})"
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
within: {
|
|
508
|
+
self: { codecId: postgisTypeId },
|
|
509
|
+
impl: (self, other) => {
|
|
510
|
+
const selfCodec = codecOf(self);
|
|
511
|
+
return buildOperation({
|
|
512
|
+
method: "within",
|
|
513
|
+
args: [toExpr(self, selfCodec), toExpr(other, selfCodec)],
|
|
514
|
+
returns: {
|
|
515
|
+
codecId: "pg/bool@1",
|
|
516
|
+
nullable: false
|
|
517
|
+
},
|
|
518
|
+
lowering: {
|
|
519
|
+
targetFamily: "sql",
|
|
520
|
+
strategy: "function",
|
|
521
|
+
template: "ST_Within({{self}}, {{arg0}})"
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
intersects: {
|
|
527
|
+
self: { codecId: postgisTypeId },
|
|
528
|
+
impl: (self, other) => {
|
|
529
|
+
const selfCodec = codecOf(self);
|
|
530
|
+
return buildOperation({
|
|
531
|
+
method: "intersects",
|
|
532
|
+
args: [toExpr(self, selfCodec), toExpr(other, selfCodec)],
|
|
533
|
+
returns: {
|
|
534
|
+
codecId: "pg/bool@1",
|
|
535
|
+
nullable: false
|
|
536
|
+
},
|
|
537
|
+
lowering: {
|
|
538
|
+
targetFamily: "sql",
|
|
539
|
+
strategy: "function",
|
|
540
|
+
template: "ST_Intersects({{self}}, {{arg0}})"
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
intersectsBbox: {
|
|
546
|
+
self: { codecId: postgisTypeId },
|
|
547
|
+
impl: (self, other) => {
|
|
548
|
+
const selfCodec = codecOf(self);
|
|
549
|
+
return buildOperation({
|
|
550
|
+
method: "intersectsBbox",
|
|
551
|
+
args: [toExpr(self, selfCodec), toExpr(other, selfCodec)],
|
|
552
|
+
returns: {
|
|
553
|
+
codecId: "pg/bool@1",
|
|
554
|
+
nullable: false
|
|
555
|
+
},
|
|
556
|
+
lowering: {
|
|
557
|
+
targetFamily: "sql",
|
|
558
|
+
strategy: "function",
|
|
559
|
+
template: "({{self}} && {{arg0}})"
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
const postgisPackMeta = {
|
|
567
|
+
kind: "extension",
|
|
568
|
+
id: "postgis",
|
|
569
|
+
familyId: "sql",
|
|
570
|
+
targetId: "postgres",
|
|
571
|
+
version: "0.0.1",
|
|
572
|
+
capabilities: { postgres: { "postgis.geometry": true } },
|
|
573
|
+
authoring: { type: postgisAuthoringTypes },
|
|
574
|
+
types: {
|
|
575
|
+
codecTypes: {
|
|
576
|
+
codecDescriptors: Array.from(postgisCodecRegistry.values()),
|
|
577
|
+
import: {
|
|
578
|
+
package: "@internal/extension-postgis/codec-types",
|
|
579
|
+
named: "CodecTypes",
|
|
580
|
+
alias: "PostgisTypes"
|
|
581
|
+
},
|
|
582
|
+
typeImports: [{
|
|
583
|
+
package: "@internal/extension-postgis/codec-types",
|
|
584
|
+
named: "Geometry",
|
|
585
|
+
alias: "Geometry"
|
|
586
|
+
}]
|
|
587
|
+
},
|
|
588
|
+
queryOperationTypes: { import: {
|
|
589
|
+
package: "@internal/extension-postgis/operation-types",
|
|
590
|
+
named: "QueryOperationTypes",
|
|
591
|
+
alias: "PostgisQueryOperationTypes"
|
|
592
|
+
} },
|
|
593
|
+
storage: [{
|
|
594
|
+
typeId: postgisTypeId,
|
|
595
|
+
familyId: "sql",
|
|
596
|
+
targetId: "postgres",
|
|
597
|
+
nativeType: "geometry"
|
|
598
|
+
}]
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
//#endregion
|
|
602
|
+
export { postgisPackMeta as n, postgisQueryOperations as r, postgisCodecRegistry as t };
|
|
603
|
+
|
|
604
|
+
//# sourceMappingURL=descriptor-meta-deM0Qc_b-FRxKhllA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-meta-deM0Qc_b-FRxKhllA.mjs","names":[],"sources":["../../../../3-extensions/postgis/dist/descriptor-meta-deM0Qc_b.mjs"],"sourcesContent":["import { t as POSTGIS_GEOMETRY_CODEC_ID } from \"./constants-CWW72xGt.mjs\";\nimport { t as postgisError } from \"./errors-Bg6kDFR-.mjs\";\nimport { buildOperation, codecOf, toExpr } from \"@internal/sql-relational-core/expression\";\nimport { buildCodecDescriptorRegistry } from \"@internal/sql-relational-core/codec-descriptor-registry\";\nimport { CodecImpl } from \"@internal/framework-components/codec\";\nimport { PostgresCodecDescriptor, definePostgresCodecs } from \"@internal/target-postgres/codec-descriptor\";\nimport { type } from \"arktype\";\n//#region src/core/authoring.ts\nconst postgisAuthoringTypes = { postgis: { Geometry: {\n\tkind: \"typeConstructor\",\n\targs: [{\n\t\tkind: \"number\",\n\t\tname: \"srid\",\n\t\tinteger: true,\n\t\tminimum: 0\n\t}],\n\toutput: {\n\t\tcodecId: POSTGIS_GEOMETRY_CODEC_ID,\n\t\tnativeType: \"geometry\",\n\t\ttypeParams: { srid: {\n\t\t\tkind: \"arg\",\n\t\t\tindex: 0\n\t\t} }\n\t}\n} } };\n//#endregion\n//#region src/core/ewkb.ts\n/**\n* Minimal EWKB (Extended Well-Known Binary) reader for the PostGIS codec.\n*\n* `node-postgres` returns geometry columns as hex-encoded EWKB strings by\n* default. This reader parses the subset we ship with the extension —\n* Point, LineString, Polygon, and the Multi* counterparts — into GeoJSON\n* objects. Z and M coordinates are not supported; if a wire value carries\n* them, decoding throws so the caller can detect the mismatch instead of\n* silently dropping data.\n*/\nconst FLAG_Z = 2147483648;\nconst FLAG_M = 1073741824;\nconst FLAG_SRID = 536870912;\nconst TYPE_MASK = 536870911;\nconst TYPE_POINT = 1;\nconst TYPE_LINESTRING = 2;\nconst TYPE_POLYGON = 3;\nconst TYPE_MULTIPOINT = 4;\nconst TYPE_MULTILINESTRING = 5;\nconst TYPE_MULTIPOLYGON = 6;\nconst HEX_PAIR_RE = /^[0-9a-fA-F]{2}$/;\nfunction hexToBytes(hex) {\n\tif (hex.length % 2 !== 0) throw postgisError(\"RUNTIME.DECODE_FAILED\", \"Geometry wire value: odd-length hex string\", { meta: { wirePreview: hex.slice(0, 32) } });\n\tconst bytes = new Uint8Array(hex.length / 2);\n\tfor (let i = 0; i < bytes.length; i++) {\n\t\tconst pair = hex.slice(i * 2, i * 2 + 2);\n\t\tif (!HEX_PAIR_RE.test(pair)) throw postgisError(\"RUNTIME.DECODE_FAILED\", `Geometry wire value: invalid hex byte at offset ${i * 2}`, { meta: { wirePreview: hex.slice(0, 32) } });\n\t\tbytes[i] = Number.parseInt(pair, 16);\n\t}\n\treturn bytes;\n}\nvar Reader = class {\n\toffset = 0;\n\tview;\n\tconstructor(bytes) {\n\t\tthis.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n\t}\n\trequireBytes(needed) {\n\t\tif (this.offset + needed > this.view.byteLength) throw postgisError(\"RUNTIME.DECODE_FAILED\", `Geometry wire value: unexpected end of buffer (need ${needed} bytes at offset ${this.offset}, ${this.view.byteLength - this.offset} available)`);\n\t}\n\treadUint8() {\n\t\tthis.requireBytes(1);\n\t\tconst v = this.view.getUint8(this.offset);\n\t\tthis.offset += 1;\n\t\treturn v;\n\t}\n\treadUint32(littleEndian) {\n\t\tthis.requireBytes(4);\n\t\tconst v = this.view.getUint32(this.offset, littleEndian);\n\t\tthis.offset += 4;\n\t\treturn v >>> 0;\n\t}\n\treadFloat64(littleEndian) {\n\t\tthis.requireBytes(8);\n\t\tconst v = this.view.getFloat64(this.offset, littleEndian);\n\t\tthis.offset += 8;\n\t\treturn v;\n\t}\n\thasRemaining() {\n\t\treturn this.offset !== this.view.byteLength;\n\t}\n\tremainingBytes() {\n\t\treturn this.view.byteLength - this.offset;\n\t}\n};\nvar Writer = class {\n\tbytes = [];\n\twriteUint8(value) {\n\t\tthis.bytes.push(value);\n\t}\n\twriteUint32(value) {\n\t\tconst buffer = /* @__PURE__ */ new ArrayBuffer(4);\n\t\tnew DataView(buffer).setUint32(0, value, true);\n\t\tthis.bytes.push(...new Uint8Array(buffer));\n\t}\n\twriteFloat64(value) {\n\t\tconst buffer = /* @__PURE__ */ new ArrayBuffer(8);\n\t\tnew DataView(buffer).setFloat64(0, value, true);\n\t\tthis.bytes.push(...new Uint8Array(buffer));\n\t}\n\ttoHex() {\n\t\treturn this.bytes.map((byte) => byte.toString(16).padStart(2, \"0\")).join(\"\").toUpperCase();\n\t}\n};\nfunction readHeader(reader) {\n\tconst byteOrder = reader.readUint8();\n\tif (byteOrder !== 0 && byteOrder !== 1) throw postgisError(\"RUNTIME.DECODE_FAILED\", `Geometry wire value: invalid byte order ${byteOrder}`);\n\tconst littleEndian = byteOrder === 1;\n\tconst typeCode = reader.readUint32(littleEndian);\n\tif ((typeCode & FLAG_Z) !== 0 || (typeCode & FLAG_M) !== 0) throw postgisError(\"RUNTIME.DECODE_FAILED\", \"Geometry wire value: Z/M coordinates are not supported\");\n\tconst geomType = typeCode & TYPE_MASK;\n\tif ((typeCode & FLAG_SRID) !== 0) return {\n\t\tgeomType,\n\t\tlittleEndian,\n\t\tsrid: reader.readUint32(littleEndian)\n\t};\n\treturn {\n\t\tgeomType,\n\t\tlittleEndian\n\t};\n}\nfunction readPosition(reader, littleEndian) {\n\treturn [reader.readFloat64(littleEndian), reader.readFloat64(littleEndian)];\n}\nfunction readPoint(reader, header) {\n\tconst coords = readPosition(reader, header.littleEndian);\n\treturn header.srid !== void 0 ? {\n\t\ttype: \"Point\",\n\t\tcoordinates: coords,\n\t\tsrid: header.srid\n\t} : {\n\t\ttype: \"Point\",\n\t\tcoordinates: coords\n\t};\n}\nfunction readLineString(reader, header) {\n\tconst n = reader.readUint32(header.littleEndian);\n\tconst coords = [];\n\tfor (let i = 0; i < n; i++) coords.push(readPosition(reader, header.littleEndian));\n\treturn header.srid !== void 0 ? {\n\t\ttype: \"LineString\",\n\t\tcoordinates: coords,\n\t\tsrid: header.srid\n\t} : {\n\t\ttype: \"LineString\",\n\t\tcoordinates: coords\n\t};\n}\nfunction readPolygon(reader, header) {\n\tconst numRings = reader.readUint32(header.littleEndian);\n\tconst rings = [];\n\tfor (let r = 0; r < numRings; r++) {\n\t\tconst n = reader.readUint32(header.littleEndian);\n\t\tconst ring = [];\n\t\tfor (let i = 0; i < n; i++) ring.push(readPosition(reader, header.littleEndian));\n\t\trings.push(ring);\n\t}\n\treturn header.srid !== void 0 ? {\n\t\ttype: \"Polygon\",\n\t\tcoordinates: rings,\n\t\tsrid: header.srid\n\t} : {\n\t\ttype: \"Polygon\",\n\t\tcoordinates: rings\n\t};\n}\nfunction readSubGeometry(reader) {\n\tconst header = readHeader(reader);\n\tswitch (header.geomType) {\n\t\tcase TYPE_POINT: return readPoint(reader, header);\n\t\tcase TYPE_LINESTRING: return readLineString(reader, header);\n\t\tcase TYPE_POLYGON: return readPolygon(reader, header);\n\t\tdefault: throw postgisError(\"RUNTIME.DECODE_FAILED\", `Geometry wire value: unsupported sub-type ${header.geomType}`);\n\t}\n}\nfunction readMultiPoint(reader, header) {\n\tconst n = reader.readUint32(header.littleEndian);\n\tconst coords = [];\n\tfor (let i = 0; i < n; i++) {\n\t\tconst sub = readSubGeometry(reader);\n\t\tif (sub.type !== \"Point\") throw postgisError(\"RUNTIME.DECODE_FAILED\", \"Geometry wire value: MultiPoint contains non-Point sub-geometry\");\n\t\tcoords.push(sub.coordinates);\n\t}\n\treturn header.srid !== void 0 ? {\n\t\ttype: \"MultiPoint\",\n\t\tcoordinates: coords,\n\t\tsrid: header.srid\n\t} : {\n\t\ttype: \"MultiPoint\",\n\t\tcoordinates: coords\n\t};\n}\nfunction readMultiLineString(reader, header) {\n\tconst n = reader.readUint32(header.littleEndian);\n\tconst lines = [];\n\tfor (let i = 0; i < n; i++) {\n\t\tconst sub = readSubGeometry(reader);\n\t\tif (sub.type !== \"LineString\") throw postgisError(\"RUNTIME.DECODE_FAILED\", \"Geometry wire value: MultiLineString contains non-LineString sub-geometry\");\n\t\tlines.push(sub.coordinates);\n\t}\n\treturn header.srid !== void 0 ? {\n\t\ttype: \"MultiLineString\",\n\t\tcoordinates: lines,\n\t\tsrid: header.srid\n\t} : {\n\t\ttype: \"MultiLineString\",\n\t\tcoordinates: lines\n\t};\n}\nfunction readMultiPolygon(reader, header) {\n\tconst n = reader.readUint32(header.littleEndian);\n\tconst polys = [];\n\tfor (let i = 0; i < n; i++) {\n\t\tconst sub = readSubGeometry(reader);\n\t\tif (sub.type !== \"Polygon\") throw postgisError(\"RUNTIME.DECODE_FAILED\", \"Geometry wire value: MultiPolygon contains non-Polygon sub-geometry\");\n\t\tpolys.push(sub.coordinates);\n\t}\n\treturn header.srid !== void 0 ? {\n\t\ttype: \"MultiPolygon\",\n\t\tcoordinates: polys,\n\t\tsrid: header.srid\n\t} : {\n\t\ttype: \"MultiPolygon\",\n\t\tcoordinates: polys\n\t};\n}\nfunction decodeEWKBHex(hex) {\n\tconst reader = new Reader(hexToBytes(hex));\n\tconst geometry = readGeometryBody(reader, readHeader(reader));\n\tif (reader.hasRemaining()) throw postgisError(\"RUNTIME.DECODE_FAILED\", `Geometry wire value: trailing data after geometry (${reader.remainingBytes()} bytes)`, { meta: { wirePreview: hex.slice(0, 32) } });\n\treturn geometry;\n}\nfunction encodeEWKBHex(value) {\n\tconst writer = new Writer();\n\twriteGeometry(writer, value);\n\treturn writer.toHex();\n}\nfunction writeHeader(writer, geomType, srid) {\n\twriter.writeUint8(1);\n\twriter.writeUint32(srid === void 0 ? geomType : geomType | FLAG_SRID);\n\tif (srid !== void 0) writer.writeUint32(srid);\n}\nfunction writePosition(writer, position) {\n\tif (!Number.isFinite(position[0]) || !Number.isFinite(position[1])) throw postgisError(\"RUNTIME.ENCODE_FAILED\", \"Geometry encode: coordinates must be finite numbers\");\n\twriter.writeFloat64(position[0]);\n\twriter.writeFloat64(position[1]);\n}\nfunction writeLineStringBody(writer, positions) {\n\twriter.writeUint32(positions.length);\n\tfor (const position of positions) writePosition(writer, position);\n}\nfunction writePolygonBody(writer, rings) {\n\twriter.writeUint32(rings.length);\n\tfor (const ring of rings) writeLineStringBody(writer, ring);\n}\nfunction writeGeometry(writer, value) {\n\tswitch (value.type) {\n\t\tcase \"Point\":\n\t\t\twriteHeader(writer, TYPE_POINT, value.srid);\n\t\t\twritePosition(writer, value.coordinates);\n\t\t\tbreak;\n\t\tcase \"LineString\":\n\t\t\twriteHeader(writer, TYPE_LINESTRING, value.srid);\n\t\t\twriteLineStringBody(writer, value.coordinates);\n\t\t\tbreak;\n\t\tcase \"Polygon\":\n\t\t\twriteHeader(writer, TYPE_POLYGON, value.srid);\n\t\t\twritePolygonBody(writer, value.coordinates);\n\t\t\tbreak;\n\t\tcase \"MultiPoint\":\n\t\t\twriteHeader(writer, TYPE_MULTIPOINT, value.srid);\n\t\t\twriter.writeUint32(value.coordinates.length);\n\t\t\tfor (const position of value.coordinates) {\n\t\t\t\twriteHeader(writer, TYPE_POINT);\n\t\t\t\twritePosition(writer, position);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"MultiLineString\":\n\t\t\twriteHeader(writer, TYPE_MULTILINESTRING, value.srid);\n\t\t\twriter.writeUint32(value.coordinates.length);\n\t\t\tfor (const line of value.coordinates) {\n\t\t\t\twriteHeader(writer, TYPE_LINESTRING);\n\t\t\t\twriteLineStringBody(writer, line);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"MultiPolygon\":\n\t\t\twriteHeader(writer, TYPE_MULTIPOLYGON, value.srid);\n\t\t\twriter.writeUint32(value.coordinates.length);\n\t\t\tfor (const polygon of value.coordinates) {\n\t\t\t\twriteHeader(writer, TYPE_POLYGON);\n\t\t\t\twritePolygonBody(writer, polygon);\n\t\t\t}\n\t\t\tbreak;\n\t}\n}\nfunction readGeometryBody(reader, header) {\n\tswitch (header.geomType) {\n\t\tcase TYPE_POINT: return readPoint(reader, header);\n\t\tcase TYPE_LINESTRING: return readLineString(reader, header);\n\t\tcase TYPE_POLYGON: return readPolygon(reader, header);\n\t\tcase TYPE_MULTIPOINT: return readMultiPoint(reader, header);\n\t\tcase TYPE_MULTILINESTRING: return readMultiLineString(reader, header);\n\t\tcase TYPE_MULTIPOLYGON: return readMultiPolygon(reader, header);\n\t\tdefault: throw postgisError(\"RUNTIME.DECODE_FAILED\", `Geometry wire value: unsupported geometry type ${header.geomType}`);\n\t}\n}\n/**\n* Encode a GeoJSON-shaped geometry to an EWKT string PostGIS understands\n* via `'<ewkt>'::geometry`. We use EWKT (not EWKB) on the way in so the\n* generated SQL stays human-readable.\n*/\nfunction encodeEWKT(value) {\n\tconst sridPrefix = value.srid !== void 0 ? `SRID=${value.srid};` : \"\";\n\tswitch (value.type) {\n\t\tcase \"Point\": return `${sridPrefix}POINT(${formatPosition(value.coordinates)})`;\n\t\tcase \"LineString\": return `${sridPrefix}LINESTRING(${value.coordinates.map(formatPosition).join(\",\")})`;\n\t\tcase \"Polygon\": return `${sridPrefix}POLYGON(${formatRings(value.coordinates)})`;\n\t\tcase \"MultiPoint\": return `${sridPrefix}MULTIPOINT(${value.coordinates.map(formatPosition).join(\",\")})`;\n\t\tcase \"MultiLineString\": return `${sridPrefix}MULTILINESTRING(${value.coordinates.map((line) => `(${line.map(formatPosition).join(\",\")})`).join(\",\")})`;\n\t\tcase \"MultiPolygon\": return `${sridPrefix}MULTIPOLYGON(${value.coordinates.map((poly) => `(${formatRings(poly)})`).join(\",\")})`;\n\t}\n}\nfunction formatPosition(p) {\n\tif (!Number.isFinite(p[0]) || !Number.isFinite(p[1])) throw postgisError(\"RUNTIME.ENCODE_FAILED\", \"Geometry encode: coordinates must be finite numbers\");\n\treturn `${p[0]} ${p[1]}`;\n}\nfunction formatRings(rings) {\n\treturn rings.map((ring) => `(${ring.map(formatPosition).join(\",\")})`).join(\",\");\n}\n//#endregion\n//#region src/core/codecs.ts\nconst geometryParamsSchema = type({ \"srid?\": \"number\" }).narrow((params, ctx) => {\n\tconst { srid } = params;\n\tif (srid === void 0) return true;\n\tif (!Number.isInteger(srid)) return ctx.mustBe(\"an integer\");\n\tif (srid < 0) return ctx.mustBe(\"a non-negative integer\");\n\treturn true;\n});\nconst POSTGIS_GEOMETRY_NATIVE_TYPE = \"geometry\";\nconst allowedGeometryTypes = /* @__PURE__ */ new Set([\n\t\"Point\",\n\t\"LineString\",\n\t\"Polygon\",\n\t\"MultiPoint\",\n\t\"MultiLineString\",\n\t\"MultiPolygon\"\n]);\nfunction assertGeometry(value) {\n\tif (!value || typeof value !== \"object\") throw postgisError(\"RUNTIME.ENCODE_FAILED\", \"Geometry value must be a GeoJSON-shaped object\", { meta: { codecId: POSTGIS_GEOMETRY_CODEC_ID } });\n\tconst type = value.type;\n\tif (typeof type !== \"string\" || !allowedGeometryTypes.has(type)) throw postgisError(\"RUNTIME.ENCODE_FAILED\", `Geometry value: unsupported type \"${String(type)}\" (expected Point, LineString, Polygon, MultiPoint, MultiLineString, or MultiPolygon)`, { meta: { codecId: POSTGIS_GEOMETRY_CODEC_ID } });\n\tif (!Array.isArray(value.coordinates)) throw postgisError(\"RUNTIME.ENCODE_FAILED\", \"Geometry value: \\\"coordinates\\\" must be an array\", { meta: { codecId: POSTGIS_GEOMETRY_CODEC_ID } });\n}\nvar PostgisGeometryCodec = class extends CodecImpl {\n\tconstructor(descriptor) {\n\t\tsuper(descriptor);\n\t}\n\tasync encode(value, _ctx) {\n\t\tassertGeometry(value);\n\t\treturn encodeEWKT(value);\n\t}\n\tasync decode(wire, _ctx) {\n\t\tif (typeof wire !== \"string\") throw postgisError(\"RUNTIME.DECODE_FAILED\", \"Geometry wire value must be a string\", { meta: { codecId: POSTGIS_GEOMETRY_CODEC_ID } });\n\t\treturn decodeEWKBHex(wire);\n\t}\n\tencodeJson(value) {\n\t\tassertGeometry(value);\n\t\treturn encodeEWKBHex(value);\n\t}\n\tdecodeJson(json) {\n\t\tif (typeof json !== \"string\") throw postgisError(\"RUNTIME.DECODE_FAILED\", \"Geometry database JSON value must be a HEXEWKB string\", { meta: { codecId: POSTGIS_GEOMETRY_CODEC_ID } });\n\t\treturn decodeEWKBHex(json);\n\t}\n};\nvar PostgisGeometryDescriptor = class extends PostgresCodecDescriptor {\n\tnativeType() {\n\t\treturn POSTGIS_GEOMETRY_NATIVE_TYPE;\n\t}\n\tjsonProjection(expression) {\n\t\treturn expression;\n\t}\n\tcodecId = POSTGIS_GEOMETRY_CODEC_ID;\n\ttraits = [\"equality\"];\n\ttargetTypes = [\"geometry\"];\n\tparamsSchema = geometryParamsSchema;\n\trenderOutputType(params) {\n\t\tconst { srid } = params;\n\t\tif (srid === void 0) return \"Geometry\";\n\t\treturn `Geometry<${srid}>`;\n\t}\n\t/**\n\t* Runtime materialization uses an empty parameter object for the\n\t* existing unparameterized `geometryColumn` variant and `{ srid }` for\n\t* constrained columns. Both resolve to the same SRID-agnostic codec:\n\t* the wire format already carries SRID inside the EWKT/EWKB payload,\n\t* so codec behavior is parameter-independent.\n\t*/\n\tfactory(_params) {\n\t\treturn () => new PostgisGeometryCodec(this);\n\t}\n};\nconst codecDescriptorMap = { geometry: new PostgisGeometryDescriptor() };\n//#endregion\n//#region src/core/registry.ts\n/**\n* Registry of every codec descriptor shipped by `@internal/extension-postgis`.\n*\n* Public consumer surface for the postgis codec set. Currently a single\n* entry (`pg/geometry@1`); the registry shape stays consistent with\n* the other codec-shipping packages so consumers don't need to\n* special-case extensions.\n*/\nconst postgisCodecRegistry = buildCodecDescriptorRegistry(definePostgresCodecs(Object.values(codecDescriptorMap)));\n//#endregion\n//#region src/core/descriptor-meta.ts\nconst postgisTypeId = \"pg/geometry@1\";\n/**\n* Build the PostGIS query operations exposed on `geometry` columns.\n*\n* Each operation lowers to a function-template that the SQL renderer\n* stitches into the surrounding statement (`{{self}}` is the receiver,\n* `{{argN}}` are the call arguments). All templates rely on the implicit\n* `geometry`/`float8`/`bool` casts already wired up by the SQL family —\n* we only add the PostGIS-specific function names.\n*/\nfunction postgisQueryOperations() {\n\treturn {\n\t\tdistance: {\n\t\t\tself: { codecId: postgisTypeId },\n\t\t\timpl: (self, other) => {\n\t\t\t\tconst selfCodec = codecOf(self);\n\t\t\t\treturn buildOperation({\n\t\t\t\t\tmethod: \"distance\",\n\t\t\t\t\targs: [toExpr(self, selfCodec), toExpr(other, selfCodec)],\n\t\t\t\t\treturns: {\n\t\t\t\t\t\tcodecId: \"pg/float8@1\",\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\tstrategy: \"function\",\n\t\t\t\t\t\ttemplate: \"ST_Distance({{self}}, {{arg0}})\"\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tdistanceSphere: {\n\t\t\tself: { codecId: postgisTypeId },\n\t\t\timpl: (self, other) => {\n\t\t\t\tconst selfCodec = codecOf(self);\n\t\t\t\treturn buildOperation({\n\t\t\t\t\tmethod: \"distanceSphere\",\n\t\t\t\t\targs: [toExpr(self, selfCodec), toExpr(other, selfCodec)],\n\t\t\t\t\treturns: {\n\t\t\t\t\t\tcodecId: \"pg/float8@1\",\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\tstrategy: \"function\",\n\t\t\t\t\t\ttemplate: \"ST_DistanceSphere({{self}}, {{arg0}})\"\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tdwithin: {\n\t\t\tself: { codecId: postgisTypeId },\n\t\t\timpl: (self, other, distance) => {\n\t\t\t\tconst selfCodec = codecOf(self);\n\t\t\t\treturn buildOperation({\n\t\t\t\t\tmethod: \"dwithin\",\n\t\t\t\t\targs: [\n\t\t\t\t\t\ttoExpr(self, selfCodec),\n\t\t\t\t\t\ttoExpr(other, selfCodec),\n\t\t\t\t\t\ttoExpr(distance, { codecId: \"pg/float8@1\" })\n\t\t\t\t\t],\n\t\t\t\t\treturns: {\n\t\t\t\t\t\tcodecId: \"pg/bool@1\",\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\tstrategy: \"function\",\n\t\t\t\t\t\ttemplate: \"ST_DWithin({{self}}, {{arg0}}, {{arg1}})\"\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tcontains: {\n\t\t\tself: { codecId: postgisTypeId },\n\t\t\timpl: (self, other) => {\n\t\t\t\tconst selfCodec = codecOf(self);\n\t\t\t\treturn buildOperation({\n\t\t\t\t\tmethod: \"contains\",\n\t\t\t\t\targs: [toExpr(self, selfCodec), toExpr(other, selfCodec)],\n\t\t\t\t\treturns: {\n\t\t\t\t\t\tcodecId: \"pg/bool@1\",\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\tstrategy: \"function\",\n\t\t\t\t\t\ttemplate: \"ST_Contains({{self}}, {{arg0}})\"\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\twithin: {\n\t\t\tself: { codecId: postgisTypeId },\n\t\t\timpl: (self, other) => {\n\t\t\t\tconst selfCodec = codecOf(self);\n\t\t\t\treturn buildOperation({\n\t\t\t\t\tmethod: \"within\",\n\t\t\t\t\targs: [toExpr(self, selfCodec), toExpr(other, selfCodec)],\n\t\t\t\t\treturns: {\n\t\t\t\t\t\tcodecId: \"pg/bool@1\",\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\tstrategy: \"function\",\n\t\t\t\t\t\ttemplate: \"ST_Within({{self}}, {{arg0}})\"\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tintersects: {\n\t\t\tself: { codecId: postgisTypeId },\n\t\t\timpl: (self, other) => {\n\t\t\t\tconst selfCodec = codecOf(self);\n\t\t\t\treturn buildOperation({\n\t\t\t\t\tmethod: \"intersects\",\n\t\t\t\t\targs: [toExpr(self, selfCodec), toExpr(other, selfCodec)],\n\t\t\t\t\treturns: {\n\t\t\t\t\t\tcodecId: \"pg/bool@1\",\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\tstrategy: \"function\",\n\t\t\t\t\t\ttemplate: \"ST_Intersects({{self}}, {{arg0}})\"\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tintersectsBbox: {\n\t\t\tself: { codecId: postgisTypeId },\n\t\t\timpl: (self, other) => {\n\t\t\t\tconst selfCodec = codecOf(self);\n\t\t\t\treturn buildOperation({\n\t\t\t\t\tmethod: \"intersectsBbox\",\n\t\t\t\t\targs: [toExpr(self, selfCodec), toExpr(other, selfCodec)],\n\t\t\t\t\treturns: {\n\t\t\t\t\t\tcodecId: \"pg/bool@1\",\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\tstrategy: \"function\",\n\t\t\t\t\t\ttemplate: \"({{self}} && {{arg0}})\"\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t};\n}\nconst postgisPackMeta = {\n\tkind: \"extension\",\n\tid: \"postgis\",\n\tfamilyId: \"sql\",\n\ttargetId: \"postgres\",\n\tversion: \"0.0.1\",\n\tcapabilities: { postgres: { \"postgis.geometry\": true } },\n\tauthoring: { type: postgisAuthoringTypes },\n\ttypes: {\n\t\tcodecTypes: {\n\t\t\tcodecDescriptors: Array.from(postgisCodecRegistry.values()),\n\t\t\timport: {\n\t\t\t\tpackage: \"@internal/extension-postgis/codec-types\",\n\t\t\t\tnamed: \"CodecTypes\",\n\t\t\t\talias: \"PostgisTypes\"\n\t\t\t},\n\t\t\ttypeImports: [{\n\t\t\t\tpackage: \"@internal/extension-postgis/codec-types\",\n\t\t\t\tnamed: \"Geometry\",\n\t\t\t\talias: \"Geometry\"\n\t\t\t}]\n\t\t},\n\t\tqueryOperationTypes: { import: {\n\t\t\tpackage: \"@internal/extension-postgis/operation-types\",\n\t\t\tnamed: \"QueryOperationTypes\",\n\t\t\talias: \"PostgisQueryOperationTypes\"\n\t\t} },\n\t\tstorage: [{\n\t\t\ttypeId: postgisTypeId,\n\t\t\tfamilyId: \"sql\",\n\t\t\ttargetId: \"postgres\",\n\t\t\tnativeType: \"geometry\"\n\t\t}]\n\t}\n};\n//#endregion\nexport { postgisQueryOperations as n, postgisCodecRegistry as r, postgisPackMeta as t };\n\n//# sourceMappingURL=descriptor-meta-deM0Qc_b.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,wBAAwB,EAAE,SAAS,EAAE,UAAU;CACpD,MAAM;CACN,MAAM,CAAC;EACN,MAAM;EACN,MAAM;EACN,SAAS;EACT,SAAS;CACV,CAAC;CACD,QAAQ;EACP,SAAS;EACT,YAAY;EACZ,YAAY,EAAE,MAAM;GACnB,MAAM;GACN,OAAO;EACR,EAAE;CACH;AACD,EAAE,EAAE;;;;;;;;;;;AAaJ,MAAM,SAAS;AACf,MAAM,SAAS;AACf,MAAM,YAAY;AAClB,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,kBAAkB;AACxB,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,uBAAuB;AAC7B,MAAM,oBAAoB;AAC1B,MAAM,cAAc;AACpB,SAAS,WAAW,KAAK;CACxB,IAAI,IAAI,SAAS,MAAM,GAAG,MAAM,aAAa,yBAAyB,8CAA8C,EAAE,MAAM,EAAE,aAAa,IAAI,MAAM,GAAG,EAAE,EAAE,EAAE,CAAC;CAC/J,MAAM,QAAQ,IAAI,WAAW,IAAI,SAAS,CAAC;CAC3C,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACtC,MAAM,OAAO,IAAI,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC;EACvC,IAAI,CAAC,YAAY,KAAK,IAAI,GAAG,MAAM,aAAa,yBAAyB,mDAAmD,IAAI,KAAK,EAAE,MAAM,EAAE,aAAa,IAAI,MAAM,GAAG,EAAE,EAAE,EAAE,CAAC;EAChL,MAAM,KAAK,OAAO,SAAS,MAAM,EAAE;CACpC;CACA,OAAO;AACR;AACA,IAAI,SAAS,MAAM;CAClB,SAAS;CACT;CACA,YAAY,OAAO;EAClB,KAAK,OAAO,IAAI,SAAS,MAAM,QAAQ,MAAM,YAAY,MAA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