1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.plugin = void 0;
|
4 | const config_js_1 = require("./config.js");
|
5 | const plugin = async (schema, documents, config) => {
|
6 | const placement = config.placement || 'prepend';
|
7 | const { content } = config;
|
8 | if (!config_js_1.VALID_PLACEMENTS.includes(placement)) {
|
9 | throw Error(`Configuration provided for 'add' plugin is invalid: value of 'placement' field is not valid (valid values are: ${config_js_1.VALID_PLACEMENTS.join(', ')})`);
|
10 | }
|
11 | if (!content) {
|
12 | throw Error(`Configuration provided for 'add' plugin is invalid: "content" is missing!`);
|
13 | }
|
14 | return {
|
15 | content: null,
|
16 | [placement]: Array.isArray(content) ? content : [content],
|
17 | };
|
18 | };
|
19 | exports.plugin = plugin;
|
20 | exports.default = { plugin: exports.plugin };
|