npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tailor-platform/sdk-plugin-seed

v0.12.0

Published

Tailor CLI plugin providing the `tailor seed` commands (TailorDB and IdP seed data)

Readme

@tailor-platform/sdk-plugin-seed

Tailor CLI plugin that provides the tailor seed commands: seed TailorDB (and IdP _User) data from JSONL files generated by seedPlugin, dump the rows currently in TailorDB back out as seed data, validate that data against the generated schemas, fill in the create-time values the data needs, such as the ids that express relations, and browse and edit the data in a local web UI.

[!NOTE] This package is a CLI plugin: it ships an external tailor-seed executable that the Tailor CLI dispatches to when you run tailor seed. Keep seedPlugin from @tailor-platform/sdk/plugin/seed in definePlugins() — it generates the seed data and schema files this plugin consumes.

Installation

Install it next to @tailor-platform/sdk in your project:

npm install -D @tailor-platform/sdk-plugin-seed@next

The Tailor CLI discovers the plugin automatically from node_modules/.bin (or your PATH). Run tailor plugin list to confirm it resolves.

The seed/data/*.schema.ts files tailor generate writes import defineSchema from @tailor-platform/sdk-plugin-seed/schema, so a project that uses seedPlugin needs this package, and it should be updated at the same time as @tailor-platform/sdk.

Usage

# Seed everything (TailorDB tables, then IdP _User)
tailor seed apply

# Truncate target tables first, without a confirmation prompt
tailor seed apply --truncate --yes

# Seed a single TailorDB namespace (excludes _User)
tailor seed apply --namespace my-db

# Seed specific tables only
tailor seed apply User Order

# Validate JSONL seed data against the generated schemas
tailor seed validate
tailor seed validate ./seed/data/User.jsonl

# Check the id and required fields before updating existing rows
tailor seed validate --upsert

# Fill in the ids rows are missing (and any other create-time field)
tailor seed fill
tailor seed fill --fields id,createdAt
tailor seed fill ./seed/data/User.jsonl

# Fill, then check the result
tailor seed fill && tailor seed validate

# Update existing rows (matched by id, or by name for _User) instead of failing on duplicates
tailor seed apply --upsert

# Write the rows currently in TailorDB out as JSONL seed data
tailor seed dump --out ./snapshot
tailor seed dump --namespace my-db --out ./snapshot
tailor seed dump --force User Order

# Apply, validate, and fill datasets on top of the base seed data
tailor seed apply --dataset cogs --dataset local
tailor seed validate --dataset cogs
tailor seed fill --dataset cogs

# Browse and edit the seed data in the browser
tailor seed studio
tailor seed studio --dataset cogs

Tables several namespaces define

When several TailorDB namespaces define a table with the same name, each goes by <namespace>.<Table>: its files are seed/data/shop-db.Customer.jsonl and seed/data/shop-db.Customer.schema.ts, the commands take that name as an entity (tailor seed apply shop-db.Customer), and --json results key it that way. A table whose name only one namespace defines keeps its own name. The commands stop when seed/data/Customer.jsonl still holds rows for such a table; move each row to the file of its namespace's table.

Datasets

The JSONL files in <distPath>/data/ are the base seed data, applied to every environment. A dataset is a directory under it holding more rows for some of the tables — the rows only one scenario needs, or the rows that differ per environment — so they can sit next to the base data instead of being copied in and out of it:

seed/data/
  Currency.jsonl  Item.jsonl  ...   # base seed data (and the *.schema.ts files)
  cogs/                             # scenario: costing demo
    Item.jsonl
    ItemValuation.jsonl
  shipments/                        # scenario: shipping demo
    Shipment.jsonl
  local/                            # per developer, gitignored
    User.jsonl
    _User.jsonl

A dataset file is named after the table it seeds, the same way as the base files, and holds only rows; the schema files stay in <distPath>/data/, generated once by tailor generate. A dataset needs a file only for the tables it adds rows to. _User.jsonl can live in a dataset too, which is how each developer keeps their own login out of the repository: add seed/data/local/ to .gitignore.

Select datasets with --dataset, repeated to combine several. They apply on top of the base seed data, in the order given:

tailor seed apply --dataset cogs --dataset local   # base, then cogs, then local
tailor seed validate --dataset cogs                # base and cogs, checked together

A table's rows are the rows of its base file followed by the rows of its file in each selected dataset, and apply seeds the tables in dependency order as usual. validate checks the selected datasets together with the base data, so a row in cogs/ItemValuation.jsonl may reference an Item from the base Item.jsonl, and every error points at the file and line the row came from.

A row is defined in exactly one place. An id (or a _User name) that appears in two of the selected files — the base data and a dataset, or two datasets — is an error in both validate and apply, never a silent override. A table whose rows differ per environment belongs in the per-environment datasets only, not in the base data.

Within one file, apply also refuses a _User name that appears on more than one row, because users are created several at a time and the IdP can store the same name twice when two requests arrive together. It stops before truncating or writing anything and lists each repeated row at its file and line, for example seed/data/_User.jsonl:3 ([email protected]): duplicate of seed/data/_User.jsonl:1.

IdP user passwords from the environment

A _User row without a password gets one from the SEED_USER_PASSWORD environment variable, in validate and in apply. A plain string is the password of every such user; a JSON object maps each name to its password ({"[email protected]":"..."}), and a user missing from it still has none. A password written in _User.jsonl is never replaced. The variable only sets the password when a user is created: with --upsert, a user that already exists keeps its password.

A file in a dataset selected with --dataset that does not match a seeded table is rejected, so a misspelled file name does not silently seed nothing.

Selecting every dataset

--all-datasets selects every dataset directory in name order, including directories added later and gitignored directories such as local/. It is available for apply, validate, and fill, and cannot be combined with --dataset or a file or directory path. Named combinations in seedPlugin({ datasets }) are not expanded; the directories themselves are selected. A dataset directory name starts with a letter or digit and contains only letters, digits, -, and _; hidden directories are not selected. If no dataset directories exist, the command fails before applying or filling any rows.

tailor seed validate --all-datasets             # base and all datasets, checked together
tailor seed apply --all-datasets                # base, then every dataset in name order
tailor seed fill --all-datasets                 # fill every dataset, leaving base files unchanged
tailor seed apply --all-datasets --no-base       # every dataset without base rows

The same duplicate-row checks and table filters apply. apply --truncate --all-datasets keeps the existing truncate scope and confirmation, then seeds the base data and every dataset, including local/. With --no-base, it seeds only the datasets after truncating. Use an explicit --dataset selection when local rows or other environments' datasets should be left out.

Naming combinations

Name the combinations you use in the datasets option of seedPlugin, so CI and scripts do not repeat the list:

seedPlugin({
  distPath: "./seed",
  datasets: {
    preview: ["cogs", "shipments"],
    dev: ["local"],
  },
});

--dataset preview then stands for --dataset cogs --dataset shipments. Any other name is a directory under <distPath>/data/. A name configured in datasets must not also be a directory there. A directory selected more than once is read once, where it is first selected.

Truncating and upserting with datasets

--truncate empties the same tables with or without datasets: every table, or the namespace or tables named on the command line. apply --truncate --dataset cogs therefore leaves the workspace holding exactly the base data and cogs — what a disposable preview environment wants. To add a dataset to a workspace that keeps its other data, apply it with --upsert and without --truncate; the base rows are matched by id and updated in place.

Leaving the base data out

--no-base applies or validates the selected datasets alone. The datasets then need a file — an empty one will do — for every table their tables reference through a foreign key, since the base data no longer provides them:

tailor seed validate --no-base --dataset snapshot
tailor seed apply --no-base --dataset snapshot

Filling and dumping datasets

tailor seed fill --dataset cogs fills only the files of the selected datasets, using the schema files of the base data; the base files are left as they are. Select datasets with --dataset rather than by path: a path is filled and validated on its own as before, and naming a dataset directory or one of its files points you at --dataset, since the directory holds no schema files of its own.

tailor seed dump --dataset snapshot writes into <distPath>/data/snapshot/, creating it if needed. A dump holds every row of the tables it covers, base rows included, so it is restored on its own rather than on top of the base data:

tailor seed dump --dataset snapshot
# ... try the change ...
tailor seed apply --truncate --yes --skip-idp --no-base --dataset snapshot

Restore with the same --namespace or table names the dump was taken with: --truncate empties every table otherwise, and with --no-base the tables the dump does not cover stay empty. A dump never holds _User, so validating it with --no-base in a project with IdP users also needs a dataset that holds _User.jsonl.

Editing seed data in the browser

tailor seed studio opens the seed data in a local web UI (lines-db studio), so rows can be browsed, edited, added, and deleted in a grid or a row form instead of by hand in the JSONL files. It serves the data directory under the seedPlugin distPath at http://127.0.0.1:4848 until you stop it with Ctrl+C. Pass a directory to open that directory instead; a dataset directory such as seed/data/cogs is checked against the schema files of the directory above it.

tailor seed studio                            # the base seed data
tailor seed studio --dataset cogs             # base and cogs, shown together
tailor seed studio --dataset cogs --no-base   # only the cogs rows
tailor seed studio --port 0 --open            # pick a free port and open the browser
  • Changes stay pending until you save them. A save is checked against the same generated schema files tailor seed validate uses, so a value they reject writes nothing and is shown with the change it came from.
  • A save writes the fields you entered, plus the id generated for a new row so other rows can reference it. Values the table fills in on create, such as createdAt or a computed field, stay out of the file; tailor seed apply fills them in.
  • A table whose JSONL file has no rows is listed only when your project has typescript installed, since the studio reads the columns from the generated schema file's types. Without it, such a table is left out of the list.
  • With --dataset or --all-datasets, a row is saved back to the file it came from. The schema files are the ones in the base data directory.
  • --json prints url, dataDir, and the selected datasets as JSON.
  • Run tailor seed validate before tailor seed apply: each save is checked on its own, so rows that reference each other across tables, such as a new _User and the user profile row for it, are only valid together once both are saved.

Validating seed data

tailor seed validate checks every row against the table it seeds: field types, required fields, the table's own validate, and the relations between files. A row is also rejected when it carries a field the table does not declare, at the top level or inside a nested object:

seed/data/Company.jsonl:3 • legacyCode: Field "legacyCode" is not declared by the table. Remove it from the row, or add it to the table definition and run `tailor generate`.

This is what catches seed data that has drifted from the table definition — a column that still exists in a deployed environment but was removed from tailor.config.ts, or a typo in a field name — before tailor seed apply turns it into a database error. The check follows the generated schema files, so run tailor generate after changing a table or attaching a plugin to one. Fields a plugin adds to the table are validated like the table's own. IdP _User rows are not checked this way, since their extra keys are user attributes.

Dumping the current data back out

tailor seed dump reads the rows a deployed app currently holds and writes them as JSONL, one file per table, in the format tailor seed apply reads. That makes a dump the restore point for the change you are about to make:

tailor seed dump --force
# ... run the migration, the executor, the workflow you want to try ...
tailor seed apply --truncate --yes --skip-idp

Naming tables limits the dump to them, and --namespace limits it to one namespace, so a table you are about to change can be captured and put back on its own rather than resetting the whole app.

Restoring needs --skip-idp unless you also have a separate backup of _User. A dump never captures _User (see below), so tailor seed apply --truncate without --skip-idp would truncate the app's current IdP users and reseed _User from whatever _User.jsonl already has on disk — data the dump did not just refresh, and that may no longer match who has actually signed up. Add --skip-idp to the restore unless you have separately backed up and intend to restore _User too.

Fields the platform assigns rather than the seed row — serial fields — are left out, unless another table's relation is keyed to that field, in which case it is kept so the relation still resolves after apply --truncate gives the row a fresh value. Explicit nulls are kept as-is, so a dumped line reads back the way a hand-written one does and tailor seed validate accepts it. Rows are read a page at a time, ordered by id, and written to disk as each page arrives rather than held in memory for the whole table; --page-size changes how many come back per request.

Without --out, the files land in the seed data directory under the seedPlugin distPath, on top of the data that is already there — so a file that already exists is only overwritten with --force:

2 JSONL file(s) already exist in /project/seed/data: User, Order. Pass --force to overwrite them, or --out to write elsewhere.

IdP _User records are never dumped. Their credentials do not survive a round trip through seed JSONL, so naming _User is an error rather than a partial export; keep that data under version control instead.

Two things the dump does not capture: the bytes behind stored file fields, and which rows came from a previous seed rather than from the app — a dump is the whole current state of the tables it covers.

Paging is not safe against concurrent writes. Each page is fetched with id as a keyset cursor, but TailorDB ids are UUIDs rather than a monotonic sequence, so a row inserted after paging starts can land before the cursor already handed out and never be seen. Dumping a table that a running app keeps writing to can therefore miss rows written during the dump; for a true point-in-time restore point, pause writes (or dump from a replica/snapshot) before running tailor seed dump.

The machine user needs unconditional read access. TailorDB read permission conditions filter rows per record, so a machine user that can only see a subset of a table still gets a successful result back — just a smaller one — and the dump reports that subset as the complete table. Restoring from it with apply --truncate then permanently drops the rows the machine user could not see, with no error at any point. Grant the machine user used for tailor seed dump unconditional read access to every table you dump.

Filling in create-time values

A relation in seed data points at a field of the row it references — usually its id — so a row you want to reference needs an id written in the file. tailor seed fill writes the value a record would get on create into the rows that are missing it, id by default:

# ./seed/data/Customer.jsonl before
{"name":"Acme Corporation","email":"[email protected]"}
# after
{"id":"0b6b6f5e-3b8a-4d0e-9a1f-2c7d8e5a4b31","name":"Acme Corporation","email":"[email protected]"}

--fields names what to fill, so any field the table gives a value to on create can be written the same way — --fields id,createdAt also stamps a creation time on rows that have none, which is how you seed records that need to look older than the seed run:

tailor seed fill --fields id,createdAt

The values come from the table itself — its id, its field defaults, its create hooks — applied to each row on its own.

Nothing is validated. That is deliberate: the ids are what you need in order to write the rows that reference them, so waiting for the data to be valid would be waiting for the thing this command gives you. A row can be filled while a required field is still missing, or while another file references an id that does not exist yet. Run tailor seed validate once the data is ready.

Only the named fields are written, and only into a row that has no value for them, so a value already in the file is never replaced — a row that already carries a createdAt keeps it. A field the table gives no value to is skipped: --fields id leaves the IdP _User data alone, whose rows are identified by name, and a field the platform assigns rather than the table — a serial field — has nothing to fill in from here:

⚠ No seed data produces a value for: invoiceNumber
✓ Nothing to fill

A line that gains nothing is left exactly as it was, byte for byte. Only the lines that take a value are rewritten, and those get their keys in the order the table declares its fields, so a filled-in id lands at the front of the line and a createdAt next to the other timestamps. Keys the table does not declare follow the declared ones.

The values are read from the schema files seedPlugin generates next to the data. Every one of them is read before anything is written, so a project that has not run tailor generate since upgrading is told which file to regenerate and keeps its data untouched:

./seed/data/Customer.schema.ts does not export `hook`. Run `tailor generate` to regenerate the seed schema files.

If a file was changed by another tool after the fill read it, the fill writes nothing and names the file; run it again to fill from the current content.

Naming a single .jsonl file limits the run to that file, so a referenced table can be filled on its own before the rows that reference it are written.

Without --upsert, a row whose id already exists in a target table fails the seed run. With --upsert, every row must supply an id (and any field the table requires) — run tailor seed fill first if some rows have none — and a matching row is updated in place instead. Because the update goes through the same write path as any other update, it runs update hooks and validation and updates fields such as updatedAt, and it publishes a record-updated event — so an executor using recordUpdatedTrigger fires for each existing row that gets updated.

The machine user used for seeding comes from --machine-user or the machineUserName seedPlugin option:

definePlugins(
  seedPlugin({
    distPath: "./seed",
    machineUserName: "admin-machine-user",
  }),
);

In a defineWorkspace() config (Beta) with several Auth services, a machine user name that two of them define is ambiguous: pass --machine-user <auth>/<name>, or set machineUserName: { namespace: "<auth>", machineUserName: "<name>" }.

Run tailor seed <command> --help for the full option reference.