export type PointGeoJSON = {type: 'Point', coordinates: Array}; export type MultipointGeoJSON = {type: 'MultiPoint', coordinates: Array>}; export type LinestringGeoJSON = {type: 'LineString', coordinates: Array>}; export type MultilinestringGeoJSON = {type: 'MultiLineString', coordinates: Array>>}; export type PolygonGeoJSON = {type: 'Polygon', coordinates: Array>>}; export type MultipolygonGeoJSON = {type: 'MultiPolygon', coordinates: Array>>>}; export type GeometrycollectionGeoJSON = {type: 'GeometryCollection', geometries: Array}; export type GeometryGeoJSON = PointGeoJSON | MultipointGeoJSON | LinestringGeoJSON | MultilinestringGeoJSON | PolygonGeoJSON | MultipolygonGeoJSON | GeometrycollectionGeoJSON; export type Link = {href: string, rel?: string | undefined, type?: string | undefined, hreflang?: string | undefined, title?: string | undefined, length?: number | undefined}; export type FeatureGeoJSON = {type: 'Feature', geometry: GeometryGeoJSON, properties: Record | null, id?: (string | number) | undefined, links?: Array | undefined}; export type TimeStamp = string; export type NumberMatched = number; export type NumberReturned = number; export type FeatureCollectionGeoJSON = {type: 'FeatureCollection', features: Array, links?: Array | undefined, timeStamp?: TimeStamp | undefined, numberMatched?: NumberMatched | undefined, numberReturned?: NumberReturned | undefined}; export type CreateApiCollectionsValidateArgs = {body: FeatureGeoJSON | FeatureCollectionGeoJSON}; export type CreateApiCollectionsValidateOptions = {baseUrl?: string | undefined, JWT?: string | undefined, fetch?: typeof fetch | undefined}; /** * Validate Feature * * POST /collections/validate * * Also accepts auth: BasicAuth */ export const createApiCollectionsValidate = async (args: CreateApiCollectionsValidateArgs, options?: CreateApiCollectionsValidateOptions) => { const {baseUrl = "https://api.planet.com/features/v1/ogc/my", fetch: fetchFn = fetch, JWT} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (JWT !== undefined) headers.set('authorization', `Bearer ${JWT}`) const url = `${baseUrl.replace(/\/+$/, '')}/collections/validate${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };