open-index/open-npm huggingface dataset:
npm package: @junte/mocker
Description: Library for creating mocks for your projects.
Latest version: 0.0.11

# Mocker
Library for creating mocks for your projects.

## Add a dependency and script to your `package.json`:
```
npm install @junte/mocker
```

## Change a `tsconfig.json`:
```
{
    ...
    compilerOptions: {
        ...
        emitDecoratorMetadata: true,
        ...
    },
    ...
}
```

# Examples

Model `ObjectLink.ts:`
```
@MockModel()
export class ObjectLink {

  @MockField({mock: 1})
  id: number;

  @MockField({mock: 'Test title'})
  title: string;
  
}
```

Model `User.ts:`
```
@MockModel()
export class User {

  @MockField({mock: () => 123})
  id: number;
  
  @MockField({mock: () => 'Test nick'})
  nick: string;

  @MockField({mock: false})
  approved: boolean;

  @MockField({mock: ObjectLink})
  name: ObjectLink;

  @MockField({
    name: 'first_name',
    mock: 'First name'
  })
  firstName: string;

  @MockField({
    serializer: new ArraySerializer(new ModelSerializer(ObjectLink)),
    mock: {type: ObjectLink, length: 2}
  })
  hobby: ObjectLink[];

}
```
at the output we get
`object_link.json:`
```
{
    "id": 1,
    "title": "Test title"
}
```

and `user.json:`

```
{
    "id": 123,
    "nick": 'Test nick',
    "approved": false,
    "name": {
        "id": 1,
        "title": "Test title"
    },
    "first_name": "First name",
    "hobby": [
        {
            "id": 1,
            "title": "Test title"
        },
        {
            "id": 1,
            "title": "Test title"
        }
      ...
    ]
}
```
npm package: @junte/mocker-library
Description: Library for creating mock files for your projects.
Latest version: 0.0.59

# MockerLibrary
Library for creating mock files for your projects.

After setting up and running the library, it will automatically create the HBS(DummyJSON) files from which the conversion to JSON will occur.
##Getting started
####1. Add a dependency to your `package.json`:
```
npm install @junte/mocker-library
```

####2. Add a script in your `package.json`:
```
"scripts": {
   ...
  "mocks": "gulp build --gulpfile node_modules/@junte/mocker-library/gulpfile.js --cwd ."
   ...
}
```

####3. Change a `tsconfig.json`:
```
{
    ...
    compilerOptions: {
        ...
        emitDecoratorMetadata: true,
        ...
    },
    ...
}
```

####4. Config
After the first run mocks script, a config file (mocker.json) will be created in root directory. Set your preferences for the library.

Default config values:
```
{
  outDirProject: './dist/out-tsc',
  modelsDir: './src/models',
  helpersDir: './src/mocks/helpers',
  objectsDir: './src/mocks/objects',
  servicesDir: './src/mocks/services',
  outObjectsJsonDir: './src/mocks/objects',
  outServicesJsonDir: './src/assets/mocks'
}
```
`outDirProject` - this equal to the `outDir` your project (see `tsconfig.json`)

`modelsDir` - directory in which the data models with decorators are placed in them

`helpersDir` - directory with helpers (for dummyjson)

`objectsDir` - directory in which the script will add `*.hbs` (for dummyjson) files generated from models

`servicesDir` - directory in which you will create `*.hbs` files for services 

`outObjectsJsonDir` - directory in which json files created from `*.hbs` files which are in `objectsDir`

`outServicesJsonDir` - directory in which json files created from `*.hbs` files which are in `servicesDir`

#Examples
Model `ObjectLink.ts:`
```
@model()
export class ObjectLink {

  @field({mock: '{{int 1 100}}'})
  id: number;

  @field({mock: '{{presentation}}'})
  presentation: string;
  
}
```

Model `User.ts:`
```
@model()
export class User {

  @field({mock: '{{int 1 100}}'})
  id: number;

  @field({mock: '{{boolean}}'})
  approved: boolean;

  @field({mock: '{{> object_link presentation="John"}}'})
  name: ObjectLink;

  @field({
    name: 'first_name',
    mock: '{{firstName}}'
  })
  firstName: string;

  @field({
    serializer: new ArraySerializer(new ModelSerializer(ObjectLink)),
    mock: '[{{#repeat 1 5}} {{> object_link presentation="Hobby"}} {{/repeat}}]'
  })
  hobby: ObjectLink[];

}
```
at the output we get
`object_link.json:`
```
{
    "id": 77,
    "presentation": "John"
}
```

and `user.json:`

```
{
    "id": 47,
    "approved": false,
    "name": {
        "id": 76,
        "presentation": "John"
    },
    "first_name": "Darrell",
    "hobby": [
        {
            "id": 71,
            "presentation": "Hobby"
        },
        {
            "id": 4,
            "presentation": "Hobby"
        },
        {
            "id": 63,
            "presentation": "Hobby"
        }
      ...
    ]
}
```