import type * as prismic from "@prismicio/client" import { createFaker, type Faker } from "../lib/createFaker" import type { GroupFieldModelMap, NestedGroupFieldModelMap, Seed, SlicePrimaryFieldModelMap, WithoutFakerConfig, } from "../types" import { boolean, type MockBooleanModelConfig } from "./boolean" import { buildMockGroupFieldMap, type BuildMockGroupFieldMapConfig } from "./buildMockGroupFieldMap" import { color, type MockColorModelConfig } from "./color" import { contentRelationship, type MockContentRelationshipModelConfig } from "./contentRelationship" import { customType, type MockCustomTypeModelConfig } from "./customType" import { date, type MockDateModelConfig } from "./date" import { embed, type MockEmbedModelConfig } from "./embed" import { geoPoint, type MockGeoPointModelConfig } from "./geoPoint" import { group, type MockGroupModelConfig } from "./group" import { image, type MockImageModelConfig } from "./image" import { integration, type MockIntegrationFieldModelConfig } from "./integration" import { keyText, type MockKeyTextModelConfig } from "./keyText" import { link, type MockLinkModelConfig } from "./link" import { linkToMedia, type MockLinkToMediaModelConfig } from "./linkToMedia" import { number, type MockNumberModelConfig } from "./number" import { richText, type MockRichTextModelConfig } from "./richText" import { select, type MockSelectModelConfig } from "./select" import { sharedSlice, type MockSharedSliceModelConfig } from "./sharedSlice" import { sharedSliceChoice } from "./sharedSliceChoice" import { sharedSliceVariation, type MockSharedSliceVariationModelConfig, } from "./sharedSliceVariation" import { slice, type MockSliceModelConfig } from "./slice" import { sliceZone, type MockSliceZoneModelConfig } from "./sliceZone" import { type MockTableModelConfig, table } from "./table" import { timestamp, type MockTimestampModelConfig } from "./timestamp" import { title, type MockTitleModelConfig } from "./title" import { uid, type MockUIDModelConfig } from "./uid" export const createModelMockFactory = ( ...args: ConstructorParameters ): ModelMockFactory => { return new ModelMockFactory(...args) } type ModelMockFactoryConfig = | { seed: Seed } | { faker: Faker } export class ModelMockFactory { private faker: Faker constructor(config: ModelMockFactoryConfig) { this.faker = "faker" in config ? config.faker : createFaker(config.seed) } get seed(): Seed { return this.faker.seed } buildMockGroupFieldMap( config?: WithoutFakerConfig, ): NestedGroupFieldModelMap { return buildMockGroupFieldMap({ ...config, faker: this.faker }) } boolean( config?: WithoutFakerConfig, ): prismic.CustomTypeModelBooleanField { return boolean({ ...config, faker: this.faker }) } color(config?: WithoutFakerConfig): prismic.CustomTypeModelColorField { return color({ ...config, faker: this.faker }) } contentRelationship( config?: WithoutFakerConfig>, ): prismic.CustomTypeModelContentRelationshipField { return contentRelationship({ ...config, faker: this.faker }) } customType( config?: WithoutFakerConfig>, ): ReturnType> { return customType({ ...config, faker: this.faker }) } date(config?: WithoutFakerConfig): prismic.CustomTypeModelDateField { return date({ ...config, faker: this.faker }) } embed(config?: WithoutFakerConfig): prismic.CustomTypeModelEmbedField { return embed({ ...config, faker: this.faker }) } geoPoint( config?: WithoutFakerConfig, ): prismic.CustomTypeModelGeoPointField { return geoPoint({ ...config, faker: this.faker }) } group( config?: WithoutFakerConfig>, ): prismic.CustomTypeModelGroupField { return group({ ...config, faker: this.faker }) } image( config?: WithoutFakerConfig>, ): prismic.CustomTypeModelImageField { return image({ ...config, faker: this.faker }) } integration( config?: WithoutFakerConfig, ): prismic.CustomTypeModelIntegrationField { return integration({ ...config, faker: this.faker }) } keyText( config?: WithoutFakerConfig, ): prismic.CustomTypeModelKeyTextField { return keyText({ ...config, faker: this.faker }) } link( config?: WithoutFakerConfig>, ): ReturnType> { return link({ ...config, faker: this.faker }) } linkToMedia( config?: WithoutFakerConfig, ): ReturnType { return linkToMedia({ ...config, faker: this.faker }) } number(config?: WithoutFakerConfig): prismic.CustomTypeModelNumberField { return number({ ...config, faker: this.faker }) } richText( config?: WithoutFakerConfig>, ): ReturnType> { return richText({ ...config, faker: this.faker }) } select