/** * Checks if a specificied source is a valid arion-compose.nix file * @param {string} source Source to check * @returns {Promise} Result of the check */ export async function check_compose(source) { const response = await fetch("/stack/_/check", { method: "POST", headers: { "Accept": "application/json", "Content-Type": "text/plain", }, body: source }); if (response.ok) { return { ok: true }; } else { return { ok: false, error: await response.json() }; } } /** * @typedef {Object} APIError * @property {string} code - Error code */ /** * @typedef {Object} CheckSuccess * @property { true } ok - Indicates that the check was successful * / /** * @typedef {Object} APIError * @property {string} code - Unique error code * @property {string} message - Human readable error details */ /** * @typedef {Object} CheckFailure * @property {false} ok - Indicates that the check has failed * @property {APIError} error - Info about the encountered error */ /** * @typedef {CheckSuccess | CheckFailure} CheckResult */