@prisma-next/extension-postgis 0.0.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.
- package/README.md +283 -0
- package/dist/codec-types-DODPC0GY.d.mts +59 -0
- package/dist/codec-types-DODPC0GY.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 +26 -0
- package/dist/column-types.d.mts.map +1 -0
- package/dist/column-types.mjs +28 -0
- package/dist/column-types.mjs.map +1 -0
- package/dist/constants-dLvIWSgv.mjs +6 -0
- package/dist/constants-dLvIWSgv.mjs.map +1 -0
- package/dist/control.d.mts +7 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +189 -0
- package/dist/control.mjs.map +1 -0
- package/dist/descriptor-meta-DUKzIH9c.mjs +516 -0
- package/dist/descriptor-meta-DUKzIH9c.mjs.map +1 -0
- package/dist/geojson-Cj4ldHQ0.d.mts +61 -0
- package/dist/geojson-Cj4ldHQ0.d.mts.map +1 -0
- package/dist/geojson.d.mts +2 -0
- package/dist/geojson.mjs +60 -0
- package/dist/geojson.mjs.map +1 -0
- package/dist/operation-types-C2s9tY0P.d.mts +123 -0
- package/dist/operation-types-C2s9tY0P.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 +64 -0
- package/src/contract.d.ts +91 -0
- package/src/contract.json +40 -0
- package/src/contract.ts +61 -0
- package/src/core/authoring.ts +18 -0
- package/src/core/codecs.ts +193 -0
- package/src/core/constants.ts +3 -0
- package/src/core/contract-space-constants.ts +30 -0
- package/src/core/descriptor-meta.ts +186 -0
- package/src/core/ewkb.ts +284 -0
- package/src/core/geojson.ts +131 -0
- package/src/core/registry.ts +14 -0
- package/src/exports/codec-types.ts +7 -0
- package/src/exports/column-types.ts +38 -0
- package/src/exports/control.ts +101 -0
- package/src/exports/geojson.ts +19 -0
- package/src/exports/operation-types.ts +7 -0
- package/src/exports/pack.ts +1 -0
- package/src/exports/runtime.ts +34 -0
- package/src/types/codec-types.ts +16 -0
- package/src/types/operation-types.ts +81 -0
package/dist/geojson.mjs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//#region src/core/geojson.ts
|
|
2
|
+
/**
|
|
3
|
+
* Construct a Point. Convenience for the common "lng/lat" case.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* point(-122.4194, 37.7749, 4326)
|
|
7
|
+
*/
|
|
8
|
+
function point(longitude, latitude, srid) {
|
|
9
|
+
if (!Number.isFinite(longitude) || !Number.isFinite(latitude)) throw new RangeError("point: coordinates must be finite numbers");
|
|
10
|
+
return srid !== void 0 ? {
|
|
11
|
+
type: "Point",
|
|
12
|
+
coordinates: [longitude, latitude],
|
|
13
|
+
srid
|
|
14
|
+
} : {
|
|
15
|
+
type: "Point",
|
|
16
|
+
coordinates: [longitude, latitude]
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Construct a Polygon from a single outer ring of `[lng, lat]` pairs.
|
|
21
|
+
* If the first and last positions differ, the ring is closed automatically.
|
|
22
|
+
*/
|
|
23
|
+
function polygon(ring, srid) {
|
|
24
|
+
if (ring.length < 3) throw new Error("polygon: ring must contain at least 3 positions");
|
|
25
|
+
const first = ring[0];
|
|
26
|
+
const last = ring[ring.length - 1];
|
|
27
|
+
if (!first || !last) throw new Error("polygon: ring positions cannot be undefined");
|
|
28
|
+
for (const position of ring) if (!Number.isFinite(position[0]) || !Number.isFinite(position[1])) throw new RangeError("polygon: coordinates must be finite numbers");
|
|
29
|
+
const closed = first[0] === last[0] && first[1] === last[1] ? ring : [...ring, first];
|
|
30
|
+
if (new Set(closed.slice(0, -1).map(([x, y]) => `${x},${y}`)).size < 3) throw new Error("polygon: ring must contain at least 3 distinct positions");
|
|
31
|
+
return srid !== void 0 ? {
|
|
32
|
+
type: "Polygon",
|
|
33
|
+
coordinates: [closed],
|
|
34
|
+
srid
|
|
35
|
+
} : {
|
|
36
|
+
type: "Polygon",
|
|
37
|
+
coordinates: [closed]
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Construct a rectangular Polygon from a bounding box.
|
|
42
|
+
*
|
|
43
|
+
* @param bbox - `[minLng, minLat, maxLng, maxLat]`
|
|
44
|
+
*/
|
|
45
|
+
function bboxPolygon(bbox, srid) {
|
|
46
|
+
const [minX, minY, maxX, maxY] = bbox;
|
|
47
|
+
if (!Number.isFinite(minX) || !Number.isFinite(minY) || !Number.isFinite(maxX) || !Number.isFinite(maxY)) throw new RangeError("bboxPolygon: coordinates must be finite numbers");
|
|
48
|
+
if (minX > maxX || minY > maxY) throw new Error(`bboxPolygon: inverted bbox [${minX}, ${minY}, ${maxX}, ${maxY}] (expected minX <= maxX and minY <= maxY)`);
|
|
49
|
+
return polygon([
|
|
50
|
+
[minX, minY],
|
|
51
|
+
[maxX, minY],
|
|
52
|
+
[maxX, maxY],
|
|
53
|
+
[minX, maxY],
|
|
54
|
+
[minX, minY]
|
|
55
|
+
], srid);
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { bboxPolygon, point, polygon };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=geojson.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geojson.mjs","names":[],"sources":["../src/core/geojson.ts"],"sourcesContent":["/**\n * GeoJSON-shaped value types used by the PostGIS codec.\n *\n * The codec speaks GeoJSON-style objects to JavaScript callers and\n * EWKT/EWKB on the wire. This file is the single source of truth for the\n * value shapes; the public type re-export lives in `exports/geojson.ts`.\n */\n\nexport type Position = readonly [number, number];\n\nexport type GeometryPoint = {\n readonly type: 'Point';\n readonly coordinates: Position;\n readonly srid?: number;\n};\n\nexport type GeometryLineString = {\n readonly type: 'LineString';\n readonly coordinates: ReadonlyArray<Position>;\n readonly srid?: number;\n};\n\nexport type GeometryPolygon = {\n readonly type: 'Polygon';\n readonly coordinates: ReadonlyArray<ReadonlyArray<Position>>;\n readonly srid?: number;\n};\n\nexport type GeometryMultiPoint = {\n readonly type: 'MultiPoint';\n readonly coordinates: ReadonlyArray<Position>;\n readonly srid?: number;\n};\n\nexport type GeometryMultiLineString = {\n readonly type: 'MultiLineString';\n readonly coordinates: ReadonlyArray<ReadonlyArray<Position>>;\n readonly srid?: number;\n};\n\nexport type GeometryMultiPolygon = {\n readonly type: 'MultiPolygon';\n readonly coordinates: ReadonlyArray<ReadonlyArray<ReadonlyArray<Position>>>;\n readonly srid?: number;\n};\n\nexport type Geometry =\n | GeometryPoint\n | GeometryLineString\n | GeometryPolygon\n | GeometryMultiPoint\n | GeometryMultiLineString\n | GeometryMultiPolygon;\n\n/**\n * Construct a Point. Convenience for the common \"lng/lat\" case.\n *\n * @example\n * point(-122.4194, 37.7749, 4326)\n */\nexport function point(longitude: number, latitude: number, srid?: number): GeometryPoint {\n if (!Number.isFinite(longitude) || !Number.isFinite(latitude)) {\n throw new RangeError('point: coordinates must be finite numbers');\n }\n return srid !== undefined\n ? { type: 'Point', coordinates: [longitude, latitude], srid }\n : { type: 'Point', coordinates: [longitude, latitude] };\n}\n\n/**\n * Construct a Polygon from a single outer ring of `[lng, lat]` pairs.\n * If the first and last positions differ, the ring is closed automatically.\n */\nexport function polygon(ring: ReadonlyArray<Position>, srid?: number): GeometryPolygon {\n if (ring.length < 3) {\n throw new Error('polygon: ring must contain at least 3 positions');\n }\n const first = ring[0];\n const last = ring[ring.length - 1];\n if (!first || !last) {\n throw new Error('polygon: ring positions cannot be undefined');\n }\n for (const position of ring) {\n if (!Number.isFinite(position[0]) || !Number.isFinite(position[1])) {\n throw new RangeError('polygon: coordinates must be finite numbers');\n }\n }\n const closed = first[0] === last[0] && first[1] === last[1] ? ring : [...ring, first];\n const distinct = new Set(closed.slice(0, -1).map(([x, y]) => `${x},${y}`));\n if (distinct.size < 3) {\n throw new Error('polygon: ring must contain at least 3 distinct positions');\n }\n return srid !== undefined\n ? { type: 'Polygon', coordinates: [closed], srid }\n : { type: 'Polygon', coordinates: [closed] };\n}\n\n/**\n * Construct a rectangular Polygon from a bounding box.\n *\n * @param bbox - `[minLng, minLat, maxLng, maxLat]`\n */\nexport function bboxPolygon(\n bbox: readonly [number, number, number, number],\n srid?: number,\n): GeometryPolygon {\n const [minX, minY, maxX, maxY] = bbox;\n if (\n !Number.isFinite(minX) ||\n !Number.isFinite(minY) ||\n !Number.isFinite(maxX) ||\n !Number.isFinite(maxY)\n ) {\n throw new RangeError('bboxPolygon: coordinates must be finite numbers');\n }\n if (minX > maxX || minY > maxY) {\n throw new Error(\n `bboxPolygon: inverted bbox [${minX}, ${minY}, ${maxX}, ${maxY}] (expected minX <= maxX and minY <= maxY)`,\n );\n }\n return polygon(\n [\n [minX, minY],\n [maxX, minY],\n [maxX, maxY],\n [minX, maxY],\n [minX, minY],\n ],\n srid,\n );\n}\n"],"mappings":";;;;;;;AA4DA,SAAgB,MAAM,WAAmB,UAAkB,MAA8B;CACvF,IAAI,CAAC,OAAO,SAAS,UAAU,IAAI,CAAC,OAAO,SAAS,SAAS,EAC3D,MAAM,IAAI,WAAW,4CAA4C;CAEnE,OAAO,SAAS,KAAA,IACZ;EAAE,MAAM;EAAS,aAAa,CAAC,WAAW,SAAS;EAAE;EAAM,GAC3D;EAAE,MAAM;EAAS,aAAa,CAAC,WAAW,SAAS;EAAE;;;;;;AAO3D,SAAgB,QAAQ,MAA+B,MAAgC;CACrF,IAAI,KAAK,SAAS,GAChB,MAAM,IAAI,MAAM,kDAAkD;CAEpE,MAAM,QAAQ,KAAK;CACnB,MAAM,OAAO,KAAK,KAAK,SAAS;CAChC,IAAI,CAAC,SAAS,CAAC,MACb,MAAM,IAAI,MAAM,8CAA8C;CAEhE,KAAK,MAAM,YAAY,MACrB,IAAI,CAAC,OAAO,SAAS,SAAS,GAAG,IAAI,CAAC,OAAO,SAAS,SAAS,GAAG,EAChE,MAAM,IAAI,WAAW,8CAA8C;CAGvE,MAAM,SAAS,MAAM,OAAO,KAAK,MAAM,MAAM,OAAO,KAAK,KAAK,OAAO,CAAC,GAAG,MAAM,MAAM;CAErF,IAAI,IADiB,IAAI,OAAO,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,IAAI,CAC7D,CAAC,OAAO,GAClB,MAAM,IAAI,MAAM,2DAA2D;CAE7E,OAAO,SAAS,KAAA,IACZ;EAAE,MAAM;EAAW,aAAa,CAAC,OAAO;EAAE;EAAM,GAChD;EAAE,MAAM;EAAW,aAAa,CAAC,OAAO;EAAE;;;;;;;AAQhD,SAAgB,YACd,MACA,MACiB;CACjB,MAAM,CAAC,MAAM,MAAM,MAAM,QAAQ;CACjC,IACE,CAAC,OAAO,SAAS,KAAK,IACtB,CAAC,OAAO,SAAS,KAAK,IACtB,CAAC,OAAO,SAAS,KAAK,IACtB,CAAC,OAAO,SAAS,KAAK,EAEtB,MAAM,IAAI,WAAW,kDAAkD;CAEzE,IAAI,OAAO,QAAQ,OAAO,MACxB,MAAM,IAAI,MACR,+BAA+B,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,4CAChE;CAEH,OAAO,QACL;EACE,CAAC,MAAM,KAAK;EACZ,CAAC,MAAM,KAAK;EACZ,CAAC,MAAM,KAAK;EACZ,CAAC,MAAM,KAAK;EACZ,CAAC,MAAM,KAAK;EACb,EACD,KACD"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { CodecExpression, Expression } from "@prisma-next/sql-relational-core/expression";
|
|
2
|
+
import { SqlQueryOperationTypes } from "@prisma-next/sql-contract/types";
|
|
3
|
+
|
|
4
|
+
//#region src/types/operation-types.d.ts
|
|
5
|
+
type CodecTypesBase = Record<string, {
|
|
6
|
+
readonly input: unknown;
|
|
7
|
+
readonly output: unknown;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Operation type definitions for the PostGIS extension.
|
|
11
|
+
*
|
|
12
|
+
* These are type-only signatures consumed by emitted `contract.d.ts`
|
|
13
|
+
* files so the query builder surfaces `.distance()`, `.dwithin()`,
|
|
14
|
+
* `.contains()`, `.within()`, `.intersects()`, and `.intersectsBbox()`
|
|
15
|
+
* on `geometry` columns.
|
|
16
|
+
*/
|
|
17
|
+
type OperationTypes = {
|
|
18
|
+
readonly 'pg/geometry@1': {
|
|
19
|
+
readonly distance: {
|
|
20
|
+
readonly self: {
|
|
21
|
+
readonly codecId: 'pg/geometry@1';
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
readonly distanceSphere: {
|
|
25
|
+
readonly self: {
|
|
26
|
+
readonly codecId: 'pg/geometry@1';
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
readonly dwithin: {
|
|
30
|
+
readonly self: {
|
|
31
|
+
readonly codecId: 'pg/geometry@1';
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
readonly contains: {
|
|
35
|
+
readonly self: {
|
|
36
|
+
readonly codecId: 'pg/geometry@1';
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
readonly within: {
|
|
40
|
+
readonly self: {
|
|
41
|
+
readonly codecId: 'pg/geometry@1';
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
readonly intersects: {
|
|
45
|
+
readonly self: {
|
|
46
|
+
readonly codecId: 'pg/geometry@1';
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
readonly intersectsBbox: {
|
|
50
|
+
readonly self: {
|
|
51
|
+
readonly codecId: 'pg/geometry@1';
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
type QueryOperationTypes<CT extends CodecTypesBase> = SqlQueryOperationTypes<CT, {
|
|
57
|
+
readonly distance: {
|
|
58
|
+
readonly self: {
|
|
59
|
+
readonly codecId: 'pg/geometry@1';
|
|
60
|
+
};
|
|
61
|
+
readonly impl: (self: CodecExpression<'pg/geometry@1', boolean, CT>, other: CodecExpression<'pg/geometry@1', boolean, CT>) => Expression<{
|
|
62
|
+
codecId: 'pg/float8@1';
|
|
63
|
+
nullable: false;
|
|
64
|
+
}>;
|
|
65
|
+
};
|
|
66
|
+
readonly distanceSphere: {
|
|
67
|
+
readonly self: {
|
|
68
|
+
readonly codecId: 'pg/geometry@1';
|
|
69
|
+
};
|
|
70
|
+
readonly impl: (self: CodecExpression<'pg/geometry@1', boolean, CT>, other: CodecExpression<'pg/geometry@1', boolean, CT>) => Expression<{
|
|
71
|
+
codecId: 'pg/float8@1';
|
|
72
|
+
nullable: false;
|
|
73
|
+
}>;
|
|
74
|
+
};
|
|
75
|
+
readonly dwithin: {
|
|
76
|
+
readonly self: {
|
|
77
|
+
readonly codecId: 'pg/geometry@1';
|
|
78
|
+
};
|
|
79
|
+
readonly impl: (self: CodecExpression<'pg/geometry@1', boolean, CT>, other: CodecExpression<'pg/geometry@1', boolean, CT>, distance: CodecExpression<'pg/float8@1', boolean, CT>) => Expression<{
|
|
80
|
+
codecId: 'pg/bool@1';
|
|
81
|
+
nullable: false;
|
|
82
|
+
}>;
|
|
83
|
+
};
|
|
84
|
+
readonly contains: {
|
|
85
|
+
readonly self: {
|
|
86
|
+
readonly codecId: 'pg/geometry@1';
|
|
87
|
+
};
|
|
88
|
+
readonly impl: (self: CodecExpression<'pg/geometry@1', boolean, CT>, other: CodecExpression<'pg/geometry@1', boolean, CT>) => Expression<{
|
|
89
|
+
codecId: 'pg/bool@1';
|
|
90
|
+
nullable: false;
|
|
91
|
+
}>;
|
|
92
|
+
};
|
|
93
|
+
readonly within: {
|
|
94
|
+
readonly self: {
|
|
95
|
+
readonly codecId: 'pg/geometry@1';
|
|
96
|
+
};
|
|
97
|
+
readonly impl: (self: CodecExpression<'pg/geometry@1', boolean, CT>, other: CodecExpression<'pg/geometry@1', boolean, CT>) => Expression<{
|
|
98
|
+
codecId: 'pg/bool@1';
|
|
99
|
+
nullable: false;
|
|
100
|
+
}>;
|
|
101
|
+
};
|
|
102
|
+
readonly intersects: {
|
|
103
|
+
readonly self: {
|
|
104
|
+
readonly codecId: 'pg/geometry@1';
|
|
105
|
+
};
|
|
106
|
+
readonly impl: (self: CodecExpression<'pg/geometry@1', boolean, CT>, other: CodecExpression<'pg/geometry@1', boolean, CT>) => Expression<{
|
|
107
|
+
codecId: 'pg/bool@1';
|
|
108
|
+
nullable: false;
|
|
109
|
+
}>;
|
|
110
|
+
};
|
|
111
|
+
readonly intersectsBbox: {
|
|
112
|
+
readonly self: {
|
|
113
|
+
readonly codecId: 'pg/geometry@1';
|
|
114
|
+
};
|
|
115
|
+
readonly impl: (self: CodecExpression<'pg/geometry@1', boolean, CT>, other: CodecExpression<'pg/geometry@1', boolean, CT>) => Expression<{
|
|
116
|
+
codecId: 'pg/bool@1';
|
|
117
|
+
nullable: false;
|
|
118
|
+
}>;
|
|
119
|
+
};
|
|
120
|
+
}>;
|
|
121
|
+
//#endregion
|
|
122
|
+
export { QueryOperationTypes as n, OperationTypes as t };
|
|
123
|
+
//# sourceMappingURL=operation-types-C2s9tY0P.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-types-C2s9tY0P.d.mts","names":[],"sources":["../src/types/operation-types.ts"],"mappings":";;;;KAGK,cAAA,GAAiB,MAAA;EAAA,SAA0B,KAAA;EAAA,SAAyB,MAAA;AAAA;;;;;;;;AAWzE;KAAY,cAAA;EAAA,SACD,eAAA;IAAA,SACE,QAAA;MAAA,SAAqB,IAAA;QAAA,SAAiB,OAAA;MAAA;IAAA;IAAA,SACtC,cAAA;MAAA,SAA2B,IAAA;QAAA,SAAiB,OAAA;MAAA;IAAA;IAAA,SAC5C,OAAA;MAAA,SAAoB,IAAA;QAAA,SAAiB,OAAA;MAAA;IAAA;IAAA,SACrC,QAAA;MAAA,SAAqB,IAAA;QAAA,SAAiB,OAAA;MAAA;IAAA;IAAA,SACtC,MAAA;MAAA,SAAmB,IAAA;QAAA,SAAiB,OAAA;MAAA;IAAA;IAAA,SACpC,UAAA;MAAA,SAAuB,IAAA;QAAA,SAAiB,OAAA;MAAA;IAAA;IAAA,SACxC,cAAA;MAAA,SAA2B,IAAA;QAAA,SAAiB,OAAA;MAAA;IAAA;EAAA;AAAA;AAAA,KAI7C,mBAAA,YAA+B,cAAA,IAAkB,sBAAA,CAC3D,EAAA;EAAA,SAEW,QAAA;IAAA,SACE,IAAA;MAAA,SAAiB,OAAA;IAAA;IAAA,SACjB,IAAA,GACP,IAAA,EAAM,eAAA,2BAA0C,EAAA,GAChD,KAAA,EAAO,eAAA,2BAA0C,EAAA,MAC9C,UAAA;MAAa,OAAA;MAAwB,QAAA;IAAA;EAAA;EAAA,SAEnC,cAAA;IAAA,SACE,IAAA;MAAA,SAAiB,OAAA;IAAA;IAAA,SACjB,IAAA,GACP,IAAA,EAAM,eAAA,2BAA0C,EAAA,GAChD,KAAA,EAAO,eAAA,2BAA0C,EAAA,MAC9C,UAAA;MAAa,OAAA;MAAwB,QAAA;IAAA;EAAA;EAAA,SAEnC,OAAA;IAAA,SACE,IAAA;MAAA,SAAiB,OAAA;IAAA;IAAA,SACjB,IAAA,GACP,IAAA,EAAM,eAAA,2BAA0C,EAAA,GAChD,KAAA,EAAO,eAAA,2BAA0C,EAAA,GACjD,QAAA,EAAU,eAAA,yBAAwC,EAAA,MAC/C,UAAA;MAAa,OAAA;MAAsB,QAAA;IAAA;EAAA;EAAA,SAEjC,QAAA;IAAA,SACE,IAAA;MAAA,SAAiB,OAAA;IAAA;IAAA,SACjB,IAAA,GACP,IAAA,EAAM,eAAA,2BAA0C,EAAA,GAChD,KAAA,EAAO,eAAA,2BAA0C,EAAA,MAC9C,UAAA;MAAa,OAAA;MAAsB,QAAA;IAAA;EAAA;EAAA,SAEjC,MAAA;IAAA,SACE,IAAA;MAAA,SAAiB,OAAA;IAAA;IAAA,SACjB,IAAA,GACP,IAAA,EAAM,eAAA,2BAA0C,EAAA,GAChD,KAAA,EAAO,eAAA,2BAA0C,EAAA,MAC9C,UAAA;MAAa,OAAA;MAAsB,QAAA;IAAA;EAAA;EAAA,SAEjC,UAAA;IAAA,SACE,IAAA;MAAA,SAAiB,OAAA;IAAA;IAAA,SACjB,IAAA,GACP,IAAA,EAAM,eAAA,2BAA0C,EAAA,GAChD,KAAA,EAAO,eAAA,2BAA0C,EAAA,MAC9C,UAAA;MAAa,OAAA;MAAsB,QAAA;IAAA;EAAA;EAAA,SAEjC,cAAA;IAAA,SACE,IAAA;MAAA,SAAiB,OAAA;IAAA;IAAA,SACjB,IAAA,GACP,IAAA,EAAM,eAAA,2BAA0C,EAAA,GAChD,KAAA,EAAO,eAAA,2BAA0C,EAAA,MAC9C,UAAA;MAAa,OAAA;MAAsB,QAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/pack.d.mts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { t as CodecTypes } from "./codec-types-DODPC0GY.mjs";
|
|
2
|
+
import * as _$_prisma_next_framework_components_codec0 from "@prisma-next/framework-components/codec";
|
|
3
|
+
|
|
4
|
+
//#region src/core/descriptor-meta.d.ts
|
|
5
|
+
declare const postgisPackMetaBase: {
|
|
6
|
+
readonly kind: "extension";
|
|
7
|
+
readonly id: "postgis";
|
|
8
|
+
readonly familyId: "sql";
|
|
9
|
+
readonly targetId: "postgres";
|
|
10
|
+
readonly version: "0.0.1";
|
|
11
|
+
readonly capabilities: {
|
|
12
|
+
readonly postgres: {
|
|
13
|
+
readonly 'postgis.geometry': true;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
readonly authoring: {
|
|
17
|
+
readonly type: {
|
|
18
|
+
readonly postgis: {
|
|
19
|
+
readonly Geometry: {
|
|
20
|
+
readonly kind: "typeConstructor";
|
|
21
|
+
readonly args: readonly [{
|
|
22
|
+
readonly kind: "number";
|
|
23
|
+
readonly name: "srid";
|
|
24
|
+
readonly integer: true;
|
|
25
|
+
readonly minimum: 0;
|
|
26
|
+
}];
|
|
27
|
+
readonly output: {
|
|
28
|
+
readonly codecId: "pg/geometry@1";
|
|
29
|
+
readonly nativeType: "geometry";
|
|
30
|
+
readonly typeParams: {
|
|
31
|
+
readonly srid: {
|
|
32
|
+
readonly kind: "arg";
|
|
33
|
+
readonly index: 0;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
readonly types: {
|
|
42
|
+
readonly codecTypes: {
|
|
43
|
+
readonly codecDescriptors: _$_prisma_next_framework_components_codec0.CodecDescriptor<unknown>[];
|
|
44
|
+
readonly import: {
|
|
45
|
+
readonly package: "@prisma-next/extension-postgis/codec-types";
|
|
46
|
+
readonly named: "CodecTypes";
|
|
47
|
+
readonly alias: "PostgisTypes";
|
|
48
|
+
};
|
|
49
|
+
readonly typeImports: readonly [{
|
|
50
|
+
readonly package: "@prisma-next/extension-postgis/codec-types";
|
|
51
|
+
readonly named: "Geometry";
|
|
52
|
+
readonly alias: "Geometry";
|
|
53
|
+
}];
|
|
54
|
+
};
|
|
55
|
+
readonly queryOperationTypes: {
|
|
56
|
+
readonly import: {
|
|
57
|
+
readonly package: "@prisma-next/extension-postgis/operation-types";
|
|
58
|
+
readonly named: "QueryOperationTypes";
|
|
59
|
+
readonly alias: "PostgisQueryOperationTypes";
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
readonly storage: readonly [{
|
|
63
|
+
readonly typeId: "pg/geometry@1";
|
|
64
|
+
readonly familyId: "sql";
|
|
65
|
+
readonly targetId: "postgres";
|
|
66
|
+
readonly nativeType: "geometry";
|
|
67
|
+
}];
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
declare const postgisPackMeta: typeof postgisPackMetaBase & {
|
|
71
|
+
readonly __codecTypes?: CodecTypes;
|
|
72
|
+
};
|
|
73
|
+
//#endregion
|
|
74
|
+
export { postgisPackMeta as default };
|
|
75
|
+
//# sourceMappingURL=pack.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack.d.mts","names":[],"sources":["../src/core/descriptor-meta.ts"],"mappings":";;;;cA4IM,mBAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAyCI,0CAAA,CAAA,eAAA;MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;cAEG,eAAA,SAAwB,mBAAA;EAAA,SAC1B,YAAA,GAAe,UAAA;AAAA"}
|
package/dist/pack.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SqlRuntimeExtensionDescriptor } from "@prisma-next/sql-runtime";
|
|
2
|
+
import { CodecDescriptorRegistry } from "@prisma-next/sql-relational-core/query-lane-context";
|
|
3
|
+
|
|
4
|
+
//#region src/core/registry.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Registry of every codec descriptor shipped by `@prisma-next/extension-postgis`.
|
|
7
|
+
*
|
|
8
|
+
* Public consumer surface for the postgis codec set. Currently a single
|
|
9
|
+
* entry (`pg/geometry@1`); the registry shape stays consistent with
|
|
10
|
+
* the other codec-shipping packages so consumers don't need to
|
|
11
|
+
* special-case extensions.
|
|
12
|
+
*/
|
|
13
|
+
declare const postgisCodecRegistry: CodecDescriptorRegistry;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/exports/runtime.d.ts
|
|
16
|
+
declare const postgisRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { postgisRuntimeDescriptor as default, postgisCodecRegistry };
|
|
19
|
+
//# sourceMappingURL=runtime.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/registry.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;AAYA;;;;;cAAa,oBAAA,EAAsB,uBAAA;;;cCR7B,wBAAA,EAA0B,6BAAA"}
|
package/dist/runtime.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { n as postgisQueryOperations, r as postgisCodecRegistry, t as postgisPackMeta } from "./descriptor-meta-DUKzIH9c.mjs";
|
|
2
|
+
//#region src/exports/runtime.ts
|
|
3
|
+
const postgisRuntimeDescriptor = {
|
|
4
|
+
kind: "extension",
|
|
5
|
+
id: postgisPackMeta.id,
|
|
6
|
+
version: postgisPackMeta.version,
|
|
7
|
+
familyId: "sql",
|
|
8
|
+
targetId: "postgres",
|
|
9
|
+
types: { codecTypes: { codecDescriptors: Array.from(postgisCodecRegistry.values()) } },
|
|
10
|
+
codecs: () => Array.from(postgisCodecRegistry.values()),
|
|
11
|
+
queryOperations: () => postgisQueryOperations(),
|
|
12
|
+
create() {
|
|
13
|
+
return {
|
|
14
|
+
familyId: "sql",
|
|
15
|
+
targetId: "postgres"
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { postgisRuntimeDescriptor as default, postgisCodecRegistry };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=runtime.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { SqlRuntimeExtensionDescriptor } from '@prisma-next/sql-runtime';\nimport { postgisPackMeta, postgisQueryOperations } from '../core/descriptor-meta';\nimport { postgisCodecRegistry } from '../core/registry';\n\nconst postgisRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'> = {\n kind: 'extension' as const,\n id: postgisPackMeta.id,\n version: postgisPackMeta.version,\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n // Expose the unified descriptor list so `extractCodecLookup` reads\n // `targetTypes` / `meta` / `renderOutputType` directly off the\n // descriptors and materialises the representative `Codec` for the\n // SQL renderer's cast-policy lookup. Without it, the Postgres\n // adapter's runtime codec lookup would miss `pg/geometry@1` and\n // `$N::geometry` casts would disappear once the renderer switches\n // to lookup-driven cast policy.\n types: {\n codecTypes: {\n codecDescriptors: Array.from(postgisCodecRegistry.values()),\n },\n },\n codecs: () => Array.from(postgisCodecRegistry.values()),\n queryOperations: () => postgisQueryOperations(),\n create() {\n return {\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n };\n },\n};\n\nexport { postgisCodecRegistry };\nexport default postgisRuntimeDescriptor;\n"],"mappings":";;AAIA,MAAM,2BAAsE;CAC1E,MAAM;CACN,IAAI,gBAAgB;CACpB,SAAS,gBAAgB;CACzB,UAAU;CACV,UAAU;CAQV,OAAO,EACL,YAAY,EACV,kBAAkB,MAAM,KAAK,qBAAqB,QAAQ,CAAC,EAC5D,EACF;CACD,cAAc,MAAM,KAAK,qBAAqB,QAAQ,CAAC;CACvD,uBAAuB,wBAAwB;CAC/C,SAAS;EACP,OAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEJ"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@prisma-next/extension-postgis",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build:contract-space": "prisma-next contract emit",
|
|
9
|
+
"build": "tsdown",
|
|
10
|
+
"test": "vitest run",
|
|
11
|
+
"test:coverage": "vitest run --coverage",
|
|
12
|
+
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
13
|
+
"lint": "biome check . --error-on-warnings",
|
|
14
|
+
"lint:fix": "biome check --write .",
|
|
15
|
+
"lint:fix:unsafe": "biome check --write --unsafe .",
|
|
16
|
+
"clean": "rm -rf dist dist-tsc dist-tsc-prod coverage .tmp-output"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@prisma-next/contract": "workspace:*",
|
|
20
|
+
"@prisma-next/contract-authoring": "workspace:*",
|
|
21
|
+
"@prisma-next/family-sql": "workspace:*",
|
|
22
|
+
"@prisma-next/framework-components": "workspace:*",
|
|
23
|
+
"@prisma-next/migration-tools": "workspace:*",
|
|
24
|
+
"@prisma-next/sql-contract": "workspace:*",
|
|
25
|
+
"@prisma-next/sql-operations": "workspace:*",
|
|
26
|
+
"@prisma-next/sql-relational-core": "workspace:*",
|
|
27
|
+
"@prisma-next/sql-runtime": "workspace:*",
|
|
28
|
+
"@prisma-next/sql-schema-ir": "workspace:*",
|
|
29
|
+
"@standard-schema/spec": "^1.1.0",
|
|
30
|
+
"arktype": "^2.1.29"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@prisma-next/adapter-postgres": "workspace:*",
|
|
34
|
+
"@prisma-next/cli": "workspace:*",
|
|
35
|
+
"@prisma-next/operations": "workspace:*",
|
|
36
|
+
"@prisma-next/sql-contract-ts": "workspace:*",
|
|
37
|
+
"@prisma-next/target-postgres": "workspace:*",
|
|
38
|
+
"@prisma-next/test-utils": "workspace:*",
|
|
39
|
+
"@prisma-next/tsconfig": "workspace:*",
|
|
40
|
+
"@prisma-next/tsdown": "workspace:*",
|
|
41
|
+
"tsdown": "catalog:",
|
|
42
|
+
"typescript": "catalog:",
|
|
43
|
+
"vitest": "catalog:"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"dist",
|
|
47
|
+
"src"
|
|
48
|
+
],
|
|
49
|
+
"exports": {
|
|
50
|
+
"./codec-types": "./dist/codec-types.mjs",
|
|
51
|
+
"./column-types": "./dist/column-types.mjs",
|
|
52
|
+
"./control": "./dist/control.mjs",
|
|
53
|
+
"./geojson": "./dist/geojson.mjs",
|
|
54
|
+
"./operation-types": "./dist/operation-types.mjs",
|
|
55
|
+
"./pack": "./dist/pack.mjs",
|
|
56
|
+
"./runtime": "./dist/runtime.mjs",
|
|
57
|
+
"./package.json": "./package.json"
|
|
58
|
+
},
|
|
59
|
+
"repository": {
|
|
60
|
+
"type": "git",
|
|
61
|
+
"url": "https://github.com/prisma/prisma-next.git",
|
|
62
|
+
"directory": "packages/3-extensions/postgis"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// ⚠️ GENERATED FILE - DO NOT EDIT
|
|
2
|
+
// This file is automatically generated by 'prisma-next contract emit'.
|
|
3
|
+
// To regenerate, run: prisma-next contract emit
|
|
4
|
+
import type { CodecTypes as PgTypes } from '@prisma-next/target-postgres/codec-types';
|
|
5
|
+
import type { JsonValue } from '@prisma-next/target-postgres/codec-types';
|
|
6
|
+
import type { Char } from '@prisma-next/target-postgres/codec-types';
|
|
7
|
+
import type { Varchar } from '@prisma-next/target-postgres/codec-types';
|
|
8
|
+
import type { Numeric } from '@prisma-next/target-postgres/codec-types';
|
|
9
|
+
import type { Bit } from '@prisma-next/target-postgres/codec-types';
|
|
10
|
+
import type { VarBit } from '@prisma-next/target-postgres/codec-types';
|
|
11
|
+
import type { Timestamp } from '@prisma-next/target-postgres/codec-types';
|
|
12
|
+
import type { Timestamptz } from '@prisma-next/target-postgres/codec-types';
|
|
13
|
+
import type { Time } from '@prisma-next/target-postgres/codec-types';
|
|
14
|
+
import type { Timetz } from '@prisma-next/target-postgres/codec-types';
|
|
15
|
+
import type { Interval } from '@prisma-next/target-postgres/codec-types';
|
|
16
|
+
import type { QueryOperationTypes as PgAdapterQueryOps } from '@prisma-next/adapter-postgres/operation-types';
|
|
17
|
+
|
|
18
|
+
import type {
|
|
19
|
+
ContractWithTypeMaps,
|
|
20
|
+
TypeMaps as TypeMapsType,
|
|
21
|
+
} from '@prisma-next/sql-contract/types';
|
|
22
|
+
import type {
|
|
23
|
+
Contract as ContractType,
|
|
24
|
+
ExecutionHashBase,
|
|
25
|
+
ProfileHashBase,
|
|
26
|
+
StorageHashBase,
|
|
27
|
+
} from '@prisma-next/contract/types';
|
|
28
|
+
|
|
29
|
+
export type StorageHash =
|
|
30
|
+
StorageHashBase<'sha256:01622b3970e0ee2a582cc4c857bca7f6ed970f21b23f44e3f2781eea0be7d5eb'>;
|
|
31
|
+
export type ExecutionHash = ExecutionHashBase<string>;
|
|
32
|
+
export type ProfileHash =
|
|
33
|
+
ProfileHashBase<'sha256:1a8dbe044289f30a1de958fe800cc5a8378b285d2e126a8c44b58864bac2c18e'>;
|
|
34
|
+
|
|
35
|
+
export type CodecTypes = PgTypes;
|
|
36
|
+
export type LaneCodecTypes = CodecTypes;
|
|
37
|
+
export type QueryOperationTypes = PgAdapterQueryOps<CodecTypes>;
|
|
38
|
+
type DefaultLiteralValue<CodecId extends string, _Encoded> = CodecId extends keyof CodecTypes
|
|
39
|
+
? CodecTypes[CodecId]['output']
|
|
40
|
+
: _Encoded;
|
|
41
|
+
|
|
42
|
+
export type FieldOutputTypes = Record<string, never>;
|
|
43
|
+
export type FieldInputTypes = Record<string, never>;
|
|
44
|
+
export type TypeMaps = TypeMapsType<
|
|
45
|
+
CodecTypes,
|
|
46
|
+
QueryOperationTypes,
|
|
47
|
+
FieldOutputTypes,
|
|
48
|
+
FieldInputTypes
|
|
49
|
+
>;
|
|
50
|
+
|
|
51
|
+
type ContractBase = ContractType<
|
|
52
|
+
{
|
|
53
|
+
readonly tables: {};
|
|
54
|
+
readonly types: {
|
|
55
|
+
readonly geometry: {
|
|
56
|
+
readonly codecId: 'pg/geometry@1';
|
|
57
|
+
readonly nativeType: 'geometry';
|
|
58
|
+
readonly typeParams: Record<string, never>;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
readonly storageHash: StorageHash;
|
|
62
|
+
},
|
|
63
|
+
Record<string, never>
|
|
64
|
+
> & {
|
|
65
|
+
readonly target: 'postgres';
|
|
66
|
+
readonly targetFamily: 'sql';
|
|
67
|
+
readonly roots: Record<string, string>;
|
|
68
|
+
readonly capabilities: {
|
|
69
|
+
readonly postgres: {
|
|
70
|
+
readonly jsonAgg: true;
|
|
71
|
+
readonly lateral: true;
|
|
72
|
+
readonly limit: true;
|
|
73
|
+
readonly orderBy: true;
|
|
74
|
+
readonly returning: true;
|
|
75
|
+
};
|
|
76
|
+
readonly sql: {
|
|
77
|
+
readonly defaultInInsert: true;
|
|
78
|
+
readonly enums: true;
|
|
79
|
+
readonly returning: true;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
readonly extensionPacks: {};
|
|
83
|
+
readonly meta: {};
|
|
84
|
+
|
|
85
|
+
readonly profileHash: ProfileHash;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type Contract = ContractWithTypeMaps<ContractBase, TypeMaps>;
|
|
89
|
+
|
|
90
|
+
export type Tables = Contract['storage']['tables'];
|
|
91
|
+
export type Models = Contract['models'];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1",
|
|
3
|
+
"targetFamily": "sql",
|
|
4
|
+
"target": "postgres",
|
|
5
|
+
"profileHash": "sha256:1a8dbe044289f30a1de958fe800cc5a8378b285d2e126a8c44b58864bac2c18e",
|
|
6
|
+
"roots": {},
|
|
7
|
+
"models": {},
|
|
8
|
+
"storage": {
|
|
9
|
+
"storageHash": "sha256:01622b3970e0ee2a582cc4c857bca7f6ed970f21b23f44e3f2781eea0be7d5eb",
|
|
10
|
+
"tables": {},
|
|
11
|
+
"types": {
|
|
12
|
+
"geometry": {
|
|
13
|
+
"codecId": "pg/geometry@1",
|
|
14
|
+
"nativeType": "geometry",
|
|
15
|
+
"typeParams": {}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"capabilities": {
|
|
20
|
+
"postgres": {
|
|
21
|
+
"jsonAgg": true,
|
|
22
|
+
"lateral": true,
|
|
23
|
+
"limit": true,
|
|
24
|
+
"orderBy": true,
|
|
25
|
+
"returning": true
|
|
26
|
+
},
|
|
27
|
+
"sql": {
|
|
28
|
+
"defaultInInsert": true,
|
|
29
|
+
"enums": true,
|
|
30
|
+
"returning": true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"extensionPacks": {},
|
|
34
|
+
"meta": {},
|
|
35
|
+
"_generated": {
|
|
36
|
+
"warning": "⚠️ GENERATED FILE - DO NOT EDIT",
|
|
37
|
+
"message": "This file is automatically generated by \"prisma-next contract emit\".",
|
|
38
|
+
"regenerate": "To regenerate, run: prisma-next contract emit"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/contract.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TS contract source for the `extension-postgis` package.
|
|
3
|
+
*
|
|
4
|
+
* Authored against the contract-space package layout convention. The
|
|
5
|
+
* same emit pipeline application authors use is applied here:
|
|
6
|
+
*
|
|
7
|
+
* `prisma-next contract emit` → `<package>/src/contract.{json,d.ts}`
|
|
8
|
+
* `prisma-next migration plan` → `<package>/migrations/<dirName>/`
|
|
9
|
+
*
|
|
10
|
+
* The descriptor at `src/exports/control.ts` then wires the emitted
|
|
11
|
+
* JSON artefacts via JSON-import declarations.
|
|
12
|
+
*
|
|
13
|
+
* ## IR coverage
|
|
14
|
+
*
|
|
15
|
+
* postgis ships **no tables** of its own. The single object the
|
|
16
|
+
* extension contributes to the contract IR is the parameterised native
|
|
17
|
+
* type `geometry`, registered under `storage.types`. Per-column
|
|
18
|
+
* instances on the user's side carry concrete `typeParams.srid`
|
|
19
|
+
* (e.g. `geometry({ srid: 4326 })`); the registration here declares
|
|
20
|
+
* the parameterised shape so the verifier sees `geometry` as part of
|
|
21
|
+
* postgis's space contribution and so the pinned `contract.json` on
|
|
22
|
+
* disk is materially distinct from an empty space.
|
|
23
|
+
*
|
|
24
|
+
* ## Why TS, not PSL
|
|
25
|
+
*
|
|
26
|
+
* The contract-space package layout convention prefers PSL
|
|
27
|
+
* (`src/contract.prisma`). postgis is the same narrow exception
|
|
28
|
+
* pgvector takes: PSL's `types {}` block instantiates parameterised
|
|
29
|
+
* types at app authoring time (e.g. `Geom4326 = postgis.Geometry(4326)`)
|
|
30
|
+
* but has no surface for an extension to register the parameterised
|
|
31
|
+
* BASE type itself (the `storage.types.geometry` entry with empty
|
|
32
|
+
* `typeParams` shown below). Until PSL grows that surface, this
|
|
33
|
+
* extension keeps its contract source in TS.
|
|
34
|
+
*
|
|
35
|
+
* @see docs/architecture docs/adrs/ADR 212 - Contract spaces.md
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
import sqlFamily from '@prisma-next/family-sql/pack';
|
|
39
|
+
import { defineContract } from '@prisma-next/sql-contract-ts/contract-builder';
|
|
40
|
+
import postgresPack from '@prisma-next/target-postgres/pack';
|
|
41
|
+
import { POSTGIS_GEOMETRY_CODEC_ID } from './core/constants';
|
|
42
|
+
import { POSTGIS_NATIVE_TYPE } from './core/contract-space-constants';
|
|
43
|
+
|
|
44
|
+
export const contract = defineContract(
|
|
45
|
+
{
|
|
46
|
+
family: sqlFamily,
|
|
47
|
+
target: postgresPack,
|
|
48
|
+
},
|
|
49
|
+
() => ({
|
|
50
|
+
types: {
|
|
51
|
+
[POSTGIS_NATIVE_TYPE]: {
|
|
52
|
+
codecId: POSTGIS_GEOMETRY_CODEC_ID,
|
|
53
|
+
nativeType: POSTGIS_NATIVE_TYPE,
|
|
54
|
+
typeParams: {},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
models: {},
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
export default contract;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';
|
|
2
|
+
import { POSTGIS_GEOMETRY_CODEC_ID } from './constants';
|
|
3
|
+
|
|
4
|
+
export const postgisAuthoringTypes = {
|
|
5
|
+
postgis: {
|
|
6
|
+
Geometry: {
|
|
7
|
+
kind: 'typeConstructor',
|
|
8
|
+
args: [{ kind: 'number', name: 'srid', integer: true, minimum: 0 }],
|
|
9
|
+
output: {
|
|
10
|
+
codecId: POSTGIS_GEOMETRY_CODEC_ID,
|
|
11
|
+
nativeType: 'geometry',
|
|
12
|
+
typeParams: {
|
|
13
|
+
srid: { kind: 'arg', index: 0 },
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
} as const satisfies AuthoringTypeNamespace;
|