Skip to content
Compare
Choose a tag to compare
@Chacaponquin Chacaponquin released this 09 Nov 16:16
c00fcbb

🌚 Features

Core

  • The Dataset class was created to export various schemas in a relational way

  • You can now define the isArray parameter as a function that is executed when each document is created.

    const schema = chaca.schema({
      image: {
        type: () => modules.image.people(),
        isArray: ({ currentFields, store }) => {
          return 5;
    
          // or
    
          return {
            min: 2,
            max: 10,
          };
        },
      },
    });
  • Added exception WrongPossibleNullDefinitionError for errors in the definition of the parameter possibleNull

  • Added exception WrongArrayDefinitionError for errors in the definition of the parameter isArray

  • Added exception WrongProbabilityFieldDefinitionError for errors in the definition of probability fields

  • 🗑️ chaca.multiGenerate was removed

  • 🎉 The number of items to select in the pick field can be defined as a range of values ​​or a function that returns the number of values ​​to choose from.

    // range
    chaca.pick({
      values: [1, 2, 3, 4, 5],
      count: {
        min: 1,
        max: 3,
      },
    });
    
    // function
    chaca.pick({
      values: [1, 2, 3, 4, 5],
      count: ({ store, currentFields }) => {
        return 2;
    
        // or
    
        return {
          min: 1,
          max: 3,
        };
      },
    });
  • Added nullOnEmpty parameter to avoid NotEnoughValuesForRefError exception

  • The ref fields can reference the schema they are located in without causing a circular dependency.

  • 🎉 Added Dataset.transform, Schema.transform and Chaca.transform methods to serialize data to a specific file format without having to export it

  • 🎉 Added new CLI commands

    • json
    • python
    • java
    • js
    • json
    • postgresql
    • ts
    • yaml

Modules

  • 🎉 Added datatype.octal
  • 🎉 Added datatype.numeric
  • 🎉 Added datatype.bigint
  • 🎉 Added datatype.character
  • 🎉 Added id.nanoid
  • 🎉 Added id.ulid
  • 🎉 Added id.cuid
  • 🎉 Added image.category
  • 🎉 Added color.human
  • 🎉 Added date.anytime
  • 🎉 Added finance.litecoinAddress
  • 🎉 Added internet.ip
  • 🎉 Added address.ordinalDirection
  • 🎉 Added lorem.word
  • 🎉 Added lorem.sentence
  • 🎉 Added lorem.paragraph
  • 🎉 Added person.zodiacSign
  • 🎉 Added system.cron
  • 🎉 Added address.longitude
  • 🎉 Added address.latitude
  • The prefix argument was added to the datatype.alphaNumeric module

Utils

  • 🎉 Added utils.pick to select elements from an array without being chosen more than once
  • 🎉 Added utils.multiple To create an array of values ​​from a generator
  • 🎉 Added banned and symbols options on utils.replaceSymbols
  • 🗑️ Deleted utils.capitalCamelCase
  • 🗑️ Deleted utils.capitalize
  • 🗑️ Deleted utils.capitalizeWord
  • 🎉 Added utils.snakeCase
  • 🎉 Added utils.dotCase
  • 🎉 Added utils.sentenceCase
  • 🎉 Added utils.capitalCase
  • 🎉 Added utils.pascalCase

🪛 Fix

Core

  • 🔄 DatasetStore.getValue -> DatasetStore.get

  • 🔄 The schemas concept was changed to modules for predefined functions

  • 🗑️ The SchemaField class and the chaca.schemaField() method are removed. The way to use the modules from now on is as follows

    // get a value
    modules.id.uuid();
    
    // use on schemas
    const schema = chaca.schema({
      id: () => modules.id.uuid(),
    });
  • Probability values ​​for the possibleNull param must be in the range 0 to 1 now

  • 🔄 Schema.generate -> Schema.array

  • 🔄 Schema.generateObject -> Schema.object

  • 🔄 FileConfig.fileName -> FileConfig.filename

  • 🔄 DatasetStore.getSchemaDocuments -> DatasetStore.currentDocuments

  • 🔄 NotExistFieldError -> NotExistRefFieldError

  • 🗑️ Removed export CLI command

Modules

  • 🔄 modules.animal.animalType -> modules.animal.type
  • 🔄 modules.image.animateAvatar -> modules.image.animatedAvatar
  • 🔄 modules.id.mongodbID -> modules.id.mongodbId