UNPKG

@scriptables/manifest

Version:

Utilities to generate, parse, and update manifest headers in Scriptable scripts.

42 lines (41 loc) 1.74 kB
import { SCRIPTABLE_MANIFEST_KEYS } from "./types.js"; function validateManifest(manifest, allowExtraKeys = false) { if (!manifest || typeof manifest !== "object") { throw new Error("Manifest must be an object"); } if (!allowExtraKeys) { const keys = Object.keys(manifest); for (const key of keys) { if (!SCRIPTABLE_MANIFEST_KEYS.includes(key)) { throw new Error(`Invalid manifest key: ${key}`); } } } const typedManifest = manifest; if (typedManifest.alwaysRunInApp !== void 0 && typeof typedManifest.alwaysRunInApp !== "boolean") { throw new Error("alwaysRunInApp must be a boolean"); } if (typedManifest.name !== void 0 && typeof typedManifest.name !== "string") { throw new Error("name must be a string"); } if (typedManifest.iconColor !== void 0 && typeof typedManifest.iconColor !== "string") { throw new Error("iconColor must be a string"); } if (typedManifest.iconGlyph !== void 0 && typeof typedManifest.iconGlyph !== "string") { throw new Error("iconGlyph must be a string"); } if (typedManifest.shareSheetInputs !== void 0) { if (!Array.isArray(typedManifest.shareSheetInputs)) { throw new Error("shareSheetInputs must be an array"); } const validInputs = ["file-url", "url", "image", "plain-text"]; for (const input of typedManifest.shareSheetInputs) { if (!validInputs.includes(input)) { throw new Error(`Invalid share sheet input: ${input}`); } } } } export { validateManifest }; //# sourceMappingURL=validateManifest.js.map //# sourceMappingURL=validateManifest.js.map