@seasketch/geoprocessing
Version:
Geoprocessing and reporting framework for SeaSketch 2.0
41 lines • 1.8 kB
JavaScript
import { hasOwnProperty } from "../src/index.js";
//// Helpers ////
/** Returns true if manifest contains clients */
export const hasClients = (manifest) => {
return manifest.clients.length > 0;
};
export const getSyncFunctionMetadata = (manifest) => {
return [
...manifest.preprocessingFunctions,
...manifest.geoprocessingFunctions.filter((func) => func.executionMode === "sync"),
];
};
export const getAsyncFunctionMetadata = (manifest) => {
return manifest.geoprocessingFunctions.filter((func) => func.executionMode === "async" && func.purpose !== "preprocessing");
};
//// Validators ////
/** Returns true if metadata is for geoprocessing function and narrows type */
export const isGeoprocessingFunctionMetadata = (meta) => {
return (meta &&
hasOwnProperty(meta, "purpose") &&
meta.purpose === "geoprocessing" &&
hasOwnProperty(meta, "executionMode") &&
(meta.executionMode === "async" || meta.executionMode === "sync"));
};
/** Returns true if metadata is for preprocessing function and narrows type */
export const isPreprocessingFunctionMetadata = (meta) => {
return (meta &&
hasOwnProperty(meta, "purpose") &&
meta.purpose === "preprocessing" &&
!hasOwnProperty(meta, "executionMode"));
};
/** Returns true if metadata is for sync function and narrows type */
export const isSyncFunctionMetadata = (meta) => {
return (isPreprocessingFunctionMetadata(meta) ||
(isGeoprocessingFunctionMetadata(meta) && meta.executionMode === "sync"));
};
/** Returns true if metadata is for async function and narrows type */
export const isAsyncFunctionMetadata = (meta) => {
return (isGeoprocessingFunctionMetadata(meta) && meta.executionMode === "async");
};
//# sourceMappingURL=manifest.js.map