UNPKG

@prismicio/mock

Version:

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

26 lines (25 loc) 935 B
import { capitalCase, snakeCase } from "../lib/changeCase.js"; import { createFaker } from "../lib/createFaker.js"; //#region src/model/customType.ts 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.id) 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 }; }; //#endregion export { customType }; //# sourceMappingURL=customType.js.map