Skip to content

Commit 197ce55

Browse files
authored
Merge pull request #1 from Magikfake/release/1.0.0-beta
Release/1.0.0 beta
2 parents 17b247b + ff3252e commit 197ce55

File tree

6 files changed

+41
-25
lines changed

6 files changed

+41
-25
lines changed

README.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11

22
<div align="center">
3-
<img src="./assets/images/logo.svg" width="200"/>
3+
<img src="https://raw.githubusercontent.com/Magikfake/sdk-js/47f342dd8437e809fedb66e0ec0e56901e8520bd/assets/images/logo.svg" alt="Magikfake logo" width="200"/>
44

55
<p>
66
Generate realistic data through AI and the large amount of data stored in our system. The magikfake AI engine is in continuous learning to generate safe data to be used for a specific project</p>
7-
8-
[![npm version](https://badgen.net/npm/v/magikfake)](https://www.npmjs.com/package/magikfake)
9-
[![npm downloads](https://badgen.net/npm/dm/magikfake)](https://www.npmjs.com/package/magikfake)
107
</div>
118

12-
## Features
9+
## 🚀 Features
1310

1411
- 🪄 AI Engine - Fake data are generated through an AI engine.
1512
- 🔆 Flexible scheme - User can define a schema similar to mongoose, using primitive types.
1613
- 🌏 Localization - Data are translated into 5 languages: 🇬🇧, 🇮🇹, 🇪🇸, 🇩🇪, 🇫🇷
17-
- 🏦 Data store - Large amount of data stored in our system.
14+
- 🏦 Dataset - Large amount of dataset in our system.
1815
- 💾 Save schema - User can save a schema to use it at a later time.
1916

20-
## Install
17+
## 📦 Install
2118

2219
```bash
23-
npm install magikfake
20+
npm install magikfake@beta
2421
```
2522

2623
---
@@ -31,7 +28,7 @@ Use it for testing now.
3128

3229
---
3330

34-
## Introduction
31+
## 🪄 Introduction
3532

3633
Magikfake was created to leverage the power of **AI** in generating data that closely resembles real-world data.
3734

@@ -51,7 +48,7 @@ For each property defined, the system analyzes the key and type to generate the
5148

5249
Unlike other fake data generation systems, Magikfake simplifies schema definition by allowing the user to assign a **primitive** type (**string**, **number**, **date**, **boolean**, **objectId**, etc...) to each property, without the need for a custom type to obtain the desired value.
5350

54-
## Usage and access limits
51+
## 💻 Usage and access limits
5552

5653
To use Magikfake's library for generating fake data, users must obtain an API key. This can be done by registering for an account on the Magikfake website at the following link: https://app.magikfake.com.
5754

@@ -65,11 +62,11 @@ By obtaining an API key and subscribing to a Magikfake plan, users can quickly a
6562
| Standard | Available in the official version | Available in the official version |
6663
| Pro | Available in the official version | Available in the official version |
6764

68-
## Try it online
65+
## ⚡️ Try it online
6966

7067
You can try Magikfake online by visiting https://magikfake.com. 1,000,000 tokens are available daily and shared among site users. If you run out of tokens, you can register on the site to take advantage of the 25,000 tokens available monthly.
7168

72-
## Supported types and validations
69+
## 📖 Supported types and validations
7370

7471
Magikfake supports a variety of primitive types that can be assigned to the properties in the schema.
7572

@@ -161,7 +158,7 @@ The types supported are:
161158
| <pre lang="json">{&#13; "users": [&#13; { &#13; "id": "objectId",&#13; "firstName": "string", &#13; "lastName": "string", &#13; "age": "number", &#13; "isFirstLogin": "boolean", &#13; "birthDate": "date" &#13; }&#13; ]&#13;}</pre>or<pre lang="json">{&#13; "users": {&#13; "type": [{ &#13; "id": "objectId",&#13; "firstName": "string", &#13; "lastName": "string", &#13; "age": "number", &#13; "isFirstLogin": "boolean", &#13; "birthDate": "date" &#13; }]&#13; }&#13;}</pre> | the **users** field of type **array** indicates a list of values of type object, where it is possible to define fields of various types. |
162159

163160

164-
## Schema example
161+
## 📜 Schema example
165162

166163
Here is a schema example with various types of fields:
167164

@@ -202,7 +199,7 @@ The fake data generated will have this type of structure:
202199
The result will try to provide a compatibility between the keys and the types, this to make the data as truthful as possible.
203200

204201

205-
## Fake data
202+
## 🎯​ Fake data
206203

207204
### Generate fake data
208205

@@ -230,8 +227,8 @@ const client = new Client({apiKey: 'your-api-key'});
230227
const query = {
231228
language: Language.en, // required: The values available are: en, it, es, de, fr.
232229
topic: 'user', // required: A casual string that represents the topic
233-
context: Context.library // optional: The business context of your data. It is possible to choose certain values. See Context enum values.
234-
limit: 4 // optional: The number of records to generate.
230+
context: Context.library, // optional: The business context of your data. It is possible to choose certain values. See Context enum values.
231+
limit: 4, // optional: The number of records to generate.
235232
schema: {
236233
id: 'objectId',
237234
name: {
@@ -316,8 +313,9 @@ const fakeData = await client.fakeData.generate(query)
316313
},
317314
],
318315
"tokenStatus": {
316+
"tokensConsumedForRequest": 5000, // Indicates the number of tokens consumed for the request
319317
"tokensOverflow": 0, // Indicates the number of token that overflowed the plan
320-
"tokenLimit": 500, // Number of token per month included in the plan
318+
"tokenLimit": 25000, // Number of token per month included in the plan
321319
"tokenRemaining": 500, // Number of token remaining
322320
"tokenResetDate": "Sat, 17 Jun 2023 08:17:07 GMT" // Indicates the date for the token reset
323321
}
@@ -334,7 +332,7 @@ import {Client, Language, Context }from 'magikfake';
334332

335333
const client = new Client({apiKey: 'your-api-key'});
336334

337-
const fakeData = await client.fakeData.tokenStatus()
335+
const tokenStatus = await client.fakeData.tokenStatus()
338336
```
339337
**Response example**
340338
```json
@@ -351,7 +349,7 @@ const fakeData = await client.fakeData.tokenStatus()
351349
tokenStatus(): Promise<ITokenStatus>
352350
```
353351

354-
## Schema
352+
## 📜 Schema
355353

356354
With Magikfake, users have the ability to save their defined schema for future use.
357355

@@ -667,7 +665,7 @@ const response = await client.schema.delete("642ab202f419d954a2b35605")
667665
true
668666
```
669667

670-
## Errors
668+
## Errors
671669

672670
When using the methods provided by the Magikfake library, it is possible that an exception may be raised. If this occurs, the user will receive an error message indicating the nature of the issue.
673671

@@ -681,7 +679,7 @@ Some of the errors that may be encountered include:
681679
In any of these cases, the user should review their code and make any necessary corrections or updates to address the error. By working with the Magikfake library and handling errors appropriately, users can generate high-quality, realistic fake data for a variety of purposes.
682680

683681

684-
## Supports and issue
682+
## 🆘 Support and issue
685683

686684
If you need support you can contact us at the following email: [email protected].
687685

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "magikfake-sdk",
2+
"name": "magikfake",
33
"version": "1.0.0-beta",
44
"description": "Generate realistic data through AI and the large amount of data stored in our system.",
55
"main": "dist/index.js",

src/errors.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,11 @@ export class InvalidAuthorization extends Error {
2020
constructor(message: string) {
2121
super(message);
2222
}
23-
}
23+
}
24+
25+
export class PaymentRequired extends Error {
26+
27+
constructor(message: string) {
28+
super(message);
29+
}
30+
}

src/fake-data/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class FakeData extends Base {
5252
return {
5353
data: body.data,
5454
tokenStatus: {
55+
tokensConsumedForRequest: parseInt(headers.get('x-tokens-consumed-for-request')),
5556
tokensOverflow: parseInt(headers.get('x-tokens-overflow')),
5657
tokenLimit: parseInt(headers.get('x-token-limit')),
5758
tokenRemaining: parseInt(headers.get('x-token-remaining')),
@@ -63,7 +64,7 @@ export class FakeData extends Base {
6364
/**
6465
* Token status related to the generation of fake data.
6566
*
66-
* const fakeData = await client.fakeData.tokenStatus()
67+
* const tokenStatus = await client.fakeData.tokenStatus()
6768
*
6869
* @returns {Promise<ITokenStatus>} The promise resolves to an object.
6970
*/

src/fake-data/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface IFakeDataQuery {
99
}
1010

1111
export interface ITokenStatus {
12+
tokensConsumedForRequest?: number,
1213
tokensOverflow: number,
1314
tokenLimit: number,
1415
tokenRemaining: number,

src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { FakeData } from './fake-data';
22
import { Schema } from './schema';
3+
import { IFakeDataQuery, ITokenStatus } from "./fake-data/types";
4+
import { ISchemaQuery, ISchemaParams, ISchema } from "./schema/types";
5+
import { Language, Context, SchemaType } from "./types";
6+
import { BadRequestError, TooManyRequestsError, InvalidAuthorization, PaymentRequired } from "./errors";
37

48
export class Client {
59
fakeData: FakeData;
@@ -14,4 +18,9 @@ export class Client {
1418
this.fakeData = new FakeData(config);
1519
this.schema = new Schema(config);
1620
}
17-
}
21+
}
22+
23+
export { Language, Context, SchemaType };
24+
export { BadRequestError, TooManyRequestsError, InvalidAuthorization, PaymentRequired }
25+
export { IFakeDataQuery, ITokenStatus };
26+
export { ISchemaQuery, ISchemaParams, ISchema };

0 commit comments

Comments
 (0)