UNPKG

@prismicio/mock

Version:

Generate mock Prismic documents, fields, Slices, and models for development and testing environments

32 lines (31 loc) 1.1 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const changeCase = require("../lib/changeCase.cjs"); const createFaker = require("../lib/createFaker.cjs"); const customType = (config) => { const faker = config.faker || createFaker.createFaker(config.seed); let label = config.label || changeCase.capitalCase(faker.words(faker.range(1, 2))); let id = config.id || changeCase.snakeCase(label); if (config.id && !config.label) { label = changeCase.capitalCase(config.id); } else if (config.label && !config.label) { id = changeCase.snakeCase(config.label); } const format = config.format ?? faker.randomElement(["page", "custom"]); let json = {}; if ("fields" in config && config.fields) { json = { Main: config.fields }; } else if ("tabs" in config && config.tabs) { json = config.tabs; } return { id, label, status: config.status ?? faker.boolean(), repeatable: config.repeatable ?? faker.boolean(), format, json }; }; exports.customType = customType; //# sourceMappingURL=customType.cjs.map