UNPKG

@seasketch/geoprocessing

Version:

Geoprocessing and reporting framework for SeaSketch 2.0

83 lines (82 loc) 3.01 kB
import { JSONValue } from "./base.js"; import { MetricProperties } from "../metrics/helpers.js"; import { z } from "zod"; /** Dimensions used in Metric */ export declare const MetricDimensions: readonly ["metricId", "geographyId", "sketchId", "groupId", "classId"]; export type MetricDimension = (typeof MetricDimensions)[number] & keyof Metric; export declare const metricSchema: z.ZodObject<{ metricId: z.ZodString; value: z.ZodNumber; extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JSONValue, z.ZodTypeDef, JSONValue>>>; classId: z.ZodNullable<z.ZodString>; groupId: z.ZodNullable<z.ZodString>; geographyId: z.ZodNullable<z.ZodString>; sketchId: z.ZodNullable<z.ZodString>; }, "strip", z.ZodTypeAny, { value: number; classId: string | null; metricId: string; geographyId: string | null; sketchId: string | null; groupId: string | null; extra?: Record<string, JSONValue> | undefined; }, { value: number; classId: string | null; metricId: string; geographyId: string | null; sketchId: string | null; groupId: string | null; extra?: Record<string, JSONValue> | undefined; }>; export declare const metricsSchema: z.ZodArray<z.ZodObject<{ metricId: z.ZodString; value: z.ZodNumber; extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JSONValue, z.ZodTypeDef, JSONValue>>>; classId: z.ZodNullable<z.ZodString>; groupId: z.ZodNullable<z.ZodString>; geographyId: z.ZodNullable<z.ZodString>; sketchId: z.ZodNullable<z.ZodString>; }, "strip", z.ZodTypeAny, { value: number; classId: string | null; metricId: string; geographyId: string | null; sketchId: string | null; groupId: string | null; extra?: Record<string, JSONValue> | undefined; }, { value: number; classId: string | null; metricId: string; geographyId: string | null; sketchId: string | null; groupId: string | null; extra?: Record<string, JSONValue> | undefined; }>, "many">; /** * Single record of value, stratified in one or more dimensions. * The name Metric is an overgeneralization, you can think of it as a MetricValue. */ export type Metric = z.infer<typeof metricSchema>; export type Metrics = z.infer<typeof metricSchema>; /** Alternative JSON format for metrics data that is smaller in size, better suited for blob storage and network transport */ export interface MetricPack { dimensions: string[]; data: (string | number | boolean | JSONValue)[][]; } /** * Single flattened metric with class values keyed by class name * Useful for rendering table rows with the values of multiple classes for a group */ export type GroupMetricAgg = { groupId: string; value: number; percValue: number; [className: string]: string | number; }; export type GroupMetricSketchAgg = GroupMetricAgg & { sketchId: string; }; export type MetricIdTypes = string | number; export type MetricProperty = (typeof MetricProperties)[number] & keyof Metric;