@digitraffic/common 2025.9.26-1 → 2025.10.16-2
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/dist/types/geojson.d.ts +47 -0
- package/dist/types/geojson.js +51 -0
- package/package.json +2 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const CoordinatesSchema: z.ZodArray<z.ZodNumber>;
|
|
3
|
+
export declare const PointSchema: z.ZodObject<{
|
|
4
|
+
type: z.ZodLiteral<"Point">;
|
|
5
|
+
coordinates: z.ZodArray<z.ZodNumber>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export declare const MultiPointSchema: z.ZodObject<{
|
|
8
|
+
type: z.ZodLiteral<"MultiPoint">;
|
|
9
|
+
coordinates: z.ZodArray<z.ZodArray<z.ZodNumber>>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export declare const LineStringSchema: z.ZodObject<{
|
|
12
|
+
type: z.ZodLiteral<"LineString">;
|
|
13
|
+
coordinates: z.ZodArray<z.ZodArray<z.ZodNumber>>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export declare const MultiLineStringSchema: z.ZodObject<{
|
|
16
|
+
type: z.ZodLiteral<"MultiLineString">;
|
|
17
|
+
coordinates: z.ZodArray<z.ZodArray<z.ZodArray<z.ZodNumber>>>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export declare const PolygonSchema: z.ZodObject<{
|
|
20
|
+
type: z.ZodLiteral<"Polygon">;
|
|
21
|
+
coordinates: z.ZodArray<z.ZodArray<z.ZodArray<z.ZodNumber>>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export declare const MultiPolygonSchema: z.ZodObject<{
|
|
24
|
+
type: z.ZodLiteral<"MultiPolygon">;
|
|
25
|
+
coordinates: z.ZodArray<z.ZodArray<z.ZodArray<z.ZodArray<z.ZodNumber>>>>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type Point = z.infer<typeof PointSchema>;
|
|
28
|
+
export type Geometry = z.infer<typeof PointSchema> | z.infer<typeof MultiPointSchema> | z.infer<typeof LineStringSchema> | z.infer<typeof MultiLineStringSchema> | z.infer<typeof PolygonSchema> | z.infer<typeof MultiPolygonSchema> | {
|
|
29
|
+
type: "GeometryCollection";
|
|
30
|
+
geometries: Geometry[];
|
|
31
|
+
};
|
|
32
|
+
export declare const GeometrySchema: z.ZodType<Geometry>;
|
|
33
|
+
export declare const FeatureSchema: z.ZodObject<{
|
|
34
|
+
type: z.ZodLiteral<"Feature">;
|
|
35
|
+
geometry: z.ZodType<Geometry, unknown, z.core.$ZodTypeInternals<Geometry, unknown>>;
|
|
36
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
37
|
+
id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
export declare const FeatureCollectionSchema: z.ZodObject<{
|
|
40
|
+
type: z.ZodLiteral<"FeatureCollection">;
|
|
41
|
+
features: z.ZodArray<z.ZodObject<{
|
|
42
|
+
type: z.ZodLiteral<"Feature">;
|
|
43
|
+
geometry: z.ZodType<Geometry, unknown, z.core.$ZodTypeInternals<Geometry, unknown>>;
|
|
44
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
45
|
+
id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const CoordinatesSchema = z.array(z.number()).min(2).max(3);
|
|
3
|
+
export const PointSchema = z.object({
|
|
4
|
+
type: z.literal("Point"),
|
|
5
|
+
coordinates: CoordinatesSchema,
|
|
6
|
+
});
|
|
7
|
+
export const MultiPointSchema = z.object({
|
|
8
|
+
type: z.literal("MultiPoint"),
|
|
9
|
+
coordinates: z.array(CoordinatesSchema),
|
|
10
|
+
});
|
|
11
|
+
export const LineStringSchema = z.object({
|
|
12
|
+
type: z.literal("LineString"),
|
|
13
|
+
coordinates: z.array(CoordinatesSchema).min(2),
|
|
14
|
+
});
|
|
15
|
+
export const MultiLineStringSchema = z.object({
|
|
16
|
+
type: z.literal("MultiLineString"),
|
|
17
|
+
coordinates: z.array(z.array(CoordinatesSchema).min(2)),
|
|
18
|
+
});
|
|
19
|
+
export const PolygonSchema = z.object({
|
|
20
|
+
type: z.literal("Polygon"),
|
|
21
|
+
coordinates: z.array(z.array(CoordinatesSchema).min(4)),
|
|
22
|
+
});
|
|
23
|
+
export const MultiPolygonSchema = z.object({
|
|
24
|
+
type: z.literal("MultiPolygon"),
|
|
25
|
+
coordinates: z.array(z.array(z.array(CoordinatesSchema).min(4))),
|
|
26
|
+
});
|
|
27
|
+
// --- Recursive GeometrySchema ---
|
|
28
|
+
export const GeometrySchema = z.lazy(() => z.union([
|
|
29
|
+
PointSchema,
|
|
30
|
+
MultiPointSchema,
|
|
31
|
+
LineStringSchema,
|
|
32
|
+
MultiLineStringSchema,
|
|
33
|
+
PolygonSchema,
|
|
34
|
+
MultiPolygonSchema,
|
|
35
|
+
// GeometryCollection is recursive, so we need to use z.lazy
|
|
36
|
+
z.object({
|
|
37
|
+
type: z.literal("GeometryCollection"),
|
|
38
|
+
geometries: z.array(GeometrySchema),
|
|
39
|
+
}),
|
|
40
|
+
]));
|
|
41
|
+
export const FeatureSchema = z.object({
|
|
42
|
+
type: z.literal("Feature"),
|
|
43
|
+
geometry: GeometrySchema,
|
|
44
|
+
properties: z.record(z.string(), z.any()).optional(),
|
|
45
|
+
id: z.union([z.string(), z.number()]).optional(),
|
|
46
|
+
});
|
|
47
|
+
export const FeatureCollectionSchema = z.object({
|
|
48
|
+
type: z.literal("FeatureCollection"),
|
|
49
|
+
features: z.array(FeatureSchema),
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=geojson.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitraffic/common",
|
|
3
|
-
"version": "2025.
|
|
3
|
+
"version": "2025.10.16-2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"./dist/database/cached": "./dist/database/cached.js",
|
|
23
23
|
"./dist/database/models": "./dist/database/models.js",
|
|
24
24
|
"./dist/database/last-updated": "./dist/database/last-updated.js",
|
|
25
|
+
"./dist/types/geojson": "./dist/types/geojson.js",
|
|
25
26
|
"./dist/types/urn": "./dist/types/urn.js",
|
|
26
27
|
"./dist/types/util-types": "./dist/types/util-types.js",
|
|
27
28
|
"./dist/types/either": "./dist/types/either.js",
|