Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 51x 51x 783x 9396x 9396x 9396x 9396x 9396x 9396x 9396x 9396x 9396x 783x 783x 51x | 'use strict';
module.exports = ({ definitions }) => {
const queries = definitions.map(({ name, relativePath, value: query }) => {
if (!/^[a-z]+(?:-[a-z]+)*\.js$/u.test(relativePath)) {
throw new TypeError(`Query definition must be directly inside list-definitions: ${relativePath}`);
}
if (typeof query.inputSchema?.safeParse !== 'function' ||
!query.inputSchema.shape || typeof query.inputSchema.shape !== 'object' ||
typeof query.execute !== 'function' || query.execute.length !== 3) {
throw new TypeError(`${relativePath} must expose inputSchema and execute(database, options, caches)`);
}
return Object.freeze({
inputSchema: query.inputSchema,
execute: query.execute,
name,
});
});
return { definitions: Object.freeze(queries) };
};
|