From 6bfc6e995875c9169f27b6caa74c3e5a4d511549 Mon Sep 17 00:00:00 2001 From: ctot-nondef Date: Fri, 18 Oct 2024 16:41:21 +0200 Subject: [PATCH] fix: geojson schemas in declaration file --- composables/use-geojson.ts | 3 ++- types/geojson.ts | 20 ++++++++++++++++++++ types/global.d.ts | 20 ++------------------ 3 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 types/geojson.ts diff --git a/composables/use-geojson.ts b/composables/use-geojson.ts index b66a854..cf4d253 100644 --- a/composables/use-geojson.ts +++ b/composables/use-geojson.ts @@ -1,6 +1,7 @@ import { useQuery } from "@tanstack/vue-query"; -import { type FeatureCollectionType, GeoFeatureSchema } from "@/types/global.d.ts"; +import { GeoFeatureSchema } from "@/types/geojson"; +import type { FeatureCollectionType } from "@/types/global.d.ts"; export function useGeojson(options?: { enabled?: boolean }) { const api = useApiClient(); diff --git a/types/geojson.ts b/types/geojson.ts new file mode 100644 index 0000000..7646c1c --- /dev/null +++ b/types/geojson.ts @@ -0,0 +1,20 @@ +import { z } from "zod"; + +export const GeoFeatureSchema = z.object({ + type: z.literal("Feature"), + id: z.string(), + geometry: z.object({ + type: z.literal("Point"), + coordinates: z.array(z.number()), + }), + properties: z.any(), +}); + +export const FeatureCollectionSchema = z.object({ + type: z.literal("FeatureCollection"), + properties: z.object({ + name: z.string(), + column_headings: z.array(z.any()), + }), + features: z.array(GeoFeatureSchema), +}); diff --git a/types/global.d.ts b/types/global.d.ts index b850644..7aac61c 100644 --- a/types/global.d.ts +++ b/types/global.d.ts @@ -1,6 +1,8 @@ import type { Ref } from "vue"; import { z } from "zod"; +import type { FeatureCollectionSchema, GeoFeatureSchema } from "@/types/geojson"; + type MaybeRef = Ref | T; export const DataTypesEnum = z.enum(["Profile", "Text", "SampleText", "Feature", "CorpusText"]); @@ -246,25 +248,7 @@ export type WindowItemMap = { [TargetType in WindowItemTargetType]: Extract; }; -export const GeoFeatureSchema = z.object({ - type: z.literal("Feature"), - id: z.string(), - geometry: z.object({ - type: z.literal("Point"), - coordinates: z.array(z.number()), - }), - properties: z.any(), -}); export type FeatureType = z.infer; - -export const FeatureCollectionSchema = z.object({ - type: z.literal("FeatureCollection"), - properties: z.object({ - name: z.string(), - column_headings: z.array(z.any()), - }), - features: z.array(GeoFeatureSchema), -}); export type FeatureCollectionType = z.infer; export interface VicavHTTPError extends Error {