UNPKG

@prismicio/mock

Version:

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

32 lines (31 loc) 952 B
import { capitalCase, snakeCase } from "../lib/changeCase.js"; import { createFaker } from "../lib/createFaker.js"; const customType = (config) => { const faker = config.faker || createFaker(config.seed); let label = config.label || capitalCase(faker.words(faker.range(1, 2))); let id = config.id || snakeCase(label); if (config.id && !config.label) { label = capitalCase(config.id); } else if (config.label && !config.label) { id = 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 }; }; export { customType }; //# sourceMappingURL=customType.js.map