-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove barrel files + export only relevant schemas & types
- Loading branch information
Showing
5 changed files
with
154 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { z } from "zod"; | ||
import { GeoJSONFeatureGenericSchema } from "./feature"; | ||
import { GeoJSONFeatureCollectionGenericSchema } from "./feature_collection"; | ||
import { GeoJSONGeometryGenericSchema } from "./geometry/geometry"; | ||
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "./position"; | ||
|
||
export const GeoJSONGenericSchema = <P extends GeoJSONPosition>(positionSchema: z.ZodSchema<P>) => | ||
z.union([ | ||
GeoJSONGeometryGenericSchema(positionSchema), | ||
GeoJSONFeatureGenericSchema(positionSchema), | ||
GeoJSONFeatureCollectionGenericSchema(positionSchema), | ||
]); | ||
|
||
export const GeoJSONSchema = GeoJSONGenericSchema(GeoJSONPositionSchema); | ||
export type GeoJSON = z.infer<typeof GeoJSONSchema>; | ||
|
||
export const GeoJSON2DSchema = GeoJSONGenericSchema(GeoJSON2DPositionSchema); | ||
export type GeoJSON2D = z.infer<typeof GeoJSON2DSchema>; | ||
|
||
export const GeoJSON3DSchema = GeoJSONGenericSchema(GeoJSON3DPositionSchema); | ||
export type GeoJSON3D = z.infer<typeof GeoJSON3DSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,132 @@ | ||
// Derived from the GeoJSON spec: https://datatracker.ietf.org/doc/html/rfc7946 | ||
import { z } from "zod"; | ||
import { GeoJSONFeatureGenericSchema } from "./feature"; | ||
import { GeoJSONFeatureCollectionGenericSchema } from "./feature_collection"; | ||
import { GeoJSONGeometryGenericSchema } from "./geometry"; | ||
import { GeoJSON2DPositionSchema, GeoJSON3DPositionSchema, GeoJSONPosition, GeoJSONPositionSchema } from "./position"; | ||
|
||
export * from "./feature"; | ||
export * from "./feature_collection"; | ||
export * from "./geometry"; | ||
export * from "./bbox"; | ||
export * from "./position"; | ||
export * from "./type"; | ||
|
||
export const GeoJSONGenericSchema = <P extends GeoJSONPosition>(positionSchema: z.ZodSchema<P>) => | ||
z.union([ | ||
GeoJSONGeometryGenericSchema(positionSchema), | ||
GeoJSONFeatureGenericSchema(positionSchema), | ||
GeoJSONFeatureCollectionGenericSchema(positionSchema), | ||
]); | ||
|
||
export const GeoJSONSchema = GeoJSONGenericSchema(GeoJSONPositionSchema); | ||
export type GeoJSON = z.infer<typeof GeoJSONSchema>; | ||
|
||
export const GeoJSON2DSchema = GeoJSONGenericSchema(GeoJSON2DPositionSchema); | ||
export type GeoJSON2D = z.infer<typeof GeoJSON2DSchema>; | ||
|
||
export const GeoJSON3DSchema = GeoJSONGenericSchema(GeoJSON3DPositionSchema); | ||
export type GeoJSON3D = z.infer<typeof GeoJSON3DSchema>; | ||
|
||
// TODO: Do not expose every single schema & inner type, only the useful ones | ||
// TODO: Add negative typing examples for all types (like with point) | ||
// TODO: Add negative typing examples for all types (like in point tests) | ||
// TODO: Make sure each exposed type & schema is tested | ||
|
||
export { | ||
GeoJSONGeometryTypeSchema, | ||
type GeoJSONGeometryEnumType, | ||
type GeoJSONGeometryType, | ||
} from "./geometry/helper/type"; | ||
|
||
export { | ||
GeoJSONGeometryGenericSchema, | ||
GeoJSONGeometrySchema, | ||
type GeoJSONGeometry, | ||
GeoJSON2DGeometrySchema, | ||
type GeoJSON2DGeometry, | ||
GeoJSON3DGeometrySchema, | ||
type GeoJSON3DGeometry, | ||
} from "./geometry/geometry"; | ||
|
||
export { | ||
GeoJSONGeometryCollectionGenericSchema, | ||
GeoJSONGeometryCollectionSchema, | ||
type GeoJSONGeometryCollection, | ||
GeoJSON2DGeometryCollectionSchema, | ||
type GeoJSON2DGeometryCollection, | ||
GeoJSON3DGeometryCollectionSchema, | ||
type GeoJSON3DGeometryCollection, | ||
} from "./geometry/geometry_collection"; | ||
|
||
export { | ||
GeoJSONLineStringGenericSchema, | ||
GeoJSONLineStringSchema, | ||
type GeoJSONLineString, | ||
GeoJSON2DLineStringSchema, | ||
type GeoJSON2DLineString, | ||
GeoJSON3DLineStringSchema, | ||
type GeoJSON3DLineString, | ||
} from "./geometry/line_string"; | ||
|
||
export { | ||
GeoJSONMultiLineStringGenericSchema, | ||
GeoJSONMultiLineStringSchema, | ||
type GeoJSONMultiLineString, | ||
GeoJSON2DMultiLineStringSchema, | ||
type GeoJSON2DMultiLineString, | ||
GeoJSON3DMultiLineStringSchema, | ||
type GeoJSON3DMultiLineString, | ||
} from "./geometry/multi_line_string"; | ||
|
||
export { | ||
GeoJSONMultiPointGenericSchema, | ||
GeoJSONMultiPointSchema, | ||
type GeoJSONMultiPoint, | ||
GeoJSON2DMultiPointSchema, | ||
type GeoJSON2DMultiPoint, | ||
GeoJSON3DMultiPointSchema, | ||
type GeoJSON3DMultiPoint, | ||
} from "./geometry/multi_point"; | ||
|
||
export { | ||
GeoJSONMultiPolygonGenericSchema, | ||
GeoJSONMultiPolygonSchema, | ||
type GeoJSONMultiPolygon, | ||
GeoJSON2DMultiPolygonSchema, | ||
type GeoJSON2DMultiPolygon, | ||
GeoJSON3DMultiPolygonSchema, | ||
type GeoJSON3DMultiPolygon, | ||
} from "./geometry/multi_polygon"; | ||
|
||
export { | ||
GeoJSONPointGenericSchema, | ||
GeoJSONPointSchema, | ||
type GeoJSONPoint, | ||
GeoJSON2DPointSchema, | ||
type GeoJSON2DPoint, | ||
GeoJSON3DPointSchema, | ||
type GeoJSON3DPoint, | ||
} from "./geometry/point"; | ||
|
||
export { | ||
GeoJSONPolygonGenericSchema, | ||
GeoJSONPolygonSchema, | ||
type GeoJSONPolygon, | ||
GeoJSON2DPolygonSchema, | ||
type GeoJSON2DPolygon, | ||
GeoJSON3DPolygonSchema, | ||
type GeoJSON3DPolygon, | ||
} from "./geometry/polygon"; | ||
|
||
export { GeoJSONBboxSchema, type GeoJSONBbox } from "./bbox"; | ||
|
||
export { | ||
GeoJSONFeatureGenericSchema, | ||
GeoJSONFeatureSchema, | ||
type GeoJSONFeature, | ||
GeoJSON2DFeatureSchema, | ||
type GeoJSON2DFeature, | ||
GeoJSON3DFeatureSchema, | ||
type GeoJSON3DFeature, | ||
} from "./feature"; | ||
|
||
export { | ||
GeoJSONFeatureCollectionGenericSchema, | ||
GeoJSONFeatureCollectionSchema, | ||
type GeoJSONFeatureCollection, | ||
GeoJSON2DFeatureCollectionSchema, | ||
type GeoJSON2DFeatureCollection, | ||
GeoJSON3DFeatureCollectionSchema, | ||
type GeoJSON3DFeatureCollection, | ||
} from "./feature_collection"; | ||
|
||
export { | ||
GeoJSONGenericSchema, | ||
GeoJSONSchema, | ||
type GeoJSON, | ||
GeoJSON2DSchema, | ||
type GeoJSON2D, | ||
GeoJSON3DSchema, | ||
type GeoJSON3D, | ||
} from "./geojson"; | ||
|
||
export { | ||
GeoJSONPositionSchema, | ||
type GeoJSONPosition, | ||
GeoJSON2DPositionSchema, | ||
type GeoJSON2DPosition, | ||
GeoJSON3DPositionSchema, | ||
type GeoJSON3DPosition, | ||
} from "./position"; | ||
|
||
export { GeoJSONTypeSchema, type GeoJSONType } from "./type"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters