# fetch-appwrite-types

> Appwrite types file maker

Latest version **2.2.2** (published 2024-11-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install fetch-appwrite-types
pnpm add fetch-appwrite-types
yarn add fetch-appwrite-types
bun add fetch-appwrite-types
```

Provides the command `fetch-appwrite-types`.

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.2 |
| Published | 2024-11-16 |
| First published | 2023-03-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 23.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 38 |
| Author | Etienne Moureton |
| Maintainers | etiennemoureton |
| Keywords | typescript, npm, template, ts |

## Links

- npm: https://www.npmjs.com/package/fetch-appwrite-types
- Repository: https://github.com/YsarocK/fetch-appwrite-types
- Homepage: https://github.com/YsarocK/fetch-appwrite-types#readme
- Issues: https://github.com/YsarocK/fetch-appwrite-types/issues
- npm.io page: https://npm.io/package/fetch-appwrite-types

## Dependencies (5)

- [dotenv](https://npm.io/package/dotenv.md) ^16.4.5
- [consola](https://npm.io/package/consola.md) ^3.2.3
- [dts-dom](https://npm.io/package/dts-dom.md) ^3.7.0
- [ts-node](https://npm.io/package/ts-node.md) ^10.9.2
- [node-appwrite](https://npm.io/package/node-appwrite.md) ^13.0.0

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 2.2.2 (latest) — 2024-11-16
- 2.0.2-2 (next) — 2024-10-11
- 2.2.1 — 2024-11-16
- 2.2.0 — 2024-11-12
- 2.1.1 — 2024-11-11
- 2.0.2-1 — 2024-10-11
- 2.0.2-0 — 2024-10-09
- 2.0.1-0 — 2024-10-09
- 1.10.1 — 2024-10-08
- 1.10.0 — 2024-10-05
- 1.9.0 — 2024-09-02
- 1.9.0-0 — 2024-09-02
- 1.8.3 — 2024-08-31
- 1.8.2 — 2024-07-08
- 1.8.1 — 2024-06-28
- … 38 more at https://npm.io/package/fetch-appwrite-types/versions

## README

![fetch-appwrite-types banner](./readme-banner.jpg)

# Generate Typesript types from Appwrite Databases

![npm](https://img.shields.io/npm/dt/fetch-appwrite-types)
![npm](https://img.shields.io/npm/v/fetch-appwrite-types)
![tests](https://github.com/YsarocK/fetch-appwrite-types/actions/workflows/tests.yml/badge.svg)

## Quick usage
Make sure ton add the following values to your ```.env``` :
```APPWRITE_ENDPOINT```
```APPWRITE_PROJECT_ID```
```APPWRITE_API_KEY```

Then run the following command :

```bash
npx fetch-appwrite-types
```

## Installation
```bash
# yarn
yarn add fetch-appwrite-types

# npm
npm install fetch-appwrite-types
```

Make sure ton add the following values to your ```.env``` :
```APPWRITE_ENDPOINT```
```APPWRITE_PROJECT_ID```
```APPWRITE_API_KEY```

```javascript
import { FetchNewTypes } from "fetch-appwrite-types/dist/main";

await FetchNewTypes();
```

## Parameters
| Name    | Default value            | Description                                       |
|---------|--------------------------|---------------------------------------------------|
| outDir  | ```"/types"``` | The folder where the type file will be generated  |
| outFileName   | `"appwrite"`  | The name of the generated type file               |
| includeDBName | ```false```              | Add the collection name at start of types         |
| hardTypes   | ```false```              | Creates an Email type and an URL types. [More](#hard-types). |

### Usage
#### CLI
Params can be passed as arguments in any order, except for the outDir which might be followed by the path.
```bash
npx fetch-appwrite-types includeDBName outDir /types outFileName appwrite hardTypes
```

#### Library
```javascript
await FetchNewTypes({
    outDir: "/types",
    outFileName: "appwrite",
    includeDBName: true,
    hardTypes: true
})
```

## Handled types

| Appwrite type | Generated type (simple) | Generated type (hard)      |
|---------------|-------------------------|----------------------------|
| String        | ```string```                  | ```string```               |
| Integer       | ```integer```                 | ```integer```              |
| Float         | ```integer```                 | ```integer```              |
| Boolean       | ```boolean```                 | ```boolean```              |
| DateTime      | ```string```                  | ```Date```                 |
| Email         | ```string```                  | [```Email```](#hard-types) |
| IP            | ```string```                  | ```string```               |
| URL           | ```string```                  | [```URL```](#hard-types)   |
| Enum          | ```Enum```                    | ```Enum```                 |
| Relationship  | Reference to Type       | Reference to Type          |

### Hard types
The hard types are types that are not native to typescript, but are often used in the context of a web application. They are generated as classes with methods to validate and parse the data.

| Name | Value |
|------|-------|
| Email | ```${string}@${string}.${string}``` |
| URL | ```${string}://${string}.${string}``` |

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