Skip to content

Releases: Quramy/prisma-fabbrica

v2.2.0

25 Jun 03:24
Compare
Choose a tag to compare

New Features

  • Transient fields (#326)
  • Callback functions (#254)
  • Improve createList signature (#335)

Transient fields

Transient fields allows to define arbitrary parameters to factories.

const UserFactory = defineUserFactory.withTransientFields({
  loginCount: 0,
})({
  defaultData: async ({ loginCount }) => ({
    /* Do something using `loginCount` parameter */
  }),
});

await UserFactory.create({
  name: "Bob", // `name` field is defined in scehma.primsma
  loginCount: 100, // `loginCount` field is NOT defined in schema but defined in factory
});

If you want more details, See docs

Callback functions

Allow to define callback functions when to define factories like this:

const UserFactory = defineUserFactory({
  onAfterCreate: async (user) => {
    await PostFactory.craete({
      author: { connect: uesr },
    });
  },
});

await UserFactory.create();

Available callback functions are onAfterBuild, onBeforeCreate, and onAfterCreate.

If you want more details, See docs

Improve createList signature

createList (or buildList) method in factory interface accepts the 2nd argument.
The 2nd argument can be an object assignable to Partial<Prisma.MODEL.CreateInput>.

// Insert 10 LoginHistory model records with the same `userId` field.
await LoginHistoryFactory.createList(10, { userId: "user001" });

Full Changelog: v2.1.5...v2.2.0

v2.1.5

24 Jun 08:11
Compare
Choose a tag to compare

What's Changed

  • Sometimes {} is not assignable to ModelFactoryInput by @Quramy in #341

Full Changelog: v2.1.4...v2.1.5

v2.1.4

19 Jun 09:49
Compare
Choose a tag to compare

Bug fixes

  • Fix TS2742: The inferred type of 'initialize' cannot be named without a reference #337

What's Changed

  • chore(CI): Publish with npm dist tag by @Quramy in #329
  • test: Compile with multiple --module options by @Quramy in #337

Full Changelog: v2.1.3...v2.1.4

v2.1.3

02 May 19:03
Compare
Choose a tag to compare

What's Changed

  • Update some dependencies

Full Changelog: v2.1.2...v2.1.3

v2.1.2

29 Mar 04:27
Compare
Choose a tag to compare

What's Changed

Full Changelog: v2.1.1...v2.1.2

v2.1.1

12 Mar 05:17
Compare
Choose a tag to compare

Bug fixes

  • fix: TypeScript error caused by internal symbol by @Quramy in #283

Full Changelog: v2.1.0...v2.1.1

v2.1.0

15 Jan 11:55
Compare
Choose a tag to compare

New features

  • Isolate PrismaClient instance for each fabbrica file (#257)

v2.0.2

13 Oct 02:26
Compare
Choose a tag to compare

Bug fixes

  • Ignore to generate factories of model whose fields annotated as Unsupported #209

v2.0.1

18 Jul 09:59
Compare
Choose a tag to compare

Bug fixes

  • Fix Import path to Prisma client on win32 generation (#169)

v2.0.0

18 Jul 00:41
Compare
Choose a tag to compare

Breaking changes

  • Change support @prisma/client version to v5.0.0 (#166).