zod-geojson 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/LICENSE +21 -0
- package/README.md +107 -0
- package/lib/base.d.ts +9 -0
- package/lib/base.d.ts.map +1 -0
- package/lib/base.js +8 -0
- package/lib/bbox.d.ts +4 -0
- package/lib/bbox.d.ts.map +1 -0
- package/lib/bbox.js +9 -0
- package/lib/feature.d.ts +634 -0
- package/lib/feature.d.ts.map +1 -0
- package/lib/feature.js +37 -0
- package/lib/feature_collection.d.ts +3174 -0
- package/lib/feature_collection.d.ts.map +1 -0
- package/lib/feature_collection.js +61 -0
- package/lib/geometry/_simple.d.ts +122 -0
- package/lib/geometry/_simple.d.ts.map +1 -0
- package/lib/geometry/_simple.js +14 -0
- package/lib/geometry/geometry_collection.d.ts +18 -0
- package/lib/geometry/geometry_collection.d.ts.map +1 -0
- package/lib/geometry/geometry_collection.js +60 -0
- package/lib/geometry/index.d.ts +131 -0
- package/lib/geometry/index.d.ts.map +1 -0
- package/lib/geometry/index.js +27 -0
- package/lib/geometry/line_string.d.ts +25 -0
- package/lib/geometry/line_string.d.ts.map +1 -0
- package/lib/geometry/line_string.js +33 -0
- package/lib/geometry/multi_line_string.d.ts +24 -0
- package/lib/geometry/multi_line_string.d.ts.map +1 -0
- package/lib/geometry/multi_line_string.js +32 -0
- package/lib/geometry/multi_point.d.ts +24 -0
- package/lib/geometry/multi_point.d.ts.map +1 -0
- package/lib/geometry/multi_point.js +32 -0
- package/lib/geometry/multi_polygon.d.ts +24 -0
- package/lib/geometry/multi_polygon.d.ts.map +1 -0
- package/lib/geometry/multi_polygon.js +44 -0
- package/lib/geometry/point.d.ts +24 -0
- package/lib/geometry/point.d.ts.map +1 -0
- package/lib/geometry/point.js +25 -0
- package/lib/geometry/polygon.d.ts +28 -0
- package/lib/geometry/polygon.d.ts.map +1 -0
- package/lib/geometry/polygon.js +51 -0
- package/lib/geometry/validation/bbox.d.ts +50 -0
- package/lib/geometry/validation/bbox.d.ts.map +1 -0
- package/lib/geometry/validation/bbox.js +184 -0
- package/lib/geometry/validation/dimension.d.ts +16 -0
- package/lib/geometry/validation/dimension.d.ts.map +1 -0
- package/lib/geometry/validation/dimension.js +54 -0
- package/lib/geometry/validation/keys.d.ts +6 -0
- package/lib/geometry/validation/keys.d.ts.map +1 -0
- package/lib/geometry/validation/keys.js +14 -0
- package/lib/index.d.ts +3930 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +29 -0
- package/lib/position.d.ts +5 -0
- package/lib/position.d.ts.map +1 -0
- package/lib/position.js +8 -0
- package/lib/type.d.ts +6 -0
- package/lib/type.d.ts.map +1 -0
- package/lib/type.js +15 -0
- package/package.json +41 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AAEvB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAAoF,CAAC;AAE/G,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.GeoJSONSchema = void 0;
|
|
18
|
+
var feature_1 = require("./feature");
|
|
19
|
+
var feature_collection_1 = require("./feature_collection");
|
|
20
|
+
var geometry_1 = require("./geometry");
|
|
21
|
+
__exportStar(require("./feature"), exports);
|
|
22
|
+
__exportStar(require("./feature_collection"), exports);
|
|
23
|
+
__exportStar(require("./geometry"), exports);
|
|
24
|
+
__exportStar(require("./bbox"), exports);
|
|
25
|
+
__exportStar(require("./position"), exports);
|
|
26
|
+
__exportStar(require("./type"), exports);
|
|
27
|
+
exports.GeoJSONSchema = geometry_1.GeoJSONGeometrySchema.or(feature_1.GeoJSONFeatureSchema).or(feature_collection_1.GeoJSONFeatureCollectionSchema);
|
|
28
|
+
// TODO: Performance testing & optimisation (replace callback iterators with for loops?)
|
|
29
|
+
// TODO: Compare performance with and without refinements
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../src/position.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,YAAY,GAAa,CAAC;AAIvC,eAAO,MAAM,qBAAqB,iCAAwC,CAAC;AAC3E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
package/lib/position.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GeoJSONPositionSchema = exports.MIN_POSITION = void 0;
|
|
4
|
+
var zod_1 = require("zod");
|
|
5
|
+
exports.MIN_POSITION = 2;
|
|
6
|
+
// GeoJSON positions and coordinates (see 3.1.1)
|
|
7
|
+
// Array: [longitude/easting, latitude/northing, altitude (optional), ...extra elements are unspecified and ambiguous]
|
|
8
|
+
exports.GeoJSONPositionSchema = zod_1.z.array(zod_1.z.number()).min(exports.MIN_POSITION);
|
package/lib/type.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const GeoJSONGeometryTypeSchema: z.ZodEnum<["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", "GeometryCollection"]>;
|
|
3
|
+
export type GeoJSONGeometryType = z.infer<typeof GeoJSONGeometryTypeSchema>;
|
|
4
|
+
export declare const GeoJSONTypeSchema: z.ZodUnion<[z.ZodEnum<["Feature", "FeatureCollection"]>, z.ZodEnum<["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", "GeometryCollection"]>]>;
|
|
5
|
+
export type GeoJSONType = z.infer<typeof GeoJSONTypeSchema>;
|
|
6
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,yBAAyB,sHAQpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,iBAAiB,iLAAyE,CAAC;AAExG,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
package/lib/type.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GeoJSONTypeSchema = exports.GeoJSONGeometryTypeSchema = void 0;
|
|
4
|
+
// GeoJSON types and Geometry type (see 1.4)
|
|
5
|
+
var zod_1 = require("zod");
|
|
6
|
+
exports.GeoJSONGeometryTypeSchema = zod_1.z.enum([
|
|
7
|
+
"Point",
|
|
8
|
+
"MultiPoint",
|
|
9
|
+
"LineString",
|
|
10
|
+
"MultiLineString",
|
|
11
|
+
"Polygon",
|
|
12
|
+
"MultiPolygon",
|
|
13
|
+
"GeometryCollection",
|
|
14
|
+
]);
|
|
15
|
+
exports.GeoJSONTypeSchema = zod_1.z.enum(["Feature", "FeatureCollection"]).or(exports.GeoJSONGeometryTypeSchema);
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zod-geojson",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Zod schemas for GeoJSON",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/reilem/zod-geojson"
|
|
8
|
+
},
|
|
9
|
+
"author": "Reinert Lemmens",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"zod",
|
|
13
|
+
"geojson",
|
|
14
|
+
"schema",
|
|
15
|
+
"validation"
|
|
16
|
+
],
|
|
17
|
+
"main": "lib/index.js",
|
|
18
|
+
"types": "lib/index.d.ts",
|
|
19
|
+
"packageManager": "pnpm@8.10.4",
|
|
20
|
+
"files": [
|
|
21
|
+
"lib",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@jest/globals": "^29.7.0",
|
|
27
|
+
"jest": "^29.7.0",
|
|
28
|
+
"prettier": "^3.2.5",
|
|
29
|
+
"rimraf": "^5.0.5",
|
|
30
|
+
"ts-jest": "^29.1.2",
|
|
31
|
+
"typescript": "~5.3.3",
|
|
32
|
+
"zod": "^3.22.4"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"test": "jest",
|
|
36
|
+
"clean": "rimraf lib",
|
|
37
|
+
"build": "pnpm clean && tsc -p tsconfig.build.json",
|
|
38
|
+
"typecheck": "tsc",
|
|
39
|
+
"prettiercheck": "prettier -c ."
|
|
40
|
+
}
|
|
41
|
+
}
|