# flotiq-codegen-ts

> CLI tool to generate API clients using Flotiq API and OpenAPI Generator

Latest version **1.4.2** (published 2024-11-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install flotiq-codegen-ts
pnpm add flotiq-codegen-ts
yarn add flotiq-codegen-ts
bun add flotiq-codegen-ts
```

Provides the command `flotiq-codegen-ts`.

## 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.4.2 |
| Published | 2024-11-21 |
| First published | 2024-04-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 783 KB |
| Known vulnerabilities | 0 (+8 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Your Name |
| Maintainers | flotiq |
| Keywords | flotiq, codegen, openapi-generator |

## Links

- npm: https://www.npmjs.com/package/flotiq-codegen-ts
- Repository: https://github.com/flotiq/flotiq-codegen-ts
- Homepage: https://github.com/flotiq/flotiq-codegen-ts#readme
- Issues: https://github.com/flotiq/flotiq-codegen-ts/issues
- npm.io page: https://npm.io/package/flotiq-codegen-ts

## Dependencies (10)

- [axios](https://npm.io/package/axios.md) ^1.6.8
- [yargs](https://npm.io/package/yargs.md) ^15.3.1
- [dotenv](https://npm.io/package/dotenv.md) ^16.4.5
- [adm-zip](https://npm.io/package/adm-zip.md) ^0.5.12
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.2.0
- [inquirer](https://npm.io/package/inquirer.md) ^8.2.0
- [typescript](https://npm.io/package/typescript.md) ^4.0
- [dotenv-flow](https://npm.io/package/dotenv-flow.md) ^4.1.0
- [loading-cli](https://npm.io/package/loading-cli.md) ^1.1.2
- [@openapitools/openapi-generator-cli](https://npm.io/package/@openapitools/openapi-generator-cli.md) ^2.13.1

## Recent versions

- 1.4.2 (latest) — 2024-11-21
- 1.4.1 — 2024-11-19
- 1.4.0 — 2024-11-08
- 1.3.1 — 2024-10-25
- 1.3.0 — 2024-10-24
- 1.2.2 — 2024-09-17
- 1.2.1 — 2024-06-13
- 1.2.0 — 2024-06-10
- 1.1.2 — 2024-06-04
- 1.1.1 — 2024-06-04
- 1.1.0 — 2024-05-29
- 1.0.9 — 2024-05-29
- 1.0.8 — 2024-05-21
- 1.0.7 — 2024-05-10
- 1.0.6 — 2024-04-23
- … 6 more at https://npm.io/package/flotiq-codegen-ts/versions

## README

<a href="https://flotiq.com/">
    <img src="https://editor.flotiq.com/fonts/fq-logo.svg" alt="Flotiq logo" title="Flotiq" align="right" height="60" />
</a>


flotiq-codegen-ts
=================

This package generates Typescript Fetch API integration for your Flotiq project.

## See it in action!

![Flotiq API accessible through TypeScript](./.images/flotiq-typescript-intellisense-2.gif)

Go to this [JSFiddle](https://jsfiddle.net/o5rafnpw/1/) to see a (limited) demo.

## Quickstart

```bash
npx flotiq-codegen-ts generate
```

## Usage

Run `flotiq-codegen-ts`, provide your API key and wait for your Typescript code to be generated in the `flotiqApi`
folder.
Then start using it:

```javascript
import {FlotiqApi} from 'flotiqApi/src';

const FLOTIQ_RO_API_KEY = 'YOUR_API_KEY';
const flotiq = new FlotiqApi(FLOTIQ_RO_API_KEY);

// Use your IDE IntelliSense to work with types & api endpoints!

const eventList = await flotiq.EventAPI.list({limit: 100});
```

## Usage in JS project

If you wish to use `flotiqApi` in JS project you can use `flotiq-codegen-ts` with `--compiled-js`/`-c` flag

```bash
npx flotiq-codegen-ts generate --compiled-js
```

Now set of compiled `d.ts` and `.js` will be automatically generated in your `flotiqApi` folder.
You can now import and use the API in your project:

```javascript
import {FlotiqApi} from 'flotiqApi/index';

const FLOTIQ_RO_API_KEY = 'YOUR_API_KEY';
const flotiq = new FlotiqApi(FLOTIQ_RO_API_KEY);

// Use your IDE IntelliSense to work with types & api endpoints!

const eventList = await flotiq.EventAPI.list({limit: 100});
```

## Watching for changes in your data in Flotiq

The `flotiq-codegen-ts` tool offers a feature to continuously monitor changes in the content on your Flotiq account. It
automatically regenerates the SDK whenever changes are detected, ensuring that developers always have the most
up-to-date data models in their IDE without manual intervention.

The `--watch`/`-w` option for `flotiq-codegen-ts` ensures your SDK stays up-to-date by automatically monitoring and regenerating
based on content changes.

If you want to see changes made in Flotiq by your content editor in your IDE, use `flotiq-codegen-ts` with `--watch`/`-w`
flag

```bash
npx flotiq-codegen-ts generate --watch
```

or, if you want your SDK to be directly compiled to JavaScript use `flotiq-codegen-ts` with flags  `--watch`/`-w`
and `--compiled-js`/`-c`

```bash
npx flotiq-codegen-ts generate --watch --compiled-js
```

Now, `flotiq-codegen-ts` will check for changes in your Flotiq content every 10 seconds. If changes are detected, it will
automatically regenerate your SDK to reflect the updates.

## Surpressing output messages

If you don't want to receive output messages, pass `--silent`/`-s` option to limit number of logs. This option assumes, that the generator cannot read api key from `.env.*` file and will not ask for key in the console.

```bash
npx flotiq-codegen-ts generate --silent
```

This is especially useful when you are using generator with other automation tools or you are running generate function by hand.

## Changing SDK output path

By default, the SDK is generated in the `flotiqApi` folder in your working directory.

If you want to change the path for the generated SDK, use the `--output`/`-o` option with your chosen path.

```bash
npx flotiq-codegen-ts generate --output ./lib/flotiqApi
```

In the example above, the SDK will be placed in the `flotiqApi` folder within `lib` in your working directory.

## Node.js api

You can use command handler in your scripts by importing command handler

```javascript
const {handler} = require('flotiq-codegen-ts/commands/generate');

await handler({flotiqApiKey: 'test-ro-key', watch: false, silent: false, compiledJs: false});
```

## Developing

To start developing this project, follow these steps:

1. Clone the repository `git clone git@github.com:flotiq/flotiq-codegen-ts.git`
2. Install dependencies `yarn install`
3. Run the project `yarn start`

## Collaborating

If you wish to talk with us about this project, feel free to hop on
our [![Discord Chat](https://img.shields.io/discord/682699728454025410.svg)](https://discord.gg/FwXcHnX).

If you found a bug, please report it in [issues](https://github.com/flotiq/flotiq-codegen-ts).

---
_Source: https://npm.io/package/flotiq-codegen-ts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
