// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial /** * The declarations of the `spatial` family. * * It holds the family's kinds, its payload types and the hash its artifact embeds. * * Generated by tools/generate.run.ts from data/ir/spatial.json. * Edit the grammar or the generator and not this file. */ import { spatialArtifact } from "#artifacts/spatial.generated" import { defineFamily } from "#family" import type { Validated } from "#types" /** * The family's ID. */ export const SPATIAL_FAMILY_ID = "spatial" /** * The hash of the generated declarations. * * The artifact embeds the same value, and the loader refuses an artifact whose hash differs. */ export const SPATIAL_DECLARATIONS_HASH = "1d85275060cde50d8080e9ae55108ac8210aa146f95766ca6cd16fe8150c4dec" /** * Every kind of recognition the family reports, by name. * Each value is the shape's ID. */ export const SpatialKind = { DigipinCompact: "digipin.compact", DigipinDisplay: "digipin.display", GeoJSONObject: "geojson.object", PlusCodeToken: "plus_code.token", } as const export type SpatialKind = (typeof SpatialKind)[keyof typeof SpatialKind] /** * The validated payload of `digipin.compact`. */ export interface DigipinCompactPayload { readonly code: Validated.Digipin } /** * The code of every rejection a recognition of `digipin.compact` can return. */ export type DigipinCompactRejection = "capture_limit" | "capture_mismatch" | "invalid_character" | "invalid_length" /** * The validated payload of `digipin.display`. */ export interface DigipinDisplayPayload { readonly code: Validated.Digipin } /** * The code of every rejection a recognition of `digipin.display` can return. */ export type DigipinDisplayRejection = "capture_limit" | "capture_mismatch" | "invalid_character" | "invalid_length" /** * The validated payload of `geojson.object`. */ export interface GeoJSONObjectPayload { readonly type: string readonly latitude?: Validated.Latitude readonly longitude?: Validated.Longitude readonly altitude?: Validated.Decimal } /** * The code of every rejection a recognition of `geojson.object` can return. */ export type GeoJSONObjectRejection = | "capture_limit" | "capture_mismatch" | "latitude_out_of_range" | "longitude_out_of_range" | "malformed_json" | "malformed_position" | "misplaced_geojson_type" | "missing_member" | "not_finite" | "unknown_geojson_type" /** * The validated payload of `plus_code.token`. */ export interface PlusCodeTokenPayload { readonly full_code?: Validated.FullPlusCode readonly short_code?: Validated.ShortPlusCode } /** * The code of every rejection a recognition of `plus_code.token` can return. */ export type PlusCodeTokenRejection = | "capture_limit" | "capture_mismatch" | "invalid_digit" | "invalid_prefix_length" | "invalid_suffix_length" /** * The payload of each kind that declares a validator. * A kind with no entry has its span and text only. */ export interface SpatialPayloads { readonly "digipin.compact": DigipinCompactPayload readonly "digipin.display": DigipinDisplayPayload readonly "geojson.object": GeoJSONObjectPayload readonly "plus_code.token": PlusCodeTokenPayload } /** * The rejection codes of each kind that declares a validator. */ export interface SpatialRejections { readonly "digipin.compact": DigipinCompactRejection readonly "digipin.display": DigipinDisplayRejection readonly "geojson.object": GeoJSONObjectRejection readonly "plus_code.token": PlusCodeTokenRejection } /** * The `spatial` family. * * Pass it to `createRecognizer`. * A bundle that imports this module holds this family's artifact and no other, * and no engine until a recognizer is created. */ export const spatial = defineFamily, SpatialRejections>({ id: SPATIAL_FAMILY_ID, kinds: SpatialKind, declarationsHash: SPATIAL_DECLARATIONS_HASH, artifact: spatialArtifact, })