Docyrus

DummyDataGenerator

Inline three-step wizard (Configure → Preview → Result) that generates realistic sample records per field type with a seeded generator, previews them with the value renderers, exports CSV / Excel / JSON / Markdown through the share sheet, and saves them to a data source. API-aligned with the web DummyDataGenerator.

iOSAndroid
Preview DummyDataGenerator on your device

Scan with Expo Go

Download Expo Go, then scan the QR code to preview native components.

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-dummy-data-generator
Required Packages(2 packages)
pnpm add expo-file-system (optional) expo-sharing (optional)

expo-file-system and expo-sharing are optional peers that only the preview step's Export menu uses (through useDataExport). Without them, the export writes nothing.

DummyDataGenerator is the presentational wizard: every piece of state comes in through props, and the generator libs are pure (no React, no fetches). To connect it to a Docyrus data source (schema, generation, batch insert), use useDocyrusDummyDataGeneratorWizard, which returns a ready wizard element.

Usage

import { useState } from 'react';

import {
  DummyDataGenerator,
  buildInitialStrategyMap,
  generateDummyRows,
  type DummyDataGeneratorStep
} from '@/components/docyrus-native/dummy-data-generator';

export function SampleRows({ fields }: { fields: DocyrusFieldLike[] }) {
  const [step, setStep] = useState<DummyDataGeneratorStep>('configure');
  const [count, setCount] = useState(20);
  const [strategies, setStrategies] = useState(() => buildInitialStrategyMap(fields));
  const [rows, setRows] = useState<Array<Record<string, unknown>>>([]);

  const generate = (seed = Date.now()) => setRows(generateDummyRows({ fields, strategies, count, seed }));

  return (
    <DummyDataGenerator
      step={step}
      onStepChange={setStep}
      targetFields={fields}
      count={count}
      onCountChange={setCount}
      strategies={strategies}
      onStrategiesChange={setStrategies}
      generatedRows={rows}
      onRegenerate={() => generate()}
      isGenerating={false}
      isCreating={false}
      generationError={null}
      result={null}
      previewOnly
      onConfirmConfigure={() => {
        generate();
        setStep('preview');
      }}
      onStartGeneration={() => setStep('configure')}
      onReset={() => setStep('configure')} />
  );
}

Wizard steps

StepPurpose
ConfigureRecord count (up to maxCount), a summary of enabled / auto-skipped fields, and one collapsible card per supported field. Each card has an enable switch (required fields stay on) and per-type controls: text shape or static value, number mode / range / integers / fixed value, currency, phone country code, date mode / window / range span, truth ratio, enum pool and mode, items per row, user pool, and a random-null ratio. Unsupported and system fields are listed as skipped.
PreviewThe first previewRowCount rows in a horizontally scrolling table rendered with the value renderers, plus Regenerate sample and an Export action sheet (CSV, Excel, JSON, Markdown). Exports include a label column and an … ID column for user and relation fields.
ResultCreated / failed / generated tiles and a per-row error list, with Generate more.

The primary action is Preview rows on the configure step. On the preview step it is Save to data source, or Finish when previewOnly is set.

API Reference

DummyDataGeneratorProps

PropTypeDefaultDescription
stepDummyDataGeneratorStep—Current step (required).
onStepChange(next: DummyDataGeneratorStep) => void—Step setter, used by Back (required).
targetFieldsReadonlyArray<DocyrusFieldLike>—Fields the user can populate (required).
requiredFieldSlugsReadonlyArray<string>[]Slugs that must stay enabled.
countnumber—Number of records to generate (required).
onCountChange(next: number) => void—Count setter (required).
maxCountnumber1000Hard cap for count.
strategiesDummyStrategyMap—Per-field generation knobs (required).
onStrategiesChange(next: DummyStrategyMap) => void—Strategy setter (required).
generatedRowsReadonlyArray<Record<string, unknown>>—Rows shown in the preview (required).
onRegenerate() => void—Re-roll the seed and regenerate (required).
isGeneratingboolean—Generation in progress (required).
isCreatingboolean—Insert in progress (required).
generationErrorError | null—Error shown on the result step (required).
resultDummyGenerationResult | null—Insert result (required).
previewRowCountnumber10Rows shown in the preview step.
exportFileNamestring'dummy-data'File name (without extension) for exports.
onConfirmConfigure() => void—Configure step primary action (required).
onStartGeneration() => void—Preview step primary action (required).
onReset() => void—Generate more on the result step (required).
previewOnlybooleanfalseHide Save to data source; the preview step ends with Finish.
usersReadonlyArray<DummyUserOption>—User pool for user fields.
relationOptionsByFieldSlugRecord<string, ReadonlyArray<DummyRelationOption>>—Relation pools, also used to print relation labels in exports.
titleReactNodet('ui.dummyDataGenerator.title', 'Generate dummy data')Header title.
descriptionReactNodet('ui.dummyDataGenerator.description', …)Header description.
iconstring'fal sparkles'DocyrusIcon in the header.
classNamestring—Root card classes.

DummyFieldStrategy

FieldTypeDescription
enabledbooleanInclude the field in generated rows.
emptyRationumber0..1 chance of leaving the value empty.
textModeTextStrategyMode'word' | 'words' | 'sentence' | 'paragraph' | 'firstName' | 'lastName' | 'fullName' | 'company' | 'jobTitle' | 'static'.
staticTextstringValue for textMode: 'static'.
numberModeNumberStrategyMode'random' | 'sequence' | 'fixed'.
min / max / stepnumberNumeric bounds and sequence step.
integerbooleanIntegers only.
staticNumbernumberValue for numberMode: 'fixed'.
dateModeDateStrategyMode'past' | 'future' | 'recent' | 'now' | 'random'.
daysWindownumber± days from now.
rangeMaxDaysnumberMaximum span for date ranges (default 14).
truthRationumber0..1 share of true for booleans (default 0.5).
countryCodestringPhone default country code (for example +90).
currencyCodestringMoney currency (for example USD).
enumModeEnumStrategyMode'random' | 'cycle' | 'static'.
staticEnumIdstringOption id for enumMode: 'static'.
selectedOptionIdsReadonlyArray<string>Restrict enums to these options.
multiMin / multiMaxnumberItems per row for multi-selects.
selectedUserIdsReadonlyArray<string>Restrict users to these ids.
selectedRelationIdsReadonlyArray<string>Restrict relations to these ids.

DummyGenerationResult

FieldTypeDescription
totalGeneratednumberRows generated.
totalCreatednumberRows inserted.
totalFailednumberRows that failed.
errorsReadonlyArray<{ rowIndex: number; message: string }>Per-row errors.

DummyUserOption accepts id / value, name / display_name / displayName / label, email and avatar_url / avatarUrl. DummyRelationOption is { id, name }.

Components

ComponentDescription
DummyDataGeneratorInline card: header, Stepper, step body, footer.
ConfigureStepCount and per-field strategy cards.
PreviewStepValue-renderer preview table and export menu.
ProgressStepInsert progress and result tiles.

Helpers

ExportDescription
buildInitialStrategyMap(fields)Default strategy for every supported, non-system field.
inferStrategyForField(field)Default strategy for one field.
isSupportedFieldType(type) / isSystemFieldSlug(slug)Field filters.
SYSTEM_FIELD_SLUGSSlugs that are never generated.
generateDummyRows(context)Pure, seeded row generator (DummyGenerationContext).
createRng(seed)Mulberry32 seeded RNG.
DUMMY_DATA_GENERATOR_STEPS['configure', 'preview', 'progress', 'result'].

Native differences

  • The wizard is an inline card. Wrap it in an AwesomeDialog or a sheet for modal use.
  • Field strategies are collapsible cards instead of a table.
  • The web preview downloads CSV and Excel. Native adds JSON and Markdown and hands every file to the share sheet through useDataExport (optional expo-file-system + expo-sharing). Excel is written by the zero-dependency writer in the internal lib/native-export.

Translation keys

ui.dummyDataGenerator.*: title, description, steps.*, actions.*, configure.*, preview.*, progress.* and result.* (same keys as web).

Type Exports

TypeDescription
DummyDataGeneratorPropsComponent props.
DummyDataGeneratorStep'configure' | 'preview' | 'progress' | 'result'.
DummyFieldStrategy / DummyStrategyMapPer-field knobs and the map keyed by slug.
DummyGenerationContextInput of generateDummyRows.
DummyGenerationResultInsert result.
DummyUserOption / DummyRelationOptionPools for user and relation fields.
TextStrategyMode / NumberStrategyMode / DateStrategyMode / EnumStrategyModeStrategy modes.

On this page