graphile-postgis 0.1.0 → 0.1.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/LICENSE +3 -1
- package/PostgisExtensionDetectionPlugin.d.ts +3 -0
- package/PostgisExtensionDetectionPlugin.js +28 -0
- package/PostgisInflectionPlugin.d.ts +3 -0
- package/PostgisInflectionPlugin.js +36 -0
- package/PostgisRegisterTypesPlugin.d.ts +3 -0
- package/PostgisRegisterTypesPlugin.js +232 -0
- package/PostgisVersionPlugin.d.ts +3 -0
- package/PostgisVersionPlugin.js +23 -0
- package/Postgis_GeometryCollection_GeometriesPlugin.d.ts +3 -0
- package/Postgis_GeometryCollection_GeometriesPlugin.js +43 -0
- package/Postgis_LineString_PointsPlugin.d.ts +3 -0
- package/Postgis_LineString_PointsPlugin.js +40 -0
- package/Postgis_MultiLineString_LineStringsPlugin.d.ts +3 -0
- package/Postgis_MultiLineString_LineStringsPlugin.js +38 -0
- package/Postgis_MultiPoint_PointsPlugin.d.ts +3 -0
- package/Postgis_MultiPoint_PointsPlugin.js +38 -0
- package/Postgis_MultiPolygon_PolygonsPlugin.d.ts +3 -0
- package/Postgis_MultiPolygon_PolygonsPlugin.js +38 -0
- package/Postgis_Point_LatitudeLongitudePlugin.d.ts +3 -0
- package/Postgis_Point_LatitudeLongitudePlugin.js +43 -0
- package/Postgis_Polygon_RingsPlugin.d.ts +3 -0
- package/Postgis_Polygon_RingsPlugin.js +49 -0
- package/README.md +125 -5
- package/constants.d.ts +12 -0
- package/constants.js +34 -0
- package/esm/PostgisExtensionDetectionPlugin.js +26 -0
- package/esm/PostgisInflectionPlugin.js +34 -0
- package/esm/PostgisRegisterTypesPlugin.js +227 -0
- package/esm/PostgisVersionPlugin.js +21 -0
- package/esm/Postgis_GeometryCollection_GeometriesPlugin.js +41 -0
- package/esm/Postgis_LineString_PointsPlugin.js +38 -0
- package/esm/Postgis_MultiLineString_LineStringsPlugin.js +36 -0
- package/esm/Postgis_MultiPoint_PointsPlugin.js +36 -0
- package/esm/Postgis_MultiPolygon_PolygonsPlugin.js +36 -0
- package/esm/Postgis_Point_LatitudeLongitudePlugin.js +41 -0
- package/esm/Postgis_Polygon_RingsPlugin.js +47 -0
- package/esm/constants.js +31 -0
- package/esm/index.js +33 -0
- package/esm/makeGeoJSONType.js +39 -0
- package/esm/types.js +1 -0
- package/esm/utils.js +47 -0
- package/index.d.ts +15 -0
- package/index.js +49 -0
- package/makeGeoJSONType.d.ts +1 -0
- package/makeGeoJSONType.js +42 -0
- package/package.json +37 -52
- package/types.d.ts +59 -0
- package/types.js +2 -0
- package/utils.d.ts +5 -0
- package/utils.js +53 -0
- package/main/PostgisExtensionDetectionPlugin.js +0 -43
- package/main/PostgisInflectionPlugin.js +0 -51
- package/main/PostgisRegisterTypesPlugin.js +0 -347
- package/main/Postgis_GeometryCollection_GeometriesPlugin.js +0 -55
- package/main/Postgis_LineString_PointsPlugin.js +0 -51
- package/main/Postgis_MultiLineString_LineStringsPlugin.js +0 -51
- package/main/Postgis_MultiPoint_PointsPlugin.js +0 -51
- package/main/Postgis_MultiPolygon_PolygonsPlugin.js +0 -51
- package/main/Postgis_Point_LatitudeLongitudePlugin.js +0 -59
- package/main/Postgis_Polygon_RingsPlugin.js +0 -64
- package/main/constants.js +0 -39
- package/main/index.js +0 -93
- package/main/makeGeoJSONType.js +0 -89
- package/main/utils.js +0 -56
- package/module/PostgisExtensionDetectionPlugin.js +0 -31
- package/module/PostgisInflectionPlugin.js +0 -44
- package/module/PostgisRegisterTypesPlugin.js +0 -267
- package/module/Postgis_GeometryCollection_GeometriesPlugin.js +0 -57
- package/module/Postgis_LineString_PointsPlugin.js +0 -53
- package/module/Postgis_MultiLineString_LineStringsPlugin.js +0 -51
- package/module/Postgis_MultiPoint_PointsPlugin.js +0 -51
- package/module/Postgis_MultiPolygon_PolygonsPlugin.js +0 -51
- package/module/Postgis_Point_LatitudeLongitudePlugin.js +0 -64
- package/module/Postgis_Polygon_RingsPlugin.js +0 -66
- package/module/constants.js +0 -30
- package/module/index.js +0 -32
- package/module/makeGeoJSONType.js +0 -79
- package/module/utils.js +0 -40
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _constants = require("./constants");
|
|
9
|
-
|
|
10
|
-
var _utils = require("./utils");
|
|
11
|
-
|
|
12
|
-
var plugin = function plugin(builder) {
|
|
13
|
-
builder.hook('GraphQLObjectType:fields', function (fields, build, context) {
|
|
14
|
-
var _context$scope = context.scope,
|
|
15
|
-
isPgGISType = _context$scope.isPgGISType,
|
|
16
|
-
pgGISType = _context$scope.pgGISType,
|
|
17
|
-
pgGISTypeDetails = _context$scope.pgGISTypeDetails;
|
|
18
|
-
|
|
19
|
-
if (!isPgGISType || !pgGISTypeDetails || pgGISTypeDetails.subtype !== _constants.GIS_SUBTYPE.MultiPoint) {
|
|
20
|
-
return fields;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
var extend = build.extend,
|
|
24
|
-
getPostgisTypeByGeometryType = build.getPostgisTypeByGeometryType,
|
|
25
|
-
GraphQLList = build.graphql.GraphQLList;
|
|
26
|
-
var hasZ = pgGISTypeDetails.hasZ,
|
|
27
|
-
hasM = pgGISTypeDetails.hasM,
|
|
28
|
-
srid = pgGISTypeDetails.srid;
|
|
29
|
-
var Point = getPostgisTypeByGeometryType(pgGISType, _constants.GIS_SUBTYPE.Point, hasZ, hasM, srid);
|
|
30
|
-
return extend(fields, {
|
|
31
|
-
points: {
|
|
32
|
-
type: new GraphQLList(Point),
|
|
33
|
-
resolve: function resolve(data) {
|
|
34
|
-
return data.__geojson.coordinates.map(function (coord) {
|
|
35
|
-
return {
|
|
36
|
-
__gisType: (0, _utils.getGISTypeName)(_constants.GIS_SUBTYPE.Point, hasZ, hasM),
|
|
37
|
-
__srid: data.__srid,
|
|
38
|
-
__geojson: {
|
|
39
|
-
type: 'Point',
|
|
40
|
-
coordinates: coord
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
var _default = plugin;
|
|
51
|
-
exports["default"] = _default;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _constants = require("./constants");
|
|
9
|
-
|
|
10
|
-
var _utils = require("./utils");
|
|
11
|
-
|
|
12
|
-
var plugin = function plugin(builder) {
|
|
13
|
-
builder.hook('GraphQLObjectType:fields', function (fields, build, context) {
|
|
14
|
-
var _context$scope = context.scope,
|
|
15
|
-
isPgGISType = _context$scope.isPgGISType,
|
|
16
|
-
pgGISType = _context$scope.pgGISType,
|
|
17
|
-
pgGISTypeDetails = _context$scope.pgGISTypeDetails;
|
|
18
|
-
|
|
19
|
-
if (!isPgGISType || !pgGISTypeDetails || pgGISTypeDetails.subtype !== _constants.GIS_SUBTYPE.MultiPolygon) {
|
|
20
|
-
return fields;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
var extend = build.extend,
|
|
24
|
-
getPostgisTypeByGeometryType = build.getPostgisTypeByGeometryType,
|
|
25
|
-
GraphQLList = build.graphql.GraphQLList;
|
|
26
|
-
var hasZ = pgGISTypeDetails.hasZ,
|
|
27
|
-
hasM = pgGISTypeDetails.hasM,
|
|
28
|
-
srid = pgGISTypeDetails.srid;
|
|
29
|
-
var Polygon = getPostgisTypeByGeometryType(pgGISType, _constants.GIS_SUBTYPE.Polygon, hasZ, hasM, srid);
|
|
30
|
-
return extend(fields, {
|
|
31
|
-
polygons: {
|
|
32
|
-
type: new GraphQLList(Polygon),
|
|
33
|
-
resolve: function resolve(data) {
|
|
34
|
-
return data.__geojson.coordinates.map(function (coord) {
|
|
35
|
-
return {
|
|
36
|
-
__gisType: (0, _utils.getGISTypeName)(_constants.GIS_SUBTYPE.Polygon, hasZ, hasM),
|
|
37
|
-
__srid: data.__srid,
|
|
38
|
-
__geojson: {
|
|
39
|
-
type: 'Polygon',
|
|
40
|
-
coordinates: coord
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
var _default = plugin;
|
|
51
|
-
exports["default"] = _default;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _constants = require("./constants");
|
|
13
|
-
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
17
|
-
|
|
18
|
-
var plugin = function plugin(builder) {
|
|
19
|
-
builder.hook('GraphQLObjectType:fields', function (fields, build, context) {
|
|
20
|
-
var _objectSpread2;
|
|
21
|
-
|
|
22
|
-
var _context$scope = context.scope,
|
|
23
|
-
isPgGISType = _context$scope.isPgGISType,
|
|
24
|
-
pgGISType = _context$scope.pgGISType,
|
|
25
|
-
pgGISTypeDetails = _context$scope.pgGISTypeDetails;
|
|
26
|
-
|
|
27
|
-
if (!isPgGISType || !pgGISTypeDetails || pgGISTypeDetails.subtype !== _constants.GIS_SUBTYPE.Point) {
|
|
28
|
-
return fields;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
var extend = build.extend,
|
|
32
|
-
_build$graphql = build.graphql,
|
|
33
|
-
GraphQLNonNull = _build$graphql.GraphQLNonNull,
|
|
34
|
-
GraphQLFloat = _build$graphql.GraphQLFloat,
|
|
35
|
-
inflection = build.inflection;
|
|
36
|
-
var xFieldName = inflection.gisXFieldName(pgGISType);
|
|
37
|
-
var yFieldName = inflection.gisYFieldName(pgGISType);
|
|
38
|
-
var zFieldName = inflection.gisZFieldName(pgGISType);
|
|
39
|
-
return extend(fields, _objectSpread((_objectSpread2 = {}, (0, _defineProperty2["default"])(_objectSpread2, xFieldName, {
|
|
40
|
-
type: new GraphQLNonNull(GraphQLFloat),
|
|
41
|
-
resolve: function resolve(data) {
|
|
42
|
-
return data.__geojson.coordinates[0];
|
|
43
|
-
}
|
|
44
|
-
}), (0, _defineProperty2["default"])(_objectSpread2, yFieldName, {
|
|
45
|
-
type: new GraphQLNonNull(GraphQLFloat),
|
|
46
|
-
resolve: function resolve(data) {
|
|
47
|
-
return data.__geojson.coordinates[1];
|
|
48
|
-
}
|
|
49
|
-
}), _objectSpread2), pgGISTypeDetails.hasZ ? (0, _defineProperty2["default"])({}, zFieldName, {
|
|
50
|
-
type: new GraphQLNonNull(GraphQLFloat),
|
|
51
|
-
resolve: function resolve(data) {
|
|
52
|
-
return data.__geojson.coordinates[2];
|
|
53
|
-
}
|
|
54
|
-
}) : {}));
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
var _default = plugin;
|
|
59
|
-
exports["default"] = _default;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _constants = require("./constants");
|
|
9
|
-
|
|
10
|
-
var _utils = require("./utils");
|
|
11
|
-
|
|
12
|
-
var plugin = function plugin(builder) {
|
|
13
|
-
builder.hook('GraphQLObjectType:fields', function (fields, build, context) {
|
|
14
|
-
var _context$scope = context.scope,
|
|
15
|
-
isPgGISType = _context$scope.isPgGISType,
|
|
16
|
-
pgGISType = _context$scope.pgGISType,
|
|
17
|
-
pgGISTypeDetails = _context$scope.pgGISTypeDetails;
|
|
18
|
-
|
|
19
|
-
if (!isPgGISType || !pgGISTypeDetails || pgGISTypeDetails.subtype !== _constants.GIS_SUBTYPE.Polygon) {
|
|
20
|
-
return fields;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
var extend = build.extend,
|
|
24
|
-
getPostgisTypeByGeometryType = build.getPostgisTypeByGeometryType,
|
|
25
|
-
GraphQLList = build.graphql.GraphQLList;
|
|
26
|
-
var hasZ = pgGISTypeDetails.hasZ,
|
|
27
|
-
hasM = pgGISTypeDetails.hasM,
|
|
28
|
-
srid = pgGISTypeDetails.srid;
|
|
29
|
-
var LineString = getPostgisTypeByGeometryType(pgGISType, _constants.GIS_SUBTYPE.LineString, hasZ, hasM, srid);
|
|
30
|
-
return extend(fields, {
|
|
31
|
-
exterior: {
|
|
32
|
-
type: LineString,
|
|
33
|
-
resolve: function resolve(data) {
|
|
34
|
-
return {
|
|
35
|
-
__gisType: (0, _utils.getGISTypeName)(_constants.GIS_SUBTYPE.LineString, hasZ, hasM),
|
|
36
|
-
__srid: data.__srid,
|
|
37
|
-
__geojson: {
|
|
38
|
-
type: 'LineString',
|
|
39
|
-
coordinates: data.__geojson.coordinates[0]
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
interiors: {
|
|
45
|
-
type: new GraphQLList(LineString),
|
|
46
|
-
resolve: function resolve(data) {
|
|
47
|
-
return data.__geojson.coordinates.slice(1).map(function (coord) {
|
|
48
|
-
return {
|
|
49
|
-
__gisType: (0, _utils.getGISTypeName)(_constants.GIS_SUBTYPE.LineString, hasZ, hasM),
|
|
50
|
-
__srid: data.__srid,
|
|
51
|
-
__geojson: {
|
|
52
|
-
type: 'LineString',
|
|
53
|
-
coordinates: coord
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
var _default = plugin;
|
|
64
|
-
exports["default"] = _default;
|
package/main/constants.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.GIS_SUBTYPE_NAME = exports.GIS_SUBTYPE = exports.SUBTYPE_STRING_BY_SUBTYPE = void 0;
|
|
7
|
-
var SUBTYPE_STRING_BY_SUBTYPE = {
|
|
8
|
-
0: 'geometry',
|
|
9
|
-
1: 'point',
|
|
10
|
-
2: 'line-string',
|
|
11
|
-
3: 'polygon',
|
|
12
|
-
4: 'multi-point',
|
|
13
|
-
5: 'multi-line-string',
|
|
14
|
-
6: 'multi-polygon',
|
|
15
|
-
7: 'geometry-collection'
|
|
16
|
-
};
|
|
17
|
-
exports.SUBTYPE_STRING_BY_SUBTYPE = SUBTYPE_STRING_BY_SUBTYPE;
|
|
18
|
-
var GIS_SUBTYPE = {
|
|
19
|
-
Geometry: 0,
|
|
20
|
-
Point: 1,
|
|
21
|
-
LineString: 2,
|
|
22
|
-
Polygon: 3,
|
|
23
|
-
MultiPoint: 4,
|
|
24
|
-
MultiLineString: 5,
|
|
25
|
-
MultiPolygon: 6,
|
|
26
|
-
GeometryCollection: 7
|
|
27
|
-
};
|
|
28
|
-
exports.GIS_SUBTYPE = GIS_SUBTYPE;
|
|
29
|
-
var GIS_SUBTYPE_NAME = {
|
|
30
|
-
0: 'Geometry',
|
|
31
|
-
1: 'Point',
|
|
32
|
-
2: 'LineString',
|
|
33
|
-
3: 'Polygon',
|
|
34
|
-
4: 'MultiPoint',
|
|
35
|
-
5: 'MultiLineString',
|
|
36
|
-
6: 'MultiPolygon',
|
|
37
|
-
7: 'GeometryCollection'
|
|
38
|
-
};
|
|
39
|
-
exports.GIS_SUBTYPE_NAME = GIS_SUBTYPE_NAME;
|
package/main/index.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
|
|
14
|
-
var _PostgisInflectionPlugin = _interopRequireDefault(require("./PostgisInflectionPlugin"));
|
|
15
|
-
|
|
16
|
-
var _PostgisExtensionDetectionPlugin = _interopRequireDefault(require("./PostgisExtensionDetectionPlugin"));
|
|
17
|
-
|
|
18
|
-
var _PostgisRegisterTypesPlugin = _interopRequireDefault(require("./PostgisRegisterTypesPlugin"));
|
|
19
|
-
|
|
20
|
-
var _Postgis_Point_LatitudeLongitudePlugin = _interopRequireDefault(require("./Postgis_Point_LatitudeLongitudePlugin"));
|
|
21
|
-
|
|
22
|
-
var _Postgis_GeometryCollection_GeometriesPlugin = _interopRequireDefault(require("./Postgis_GeometryCollection_GeometriesPlugin"));
|
|
23
|
-
|
|
24
|
-
var _Postgis_LineString_PointsPlugin = _interopRequireDefault(require("./Postgis_LineString_PointsPlugin"));
|
|
25
|
-
|
|
26
|
-
var _Postgis_Polygon_RingsPlugin = _interopRequireDefault(require("./Postgis_Polygon_RingsPlugin"));
|
|
27
|
-
|
|
28
|
-
var _Postgis_MultiPoint_PointsPlugin = _interopRequireDefault(require("./Postgis_MultiPoint_PointsPlugin"));
|
|
29
|
-
|
|
30
|
-
var _Postgis_MultiLineString_LineStringsPlugin = _interopRequireDefault(require("./Postgis_MultiLineString_LineStringsPlugin"));
|
|
31
|
-
|
|
32
|
-
var _Postgis_MultiPolygon_PolygonsPlugin = _interopRequireDefault(require("./Postgis_MultiPolygon_PolygonsPlugin"));
|
|
33
|
-
|
|
34
|
-
var PostgisPlugin = /*#__PURE__*/function () {
|
|
35
|
-
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(builder, options) {
|
|
36
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
37
|
-
while (1) {
|
|
38
|
-
switch (_context.prev = _context.next) {
|
|
39
|
-
case 0:
|
|
40
|
-
_context.next = 2;
|
|
41
|
-
return (0, _PostgisInflectionPlugin["default"])(builder, options);
|
|
42
|
-
|
|
43
|
-
case 2:
|
|
44
|
-
_context.next = 4;
|
|
45
|
-
return (0, _PostgisExtensionDetectionPlugin["default"])(builder, options);
|
|
46
|
-
|
|
47
|
-
case 4:
|
|
48
|
-
_context.next = 6;
|
|
49
|
-
return (0, _PostgisRegisterTypesPlugin["default"])(builder, options);
|
|
50
|
-
|
|
51
|
-
case 6:
|
|
52
|
-
_context.next = 8;
|
|
53
|
-
return (0, _Postgis_Point_LatitudeLongitudePlugin["default"])(builder, options);
|
|
54
|
-
|
|
55
|
-
case 8:
|
|
56
|
-
_context.next = 10;
|
|
57
|
-
return (0, _Postgis_LineString_PointsPlugin["default"])(builder, options);
|
|
58
|
-
|
|
59
|
-
case 10:
|
|
60
|
-
_context.next = 12;
|
|
61
|
-
return (0, _Postgis_Polygon_RingsPlugin["default"])(builder, options);
|
|
62
|
-
|
|
63
|
-
case 12:
|
|
64
|
-
_context.next = 14;
|
|
65
|
-
return (0, _Postgis_MultiPoint_PointsPlugin["default"])(builder, options);
|
|
66
|
-
|
|
67
|
-
case 14:
|
|
68
|
-
_context.next = 16;
|
|
69
|
-
return (0, _Postgis_MultiLineString_LineStringsPlugin["default"])(builder, options);
|
|
70
|
-
|
|
71
|
-
case 16:
|
|
72
|
-
_context.next = 18;
|
|
73
|
-
return (0, _Postgis_MultiPolygon_PolygonsPlugin["default"])(builder, options);
|
|
74
|
-
|
|
75
|
-
case 18:
|
|
76
|
-
_context.next = 20;
|
|
77
|
-
return (0, _Postgis_GeometryCollection_GeometriesPlugin["default"])(builder, options);
|
|
78
|
-
|
|
79
|
-
case 20:
|
|
80
|
-
case "end":
|
|
81
|
-
return _context.stop();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}, _callee);
|
|
85
|
-
}));
|
|
86
|
-
|
|
87
|
-
return function PostgisPlugin(_x, _x2) {
|
|
88
|
-
return _ref.apply(this, arguments);
|
|
89
|
-
};
|
|
90
|
-
}();
|
|
91
|
-
|
|
92
|
-
var _default = PostgisPlugin;
|
|
93
|
-
exports["default"] = _default;
|
package/main/makeGeoJSONType.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = makeGeoJSONType;
|
|
7
|
-
|
|
8
|
-
// This file is based on
|
|
9
|
-
// https://github.com/taion/graphql-type-json/blob/6e45ae4ee0a60f8f3565c8c980a82c7d9b98d3f5/src/index.js
|
|
10
|
-
|
|
11
|
-
/*
|
|
12
|
-
The MIT License (MIT)
|
|
13
|
-
|
|
14
|
-
Copyright (c) 2016 Jimmy Jia
|
|
15
|
-
Copyright (c) 2019 Benjie Gillam
|
|
16
|
-
|
|
17
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
19
|
-
in the Software without restriction, including without limitation the rights
|
|
20
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
22
|
-
furnished to do so, subject to the following conditions:
|
|
23
|
-
|
|
24
|
-
The above copyright notice and this permission notice shall be included in all
|
|
25
|
-
copies or substantial portions of the Software.
|
|
26
|
-
|
|
27
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
|
-
SOFTWARE.
|
|
34
|
-
*/
|
|
35
|
-
function makeGeoJSONType(graphql) {
|
|
36
|
-
var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GeoJSON';
|
|
37
|
-
var Kind = graphql.Kind;
|
|
38
|
-
var GraphQLScalarType = graphql.GraphQLScalarType;
|
|
39
|
-
|
|
40
|
-
function identity(value) {
|
|
41
|
-
return value;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function parseLiteral(ast, variables) {
|
|
45
|
-
switch (ast.kind) {
|
|
46
|
-
case Kind.STRING:
|
|
47
|
-
case Kind.BOOLEAN:
|
|
48
|
-
return ast.value;
|
|
49
|
-
|
|
50
|
-
case Kind.INT:
|
|
51
|
-
case Kind.FLOAT:
|
|
52
|
-
return parseFloat(ast.value);
|
|
53
|
-
|
|
54
|
-
case Kind.OBJECT:
|
|
55
|
-
{
|
|
56
|
-
var value = Object.create(null);
|
|
57
|
-
ast.fields.forEach(function (field) {
|
|
58
|
-
value[field.name.value] = parseLiteral(field.value, variables);
|
|
59
|
-
});
|
|
60
|
-
return value;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
case Kind.LIST:
|
|
64
|
-
return ast.values.map(function (n) {
|
|
65
|
-
return parseLiteral(n, variables);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
case Kind.NULL:
|
|
69
|
-
return null;
|
|
70
|
-
|
|
71
|
-
case Kind.VARIABLE:
|
|
72
|
-
{
|
|
73
|
-
var variableName = ast.name.value;
|
|
74
|
-
return variables ? variables[variableName] : undefined;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
default:
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return new GraphQLScalarType({
|
|
83
|
-
name: name,
|
|
84
|
-
description: "The `".concat(name, "` scalar type represents GeoJSON values as specified by") + '[RFC 7946](https://tools.ietf.org/html/rfc7946).',
|
|
85
|
-
serialize: identity,
|
|
86
|
-
parseValue: identity,
|
|
87
|
-
parseLiteral: parseLiteral
|
|
88
|
-
});
|
|
89
|
-
}
|
package/main/utils.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getGISTypeName = exports.getGISTypeModifier = exports.getGISTypeDetails = void 0;
|
|
7
|
-
|
|
8
|
-
var _constants = require("./constants");
|
|
9
|
-
|
|
10
|
-
var getGISTypeDetails = function getGISTypeDetails(modifier) {
|
|
11
|
-
var allZeroesHopefully = modifier >> 24;
|
|
12
|
-
|
|
13
|
-
if (allZeroesHopefully !== 0) {
|
|
14
|
-
throw new Error('Unsupported PostGIS modifier');
|
|
15
|
-
} // Ref: https://github.com/postgis/postgis/blob/2.5.2/liblwgeom/liblwgeom.h.in#L156-L173
|
|
16
|
-
// #define TYPMOD_GET_SRID(typmod) ((((typmod) & 0x0FFFFF00) - ((typmod) & 0x10000000)) >> 8)
|
|
17
|
-
// #define TYPMOD_GET_TYPE(typmod) ((typmod & 0x000000FC)>>2)
|
|
18
|
-
// #define TYPMOD_GET_Z(typmod) ((typmod & 0x00000002)>>1)
|
|
19
|
-
// #define TYPMOD_GET_M(typmod) (typmod & 0x00000001)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var srid = (modifier & 0x0fffff00) - (modifier & 0x10000000) >> 8;
|
|
23
|
-
var subtype = (modifier & 0x000000fc) >> 2;
|
|
24
|
-
var hasZ = (modifier & 0x00000002) >> 1 === 1;
|
|
25
|
-
var hasM = (modifier & 0x00000001) === 1;
|
|
26
|
-
|
|
27
|
-
if (subtype !== 0 && subtype !== 1 && subtype !== 2 && subtype !== 3 && subtype !== 4 && subtype !== 5 && subtype !== 6 && subtype !== 7) {
|
|
28
|
-
throw new Error("Unsupported PostGIS modifier, expected 0-7, received ".concat(subtype, " (").concat(modifier, ")"));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
subtype: subtype,
|
|
33
|
-
hasZ: hasZ,
|
|
34
|
-
hasM: hasM,
|
|
35
|
-
srid: srid
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
exports.getGISTypeDetails = getGISTypeDetails;
|
|
40
|
-
|
|
41
|
-
var getGISTypeModifier = function getGISTypeModifier(subtype, hasZ, hasM, srid) {
|
|
42
|
-
// Ref: https://github.com/postgis/postgis/blob/2.5.2/liblwgeom/liblwgeom.h.in#L156-L173
|
|
43
|
-
// #define TYPMOD_SET_SRID(typmod, srid) ((typmod) = (((typmod) & 0xE00000FF) | ((srid & 0x001FFFFF)<<8)))
|
|
44
|
-
// #define TYPMOD_SET_TYPE(typmod, type) ((typmod) = (typmod & 0xFFFFFF03) | ((type & 0x0000003F)<<2))
|
|
45
|
-
// #define TYPMOD_SET_Z(typmod) ((typmod) = typmod | 0x00000002)
|
|
46
|
-
// #define TYPMOD_SET_M(typmod) ((typmod) = typmod | 0x00000001)
|
|
47
|
-
return ((srid & 0x001fffff) << 8) + ((subtype & 0x0000003f) << 2) + (hasZ ? 0x00000002 : 0) + (hasM ? 0x00000001 : 0);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
exports.getGISTypeModifier = getGISTypeModifier;
|
|
51
|
-
|
|
52
|
-
var getGISTypeName = function getGISTypeName(subtype, hasZ, hasM) {
|
|
53
|
-
return "".concat(_constants.GIS_SUBTYPE_NAME[subtype]).concat(hasZ ? 'Z' : '').concat(hasM ? 'M' : '');
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
exports.getGISTypeName = getGISTypeName;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const plugin = builder => {
|
|
2
|
-
builder.hook('build', build => {
|
|
3
|
-
const {
|
|
4
|
-
pgIntrospectionResultsByKind: introspectionResultsByKind
|
|
5
|
-
} = build;
|
|
6
|
-
const pgGISExtension = introspectionResultsByKind.extension.find(e => e.name === 'postgis'); // Check we have the postgis extension
|
|
7
|
-
|
|
8
|
-
if (!pgGISExtension) {
|
|
9
|
-
console.warn('PostGIS extension not found in database; skipping');
|
|
10
|
-
return build;
|
|
11
|
-
} // Extract the geography and geometry types
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const pgGISGeometryType = introspectionResultsByKind.type.find(t => t.name === 'geometry' && t.namespaceId === pgGISExtension.namespaceId);
|
|
15
|
-
const pgGISGeographyType = introspectionResultsByKind.type.find(t => t.name === 'geography' && t.namespaceId === pgGISExtension.namespaceId);
|
|
16
|
-
|
|
17
|
-
if (!pgGISGeographyType || !pgGISGeometryType) {
|
|
18
|
-
throw new Error("PostGIS is installed, but we couldn't find the geometry/geography types!");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return build.extend(build, {
|
|
22
|
-
pgGISGraphQLTypesByTypeAndSubtype: {},
|
|
23
|
-
pgGISGraphQLInterfaceTypesByType: {},
|
|
24
|
-
pgGISGeometryType,
|
|
25
|
-
pgGISGeographyType,
|
|
26
|
-
pgGISExtension
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export default plugin;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
-
|
|
7
|
-
import { SUBTYPE_STRING_BY_SUBTYPE } from './constants';
|
|
8
|
-
|
|
9
|
-
const plugin = builder => {
|
|
10
|
-
builder.hook('inflection', inflection => {
|
|
11
|
-
return _objectSpread(_objectSpread({}, inflection), {}, {
|
|
12
|
-
gisType(type, subtype, hasZ, hasM) {
|
|
13
|
-
return this.upperCamelCase([type.name, SUBTYPE_STRING_BY_SUBTYPE[subtype], hasZ ? 'z' : null, hasM ? 'm' : null].filter(_ => _).join('-'));
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
gisInterfaceName(type) {
|
|
17
|
-
return this.upperCamelCase(`${type.name}-interface`);
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
gisDimensionInterfaceName(type, hasZ, hasM) {
|
|
21
|
-
return this.upperCamelCase([type.name, SUBTYPE_STRING_BY_SUBTYPE[0], hasZ ? 'z' : null, hasM ? 'm' : null].filter(_ => _).join('-'));
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
geojsonFieldName() {
|
|
25
|
-
return `geojson`;
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
gisXFieldName(type) {
|
|
29
|
-
return type.name === 'geography' ? 'longitude' : 'x';
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
gisYFieldName(type) {
|
|
33
|
-
return type.name === 'geography' ? 'latitude' : 'y';
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
gisZFieldName(type) {
|
|
37
|
-
return type.name === 'geography' ? 'height' : 'z';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export default plugin;
|