graphile-plugin-connection-filter-postgis 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -86
- package/esm/index.d.ts +18 -0
- package/esm/index.js +19 -24
- package/esm/plugin.d.ts +14 -0
- package/esm/plugin.js +280 -0
- package/esm/preset.d.ts +23 -0
- package/esm/preset.js +25 -0
- package/esm/types.d.ts +23 -0
- package/esm/types.js +1 -0
- package/index.d.ts +18 -4
- package/index.js +22 -28
- package/package.json +45 -41
- package/plugin.d.ts +14 -0
- package/plugin.js +286 -0
- package/preset.d.ts +23 -0
- package/preset.js +28 -0
- package/types.d.ts +23 -0
- package/types.js +2 -0
- package/PgConnectionArgFilterPostgisOperatorsPlugin.d.ts +0 -3
- package/PgConnectionArgFilterPostgisOperatorsPlugin.js +0 -219
- package/esm/PgConnectionArgFilterPostgisOperatorsPlugin.js +0 -217
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const PgConnectionArgFilterPostgisOperatorsPlugin = (builder) => {
|
|
4
|
-
builder.hook("init", (_, build) => {
|
|
5
|
-
const { addConnectionFilterOperator, inflection, pgSql: sql, pgGISExtension, pgGISGeographyType, pgGISGeometryType, } = build;
|
|
6
|
-
if (!pgGISExtension || !pgGISGeographyType || !pgGISGeometryType) {
|
|
7
|
-
return _;
|
|
8
|
-
}
|
|
9
|
-
const GEOGRAPHY = pgGISGeographyType.name;
|
|
10
|
-
const GEOMETRY = pgGISGeometryType.name;
|
|
11
|
-
const gqlTypeNamesByGisBaseTypeName = {
|
|
12
|
-
geography: [],
|
|
13
|
-
geometry: [],
|
|
14
|
-
};
|
|
15
|
-
gqlTypeNamesByGisBaseTypeName.geography.push(inflection.gisInterfaceName(pgGISGeographyType));
|
|
16
|
-
gqlTypeNamesByGisBaseTypeName.geometry.push(inflection.gisInterfaceName(pgGISGeometryType));
|
|
17
|
-
const subtypes = [0, 1, 2, 3, 4, 5, 6, 7];
|
|
18
|
-
for (const subtype of subtypes) {
|
|
19
|
-
for (const hasZ of [false, true]) {
|
|
20
|
-
for (const hasM of [false, true]) {
|
|
21
|
-
gqlTypeNamesByGisBaseTypeName.geography.push(inflection.gisType(pgGISGeographyType, subtype, hasZ, hasM));
|
|
22
|
-
gqlTypeNamesByGisBaseTypeName.geometry.push(inflection.gisType(pgGISGeometryType, subtype, hasZ, hasM));
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const specs = [];
|
|
27
|
-
const functionSpecs = [
|
|
28
|
-
[
|
|
29
|
-
"ST_3DIntersects",
|
|
30
|
-
[GEOMETRY],
|
|
31
|
-
"intersects3D",
|
|
32
|
-
"They share any portion of space in 3D.",
|
|
33
|
-
],
|
|
34
|
-
[
|
|
35
|
-
"ST_Contains",
|
|
36
|
-
[GEOMETRY],
|
|
37
|
-
"contains",
|
|
38
|
-
"No points of the specified geometry lie in the exterior, and at least one point of the interior of the specified geometry lies in the interior.",
|
|
39
|
-
],
|
|
40
|
-
[
|
|
41
|
-
"ST_ContainsProperly",
|
|
42
|
-
[GEOMETRY],
|
|
43
|
-
"containsProperly",
|
|
44
|
-
"The specified geometry intersects the interior but not the boundary (or exterior).",
|
|
45
|
-
],
|
|
46
|
-
[
|
|
47
|
-
"ST_CoveredBy",
|
|
48
|
-
[GEOMETRY, GEOGRAPHY],
|
|
49
|
-
"coveredBy",
|
|
50
|
-
"No point is outside the specified geometry.",
|
|
51
|
-
],
|
|
52
|
-
[
|
|
53
|
-
"ST_Covers",
|
|
54
|
-
[GEOMETRY, GEOGRAPHY],
|
|
55
|
-
"covers",
|
|
56
|
-
"No point in the specified geometry is outside.",
|
|
57
|
-
],
|
|
58
|
-
[
|
|
59
|
-
"ST_Crosses",
|
|
60
|
-
[GEOMETRY],
|
|
61
|
-
"crosses",
|
|
62
|
-
"They have some, but not all, interior points in common.",
|
|
63
|
-
],
|
|
64
|
-
[
|
|
65
|
-
"ST_Disjoint",
|
|
66
|
-
[GEOMETRY],
|
|
67
|
-
"disjoint",
|
|
68
|
-
"They do not share any space together.",
|
|
69
|
-
],
|
|
70
|
-
[
|
|
71
|
-
"ST_Equals",
|
|
72
|
-
[GEOMETRY],
|
|
73
|
-
"equals",
|
|
74
|
-
"They represent the same geometry. Directionality is ignored.",
|
|
75
|
-
],
|
|
76
|
-
[
|
|
77
|
-
"ST_Intersects",
|
|
78
|
-
[GEOMETRY, GEOGRAPHY],
|
|
79
|
-
"intersects",
|
|
80
|
-
"They share any portion of space in 2D.",
|
|
81
|
-
],
|
|
82
|
-
[
|
|
83
|
-
"ST_OrderingEquals",
|
|
84
|
-
[GEOMETRY],
|
|
85
|
-
"orderingEquals",
|
|
86
|
-
"They represent the same geometry and points are in the same directional order.",
|
|
87
|
-
],
|
|
88
|
-
[
|
|
89
|
-
"ST_Overlaps",
|
|
90
|
-
[GEOMETRY],
|
|
91
|
-
"overlaps",
|
|
92
|
-
"They share space, are of the same dimension, but are not completely contained by each other.",
|
|
93
|
-
],
|
|
94
|
-
[
|
|
95
|
-
"ST_Touches",
|
|
96
|
-
[GEOMETRY],
|
|
97
|
-
"touches",
|
|
98
|
-
"They have at least one point in common, but their interiors do not intersect.",
|
|
99
|
-
],
|
|
100
|
-
[
|
|
101
|
-
"ST_Within",
|
|
102
|
-
[GEOMETRY],
|
|
103
|
-
"within",
|
|
104
|
-
"Completely inside the specified geometry.",
|
|
105
|
-
],
|
|
106
|
-
];
|
|
107
|
-
for (const [fn, baseTypeNames, operatorName, description,] of functionSpecs) {
|
|
108
|
-
for (const baseTypeName of baseTypeNames) {
|
|
109
|
-
const sqlGisFunction = pgGISExtension.namespaceName === "public"
|
|
110
|
-
? sql.identifier(fn.toLowerCase())
|
|
111
|
-
: sql.identifier(pgGISExtension.namespaceName, fn.toLowerCase());
|
|
112
|
-
specs.push({
|
|
113
|
-
typeNames: gqlTypeNamesByGisBaseTypeName[baseTypeName === GEOGRAPHY ? "geography" : "geometry"],
|
|
114
|
-
operatorName,
|
|
115
|
-
description,
|
|
116
|
-
resolveType: (fieldType) => fieldType,
|
|
117
|
-
resolve: (i, v) => sql.query `${sqlGisFunction}(${i}, ${v})`,
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
const operatorSpecs = [
|
|
122
|
-
[
|
|
123
|
-
"=",
|
|
124
|
-
[GEOMETRY, GEOGRAPHY],
|
|
125
|
-
"exactlyEquals",
|
|
126
|
-
"Coordinates and coordinate order are the same as specified geometry.",
|
|
127
|
-
],
|
|
128
|
-
[
|
|
129
|
-
"&&",
|
|
130
|
-
[GEOMETRY, GEOGRAPHY],
|
|
131
|
-
"bboxIntersects2D",
|
|
132
|
-
"2D bounding box intersects the specified geometry's 2D bounding box.",
|
|
133
|
-
],
|
|
134
|
-
[
|
|
135
|
-
"&&&",
|
|
136
|
-
[GEOMETRY],
|
|
137
|
-
"bboxIntersectsND",
|
|
138
|
-
"n-D bounding box intersects the specified geometry's n-D bounding box.",
|
|
139
|
-
],
|
|
140
|
-
[
|
|
141
|
-
"&<",
|
|
142
|
-
[GEOMETRY],
|
|
143
|
-
"bboxOverlapsOrLeftOf",
|
|
144
|
-
"Bounding box overlaps or is to the left of the specified geometry's bounding box.",
|
|
145
|
-
],
|
|
146
|
-
[
|
|
147
|
-
"&<|",
|
|
148
|
-
[GEOMETRY],
|
|
149
|
-
"bboxOverlapsOrBelow",
|
|
150
|
-
"Bounding box overlaps or is below the specified geometry's bounding box.",
|
|
151
|
-
],
|
|
152
|
-
[
|
|
153
|
-
"&>",
|
|
154
|
-
[GEOMETRY],
|
|
155
|
-
"bboxOverlapsOrRightOf",
|
|
156
|
-
"Bounding box overlaps or is to the right of the specified geometry's bounding box.",
|
|
157
|
-
],
|
|
158
|
-
[
|
|
159
|
-
"|&>",
|
|
160
|
-
[GEOMETRY],
|
|
161
|
-
"bboxOverlapsOrAbove",
|
|
162
|
-
"Bounding box overlaps or is above the specified geometry's bounding box.",
|
|
163
|
-
],
|
|
164
|
-
[
|
|
165
|
-
"<<",
|
|
166
|
-
[GEOMETRY],
|
|
167
|
-
"bboxLeftOf",
|
|
168
|
-
"Bounding box is strictly to the left of the specified geometry's bounding box.",
|
|
169
|
-
],
|
|
170
|
-
[
|
|
171
|
-
"<<|",
|
|
172
|
-
[GEOMETRY],
|
|
173
|
-
"bboxBelow",
|
|
174
|
-
"Bounding box is strictly below the specified geometry's bounding box.",
|
|
175
|
-
],
|
|
176
|
-
[
|
|
177
|
-
">>",
|
|
178
|
-
[GEOMETRY],
|
|
179
|
-
"bboxRightOf",
|
|
180
|
-
"Bounding box is strictly to the right of the specified geometry's bounding box.",
|
|
181
|
-
],
|
|
182
|
-
[
|
|
183
|
-
"|>>",
|
|
184
|
-
[GEOMETRY],
|
|
185
|
-
"bboxAbove",
|
|
186
|
-
"Bounding box is strictly above the specified geometry's bounding box.",
|
|
187
|
-
],
|
|
188
|
-
[
|
|
189
|
-
"~",
|
|
190
|
-
[GEOMETRY],
|
|
191
|
-
"bboxContains",
|
|
192
|
-
"Bounding box contains the specified geometry's bounding box.",
|
|
193
|
-
],
|
|
194
|
-
[
|
|
195
|
-
"~=",
|
|
196
|
-
[GEOMETRY],
|
|
197
|
-
"bboxEquals",
|
|
198
|
-
"Bounding box is the same as the specified geometry's bounding box.",
|
|
199
|
-
],
|
|
200
|
-
];
|
|
201
|
-
for (const [op, baseTypeNames, operatorName, description,] of operatorSpecs) {
|
|
202
|
-
for (const baseTypeName of baseTypeNames) {
|
|
203
|
-
specs.push({
|
|
204
|
-
typeNames: gqlTypeNamesByGisBaseTypeName[baseTypeName === GEOGRAPHY ? "geography" : "geometry"],
|
|
205
|
-
operatorName,
|
|
206
|
-
description,
|
|
207
|
-
resolveType: (fieldType) => fieldType,
|
|
208
|
-
resolve: (i, v) => sql.query `${i} ${sql.raw(op)} ${v}`,
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
specs.sort((a, b) => (a.operatorName > b.operatorName ? 1 : -1));
|
|
213
|
-
for (const spec of specs) {
|
|
214
|
-
addConnectionFilterOperator(spec.typeNames, spec.operatorName, spec.description, spec.resolveType, spec.resolve);
|
|
215
|
-
}
|
|
216
|
-
return _;
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
exports.default = PgConnectionArgFilterPostgisOperatorsPlugin;
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
const PgConnectionArgFilterPostgisOperatorsPlugin = (builder) => {
|
|
2
|
-
builder.hook("init", (_, build) => {
|
|
3
|
-
const { addConnectionFilterOperator, inflection, pgSql: sql, pgGISExtension, pgGISGeographyType, pgGISGeometryType, } = build;
|
|
4
|
-
if (!pgGISExtension || !pgGISGeographyType || !pgGISGeometryType) {
|
|
5
|
-
return _;
|
|
6
|
-
}
|
|
7
|
-
const GEOGRAPHY = pgGISGeographyType.name;
|
|
8
|
-
const GEOMETRY = pgGISGeometryType.name;
|
|
9
|
-
const gqlTypeNamesByGisBaseTypeName = {
|
|
10
|
-
geography: [],
|
|
11
|
-
geometry: [],
|
|
12
|
-
};
|
|
13
|
-
gqlTypeNamesByGisBaseTypeName.geography.push(inflection.gisInterfaceName(pgGISGeographyType));
|
|
14
|
-
gqlTypeNamesByGisBaseTypeName.geometry.push(inflection.gisInterfaceName(pgGISGeometryType));
|
|
15
|
-
const subtypes = [0, 1, 2, 3, 4, 5, 6, 7];
|
|
16
|
-
for (const subtype of subtypes) {
|
|
17
|
-
for (const hasZ of [false, true]) {
|
|
18
|
-
for (const hasM of [false, true]) {
|
|
19
|
-
gqlTypeNamesByGisBaseTypeName.geography.push(inflection.gisType(pgGISGeographyType, subtype, hasZ, hasM));
|
|
20
|
-
gqlTypeNamesByGisBaseTypeName.geometry.push(inflection.gisType(pgGISGeometryType, subtype, hasZ, hasM));
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const specs = [];
|
|
25
|
-
const functionSpecs = [
|
|
26
|
-
[
|
|
27
|
-
"ST_3DIntersects",
|
|
28
|
-
[GEOMETRY],
|
|
29
|
-
"intersects3D",
|
|
30
|
-
"They share any portion of space in 3D.",
|
|
31
|
-
],
|
|
32
|
-
[
|
|
33
|
-
"ST_Contains",
|
|
34
|
-
[GEOMETRY],
|
|
35
|
-
"contains",
|
|
36
|
-
"No points of the specified geometry lie in the exterior, and at least one point of the interior of the specified geometry lies in the interior.",
|
|
37
|
-
],
|
|
38
|
-
[
|
|
39
|
-
"ST_ContainsProperly",
|
|
40
|
-
[GEOMETRY],
|
|
41
|
-
"containsProperly",
|
|
42
|
-
"The specified geometry intersects the interior but not the boundary (or exterior).",
|
|
43
|
-
],
|
|
44
|
-
[
|
|
45
|
-
"ST_CoveredBy",
|
|
46
|
-
[GEOMETRY, GEOGRAPHY],
|
|
47
|
-
"coveredBy",
|
|
48
|
-
"No point is outside the specified geometry.",
|
|
49
|
-
],
|
|
50
|
-
[
|
|
51
|
-
"ST_Covers",
|
|
52
|
-
[GEOMETRY, GEOGRAPHY],
|
|
53
|
-
"covers",
|
|
54
|
-
"No point in the specified geometry is outside.",
|
|
55
|
-
],
|
|
56
|
-
[
|
|
57
|
-
"ST_Crosses",
|
|
58
|
-
[GEOMETRY],
|
|
59
|
-
"crosses",
|
|
60
|
-
"They have some, but not all, interior points in common.",
|
|
61
|
-
],
|
|
62
|
-
[
|
|
63
|
-
"ST_Disjoint",
|
|
64
|
-
[GEOMETRY],
|
|
65
|
-
"disjoint",
|
|
66
|
-
"They do not share any space together.",
|
|
67
|
-
],
|
|
68
|
-
[
|
|
69
|
-
"ST_Equals",
|
|
70
|
-
[GEOMETRY],
|
|
71
|
-
"equals",
|
|
72
|
-
"They represent the same geometry. Directionality is ignored.",
|
|
73
|
-
],
|
|
74
|
-
[
|
|
75
|
-
"ST_Intersects",
|
|
76
|
-
[GEOMETRY, GEOGRAPHY],
|
|
77
|
-
"intersects",
|
|
78
|
-
"They share any portion of space in 2D.",
|
|
79
|
-
],
|
|
80
|
-
[
|
|
81
|
-
"ST_OrderingEquals",
|
|
82
|
-
[GEOMETRY],
|
|
83
|
-
"orderingEquals",
|
|
84
|
-
"They represent the same geometry and points are in the same directional order.",
|
|
85
|
-
],
|
|
86
|
-
[
|
|
87
|
-
"ST_Overlaps",
|
|
88
|
-
[GEOMETRY],
|
|
89
|
-
"overlaps",
|
|
90
|
-
"They share space, are of the same dimension, but are not completely contained by each other.",
|
|
91
|
-
],
|
|
92
|
-
[
|
|
93
|
-
"ST_Touches",
|
|
94
|
-
[GEOMETRY],
|
|
95
|
-
"touches",
|
|
96
|
-
"They have at least one point in common, but their interiors do not intersect.",
|
|
97
|
-
],
|
|
98
|
-
[
|
|
99
|
-
"ST_Within",
|
|
100
|
-
[GEOMETRY],
|
|
101
|
-
"within",
|
|
102
|
-
"Completely inside the specified geometry.",
|
|
103
|
-
],
|
|
104
|
-
];
|
|
105
|
-
for (const [fn, baseTypeNames, operatorName, description,] of functionSpecs) {
|
|
106
|
-
for (const baseTypeName of baseTypeNames) {
|
|
107
|
-
const sqlGisFunction = pgGISExtension.namespaceName === "public"
|
|
108
|
-
? sql.identifier(fn.toLowerCase())
|
|
109
|
-
: sql.identifier(pgGISExtension.namespaceName, fn.toLowerCase());
|
|
110
|
-
specs.push({
|
|
111
|
-
typeNames: gqlTypeNamesByGisBaseTypeName[baseTypeName === GEOGRAPHY ? "geography" : "geometry"],
|
|
112
|
-
operatorName,
|
|
113
|
-
description,
|
|
114
|
-
resolveType: (fieldType) => fieldType,
|
|
115
|
-
resolve: (i, v) => sql.query `${sqlGisFunction}(${i}, ${v})`,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
const operatorSpecs = [
|
|
120
|
-
[
|
|
121
|
-
"=",
|
|
122
|
-
[GEOMETRY, GEOGRAPHY],
|
|
123
|
-
"exactlyEquals",
|
|
124
|
-
"Coordinates and coordinate order are the same as specified geometry.",
|
|
125
|
-
],
|
|
126
|
-
[
|
|
127
|
-
"&&",
|
|
128
|
-
[GEOMETRY, GEOGRAPHY],
|
|
129
|
-
"bboxIntersects2D",
|
|
130
|
-
"2D bounding box intersects the specified geometry's 2D bounding box.",
|
|
131
|
-
],
|
|
132
|
-
[
|
|
133
|
-
"&&&",
|
|
134
|
-
[GEOMETRY],
|
|
135
|
-
"bboxIntersectsND",
|
|
136
|
-
"n-D bounding box intersects the specified geometry's n-D bounding box.",
|
|
137
|
-
],
|
|
138
|
-
[
|
|
139
|
-
"&<",
|
|
140
|
-
[GEOMETRY],
|
|
141
|
-
"bboxOverlapsOrLeftOf",
|
|
142
|
-
"Bounding box overlaps or is to the left of the specified geometry's bounding box.",
|
|
143
|
-
],
|
|
144
|
-
[
|
|
145
|
-
"&<|",
|
|
146
|
-
[GEOMETRY],
|
|
147
|
-
"bboxOverlapsOrBelow",
|
|
148
|
-
"Bounding box overlaps or is below the specified geometry's bounding box.",
|
|
149
|
-
],
|
|
150
|
-
[
|
|
151
|
-
"&>",
|
|
152
|
-
[GEOMETRY],
|
|
153
|
-
"bboxOverlapsOrRightOf",
|
|
154
|
-
"Bounding box overlaps or is to the right of the specified geometry's bounding box.",
|
|
155
|
-
],
|
|
156
|
-
[
|
|
157
|
-
"|&>",
|
|
158
|
-
[GEOMETRY],
|
|
159
|
-
"bboxOverlapsOrAbove",
|
|
160
|
-
"Bounding box overlaps or is above the specified geometry's bounding box.",
|
|
161
|
-
],
|
|
162
|
-
[
|
|
163
|
-
"<<",
|
|
164
|
-
[GEOMETRY],
|
|
165
|
-
"bboxLeftOf",
|
|
166
|
-
"Bounding box is strictly to the left of the specified geometry's bounding box.",
|
|
167
|
-
],
|
|
168
|
-
[
|
|
169
|
-
"<<|",
|
|
170
|
-
[GEOMETRY],
|
|
171
|
-
"bboxBelow",
|
|
172
|
-
"Bounding box is strictly below the specified geometry's bounding box.",
|
|
173
|
-
],
|
|
174
|
-
[
|
|
175
|
-
">>",
|
|
176
|
-
[GEOMETRY],
|
|
177
|
-
"bboxRightOf",
|
|
178
|
-
"Bounding box is strictly to the right of the specified geometry's bounding box.",
|
|
179
|
-
],
|
|
180
|
-
[
|
|
181
|
-
"|>>",
|
|
182
|
-
[GEOMETRY],
|
|
183
|
-
"bboxAbove",
|
|
184
|
-
"Bounding box is strictly above the specified geometry's bounding box.",
|
|
185
|
-
],
|
|
186
|
-
[
|
|
187
|
-
"~",
|
|
188
|
-
[GEOMETRY],
|
|
189
|
-
"bboxContains",
|
|
190
|
-
"Bounding box contains the specified geometry's bounding box.",
|
|
191
|
-
],
|
|
192
|
-
[
|
|
193
|
-
"~=",
|
|
194
|
-
[GEOMETRY],
|
|
195
|
-
"bboxEquals",
|
|
196
|
-
"Bounding box is the same as the specified geometry's bounding box.",
|
|
197
|
-
],
|
|
198
|
-
];
|
|
199
|
-
for (const [op, baseTypeNames, operatorName, description,] of operatorSpecs) {
|
|
200
|
-
for (const baseTypeName of baseTypeNames) {
|
|
201
|
-
specs.push({
|
|
202
|
-
typeNames: gqlTypeNamesByGisBaseTypeName[baseTypeName === GEOGRAPHY ? "geography" : "geometry"],
|
|
203
|
-
operatorName,
|
|
204
|
-
description,
|
|
205
|
-
resolveType: (fieldType) => fieldType,
|
|
206
|
-
resolve: (i, v) => sql.query `${i} ${sql.raw(op)} ${v}`,
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
specs.sort((a, b) => (a.operatorName > b.operatorName ? 1 : -1));
|
|
211
|
-
for (const spec of specs) {
|
|
212
|
-
addConnectionFilterOperator(spec.typeNames, spec.operatorName, spec.description, spec.resolveType, spec.resolve);
|
|
213
|
-
}
|
|
214
|
-
return _;
|
|
215
|
-
});
|
|
216
|
-
};
|
|
217
|
-
export default PgConnectionArgFilterPostgisOperatorsPlugin;
|