# @2bttns/formatter

> Convert JSON data into a format readable by the 2bttns Console.

Latest version **1.2.4** (published 2023-07-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @2bttns/formatter
pnpm add @2bttns/formatter
yarn add @2bttns/formatter
bun add @2bttns/formatter
```

Provides the command `game-objects-converter`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.4 |
| Published | 2023-07-25 |
| First published | 2023-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 45.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | 2bttns Company |
| Maintainers | mriziq, mat-2bttns |

## Links

- npm: https://www.npmjs.com/package/@2bttns/formatter
- npm.io page: https://npm.io/package/@2bttns/formatter

## Dependencies (6)

- [cuid](https://npm.io/package/cuid.md) ^3.0.0
- [glob](https://npm.io/package/glob.md) ^10.3.3
- [enquirer](https://npm.io/package/enquirer.md) ^2.3.6
- [omelette](https://npm.io/package/omelette.md) ^0.4.17
- [typescript](https://npm.io/package/typescript.md) ^5.1.6
- [@types/node](https://npm.io/package/@types/node.md) ^20.3.2

## Recent versions

- 1.2.4 (latest) — 2023-07-25
- 1.2.3 — 2023-07-25
- 1.2.2 — 2023-07-23
- 1.2.1 — 2023-07-23
- 1.2.0 — 2023-07-23
- 1.1.7 — 2023-07-17
- 1.1.6 — 2023-07-17
- 1.1.5 — 2023-07-17
- 1.1.4 — 2023-07-17
- 1.1.3 — 2023-07-17
- 1.0.3 — 2023-07-17
- 1.0.2 — 2023-07-17

## README

# Game Object Formatter
Convert JSON data into a format readable by the 2bttns Console.

## Usage 

   ```bash
   npx @2bttns/formatter
   ```

```bash
✔ What do you want to do? · Format data for 2bttns Console
✔ 📁 Enter the path of the input JSON file:  · unformatted-data/genres.json
✔ 🔍 Select the path in JSON where the data to be converted is located:  · genres
✔ ⭐️ Which key in your JSON corresponds to "id" with value type "string"?
 👉 Enter "none" if none exists. · id
✔ ⭐️ Which key in your JSON corresponds to "name" with value type "string"?
 👉 Enter "none" if none exists. · name
✔ ⭐️ Which key in your JSON corresponds to "description" with value type "string"?
 👉 Enter "none" if none exists. · none
✔ ⭐️ Which key in your JSON corresponds to "tagIds" with value type "object"?
 👉 Enter "none" if none exists. · none
✔ 📁 Enter the path where you want to save the output JSON file (e.g., /your/path/name/):  · /Users/admin/Desktop/2bttns Company
✅ Output JSON file saved successfully! ✅
```

```Format data for 2bttns Console``` will guide you through mapping your JSON and generating a ready to upload file.

```Get ready-to-upload json data``` will download already formatted Game Objects available in the formatter.

```bash
# Ready to upload json data
? Select the JSON file you want to output from the /formatted-data folder: … 
❯ ready-car-considerations.json
  ready-chords.json
  ready-indoorActivities.json
  ready-outdoorActivities.json

```

## Table of Contents
1. [Data Model](#game-objects-model)
2. [Usage](#usage)
3. [Example](#example)
4. [Upload to Console](#upload-to-console)
5. [License](#license)


---


#### Warnin
> The Tags section at the bottom of the output JSON is currently set to have empty strings for `id`, `name`, and `description` fields. <br/> As a result, a new Tag object will be generated in the Console.


## Game Objects Model
The script converts any size JSON into the data model below. 

> Your JSON must contain a `name` equivalent field. These values are loaded as choices within your Game buttons.
>
> Fields not represented in the Game Objects model are ignored. See [Example](#example) for more information.

```typescript
const outputShape: OutputShape = {
  gameObjects: [
    {
      id: '',
      name: '',
      description: '',
      tagIds: []
    }
  ],
  tags: [
    {
      id: '',
      name: '',
      description: ''
    }
  ]
};
```

Interface Type
```typescript
interface GameObject {
  id: string;
  name: string;
  description: string;
  tagIds: string[];
  [key: string]: any;
}
```

## Example

Here's an example of the input JSON:

```json
{
    "chords": [
      {
        "name": "C Major",
        "notes": ["C", "E", "G"]
      },
      {
        "name": "C Minor",
        "notes": ["C", "Eb", "G"]
      },
      {
        "name": "D Major",
        "notes": ["D", "F#", "A"]
      },
      ...
    ]
}
```

And here's the resulting output JSON:

```json
{
  "gameObjects": [
    {
      "id": "cljgvm1w00000679s2l9a5zql",
      "name": "C Major",
      "description": "",
      "tagIds": []
    },
    {
      "id": "cljgvm1w10001679sdppzbk1p",
      "name": "C Minor",
      "description": "",
      "tagIds": []
    },
    {
      "id": "cljgvm1w10002679sda2j6i75",
      "name": "D Major",
      "description": "",
      "tagIds": []
    },
    ...
  ],
  "tags": [
    {
      "id": "",
      "name": "",
      "description": ""
    }
  ]
}
```

## Upload to Console

Now your new json is ready to be uploaded.

1. Locate your converted data inside `output`.
2. Open your Console
3. Navigate to Game Objects
4. Click Actions then Import from JSON
5. Upload the `ready-for-upload.json` file and click Confirm.

Your Game Objects are now ready to be Tagged!

## License

This project is licensed under the [MIT License](/MIT_LICENSE.txt).

---
_Source: https://npm.io/package/@2bttns/formatter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
