@drichdev/genata 1.0.1 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,28 +15,53 @@ A lightweight, secure, and TypeScript-first library for generating realistic fak
15
15
  ## 📦 Installation
16
16
 
17
17
  ```bash
18
- npm install genata
18
+ npm install @drichdev/genata
19
19
  # or
20
- yarn add genata
20
+ yarn add @drichdev/genata
21
21
  # or
22
- pnpm add genata
22
+ pnpm add @drichdev/genata
23
23
  ```
24
24
 
25
25
  ## 🎯 Quick Start
26
26
 
27
- ### Basic Usage
27
+ ### CommonJS (Node.js)
28
28
 
29
29
  ```javascript
30
- import genata from "genata";
30
+ const genata = require('@drichdev/genata');
31
31
 
32
- // Generate single values
33
32
  const email = genata.email();
34
33
  const firstName = genata.firstName();
35
34
  const phone = genata.phone();
35
+ ```
36
+
37
+ ### ES Modules (Node.js with "type": "module")
38
+
39
+ ```javascript
40
+ import genata from '@drichdev/genata';
36
41
 
37
- // Generate with options
38
- const password = genata.password({ length: 20 });
39
- const randomInt = genata.datatype.integer({ min: 1, max: 100 });
42
+ const email = genata.email();
43
+ const firstName = genata.firstName();
44
+ const phone = genata.phone();
45
+ ```
46
+
47
+ ### TypeScript / Next.js
48
+
49
+ ```typescript
50
+ import genata from '@drichdev/genata';
51
+
52
+ export default function Home() {
53
+ const email = genata.email();
54
+ const firstName = genata.firstName();
55
+ const phone = genata.phone();
56
+
57
+ return (
58
+ <div>
59
+ <p>Email: {email}</p>
60
+ <p>Name: {firstName}</p>
61
+ <p>Phone: {phone}</p>
62
+ </div>
63
+ );
64
+ }
40
65
  ```
41
66
 
42
67
  ### Using Generators by Category
@@ -146,8 +171,8 @@ Location: address, city, country, zip
146
171
  Internet: url, ipv4, ipv6, credit_card
147
172
  Company: company, job_title
148
173
  Date: date, datetime
149
- Data Types: uuid, boolean, int, float, number, zero_one, id_increment, color
150
- Text: sentence, paragraph
174
+ Data Types: uuid, boolean, int, float, number, zero_one, id_increment, color, hex
175
+ Text: sentence, paragraph, word, slug
151
176
  ```
152
177
 
153
178
  ## 🎛️ API Reference
@@ -299,6 +324,42 @@ For very large batches (>100K records), consider:
299
324
  - Using `generateBatchWithProgress` to show progress
300
325
  - Running in a worker thread if in browser
301
326
 
327
+ ## 📚 Complete Documentation
328
+
329
+ For detailed examples and advanced usage, see [USAGE.md](./USAGE.md)
330
+
331
+ ## 🔧 Import Methods
332
+
333
+ ### CommonJS
334
+ ```javascript
335
+ const genata = require('@drichdev/genata');
336
+ genata.email();
337
+ ```
338
+
339
+ ### ES Modules
340
+ ```javascript
341
+ import genata from '@drichdev/genata';
342
+ genata.email();
343
+ ```
344
+
345
+ ### TypeScript
346
+ ```typescript
347
+ import genata, { type FieldDefinition } from '@drichdev/genata';
348
+ ```
349
+
350
+ ### Next.js / React
351
+ ```typescript
352
+ import genata from '@drichdev/genata';
353
+
354
+ export default function Component() {
355
+ const data = genata.email();
356
+ return <div>{data}</div>;
357
+ }
358
+ ```
359
+
360
+ **⚠️ Note**: If you get a "Module type is not specified" warning, add `"type": "module"` to your `package.json` or use CommonJS require instead.
361
+
302
362
  ---
303
363
 
304
364
  Made with ❤️ by Drichdev
365
+
@@ -1 +1 @@
1
- {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/generators/field.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAW5D,UAAU,sBAAuB,SAAQ,gBAAgB;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,SAAS,EACf,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CA8ET"}
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/generators/field.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAW5D,UAAU,sBAAuB,SAAQ,gBAAgB;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,SAAS,EACf,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAoFT"}
@@ -70,8 +70,14 @@ function generateField(type, options) {
70
70
  return base_1.TextGenerators.paragraph(options);
71
71
  case "sentence":
72
72
  return base_1.TextGenerators.sentence(options);
73
+ case "word":
74
+ return base_1.TextGenerators.word(options);
75
+ case "slug":
76
+ return base_1.TextGenerators.slug(options);
73
77
  case "color":
74
78
  return base_1.DataTypeGenerators.color(options);
79
+ case "hex":
80
+ return base_1.DataTypeGenerators.hex(options);
75
81
  default:
76
82
  throw new Error(`Unknown field type: ${type}`);
77
83
  }
package/dist/index.d.ts CHANGED
@@ -7,7 +7,6 @@
7
7
  * - genata.person.firstName() - generates a first name
8
8
  * - genata.generateBatch([...]) - generates multiple records
9
9
  */
10
- import { PersonGenerators, LocationGenerators, InternetGenerators, CompanyGenerators, DateGenerators, DataTypeGenerators, TextGenerators, generateBatch, generateBatchWithProgress } from "./generators";
11
10
  import type { FieldDefinition, BatchGeneratorOptions } from "./types";
12
11
  /**
13
12
  * Main Genata API
@@ -89,8 +88,5 @@ declare const genata: {
89
88
  resetSeed: () => void;
90
89
  setLocale: (locale: string) => void;
91
90
  };
92
- export default genata;
93
- export * from "./types";
94
- export * from "./validators";
95
- export { PersonGenerators, LocationGenerators, InternetGenerators, CompanyGenerators, DateGenerators, DataTypeGenerators, TextGenerators, generateBatch, generateBatchWithProgress, };
91
+ export = genata;
96
92
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc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whB,CAAC;;;;;;;qBAA2uB,CAAC;;;;;4BA1B/vI,eAAe,EAAE,YACf,qBAAqB;wCAIvB,eAAe,EAAE,YACf,qBAAqB,GAAG;QAAE,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE;oBAI/D,MAAM;;wBASF,MAAM;CAI3B,CAAC;AAEF,SAAS,MAAM,CAAC"}
package/dist/index.js CHANGED
@@ -8,32 +8,7 @@
8
8
  * - genata.person.firstName() - generates a first name
9
9
  * - genata.generateBatch([...]) - generates multiple records
10
10
  */
11
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
- if (k2 === undefined) k2 = k;
13
- var desc = Object.getOwnPropertyDescriptor(m, k);
14
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
- desc = { enumerable: true, get: function() { return m[k]; } };
16
- }
17
- Object.defineProperty(o, k2, desc);
18
- }) : (function(o, m, k, k2) {
19
- if (k2 === undefined) k2 = k;
20
- o[k2] = m[k];
21
- }));
22
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
23
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.generateBatchWithProgress = exports.generateBatch = exports.TextGenerators = exports.DataTypeGenerators = exports.DateGenerators = exports.CompanyGenerators = exports.InternetGenerators = exports.LocationGenerators = exports.PersonGenerators = void 0;
27
11
  const generators_1 = require("./generators");
28
- Object.defineProperty(exports, "PersonGenerators", { enumerable: true, get: function () { return generators_1.PersonGenerators; } });
29
- Object.defineProperty(exports, "LocationGenerators", { enumerable: true, get: function () { return generators_1.LocationGenerators; } });
30
- Object.defineProperty(exports, "InternetGenerators", { enumerable: true, get: function () { return generators_1.InternetGenerators; } });
31
- Object.defineProperty(exports, "CompanyGenerators", { enumerable: true, get: function () { return generators_1.CompanyGenerators; } });
32
- Object.defineProperty(exports, "DateGenerators", { enumerable: true, get: function () { return generators_1.DateGenerators; } });
33
- Object.defineProperty(exports, "DataTypeGenerators", { enumerable: true, get: function () { return generators_1.DataTypeGenerators; } });
34
- Object.defineProperty(exports, "TextGenerators", { enumerable: true, get: function () { return generators_1.TextGenerators; } });
35
- Object.defineProperty(exports, "generateBatch", { enumerable: true, get: function () { return generators_1.generateBatch; } });
36
- Object.defineProperty(exports, "generateBatchWithProgress", { enumerable: true, get: function () { return generators_1.generateBatchWithProgress; } });
37
12
  const faker_1 = require("./utils/faker");
38
13
  const validators_1 = require("./validators");
39
14
  /**
@@ -72,6 +47,4 @@ const genata = {
72
47
  (0, faker_1.initializeFaker)({ locale });
73
48
  },
74
49
  };
75
- exports.default = genata;
76
- __exportStar(require("./types"), exports);
77
- __exportStar(require("./validators"), exports);
50
+ module.exports = genata;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Types and interfaces for Genata data generation
3
3
  */
4
- export type FieldType = "first_name" | "last_name" | "full_name" | "email" | "password" | "phone" | "address" | "city" | "country" | "zip" | "date" | "datetime" | "int" | "float" | "uuid" | "boolean" | "id_increment" | "number" | "zero_one" | "company" | "job_title" | "username" | "url" | "credit_card" | "ipv4" | "ipv6" | "color" | "paragraph" | "sentence";
4
+ export type FieldType = "first_name" | "last_name" | "full_name" | "email" | "password" | "phone" | "address" | "city" | "country" | "zip" | "date" | "datetime" | "int" | "float" | "uuid" | "boolean" | "id_increment" | "number" | "zero_one" | "company" | "job_title" | "username" | "url" | "credit_card" | "ipv4" | "ipv6" | "color" | "hex" | "paragraph" | "sentence" | "word" | "slug";
5
5
  export interface GeneratorOptions {
6
6
  seed?: number;
7
7
  locale?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,WAAW,GACX,WAAW,GACX,OAAO,GACP,UAAU,GACV,OAAO,GACP,SAAS,GACT,MAAM,GACN,SAAS,GACT,KAAK,GACL,MAAM,GACN,UAAU,GACV,KAAK,GACL,OAAO,GACP,MAAM,GACN,SAAS,GACT,cAAc,GACd,QAAQ,GACR,UAAU,GACV,SAAS,GACT,WAAW,GACX,UAAU,GACV,KAAK,GACL,aAAa,GACb,MAAM,GACN,MAAM,GACN,OAAO,GACP,WAAW,GACX,UAAU,CAAC;AAEf,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,WAAW,GACX,WAAW,GACX,OAAO,GACP,UAAU,GACV,OAAO,GACP,SAAS,GACT,MAAM,GACN,SAAS,GACT,KAAK,GACL,MAAM,GACN,UAAU,GACV,KAAK,GACL,OAAO,GACP,MAAM,GACN,SAAS,GACT,cAAc,GACd,QAAQ,GACR,UAAU,GACV,SAAS,GACT,WAAW,GACX,UAAU,GACV,KAAK,GACL,aAAa,GACb,MAAM,GACN,MAAM,GACN,OAAO,GACP,KAAK,G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AgB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,SAAS,CAkCjE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,IAAI,SAAS,CAI1E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEnF,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAI3D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAI7D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAI/D;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAGxE;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAGzE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,SAAS,CAqCjE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,IAAI,SAAS,CAI1E"}
@@ -71,8 +71,11 @@ function isValidFieldType(type) {
71
71
  "ipv4",
72
72
  "ipv6",
73
73
  "color",
74
+ "hex",
74
75
  "paragraph",
75
76
  "sentence",
77
+ "word",
78
+ "slug",
76
79
  ];
77
80
  return typeof type === "string" && validTypes.includes(type);
78
81
  }
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@drichdev/genata",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "Generate realistic fake data easily",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "module": "dist/index.esm.js",
8
7
  "files": [
9
8
  "dist"
10
9
  ],
@@ -22,7 +21,7 @@
22
21
  "testing",
23
22
  "data-generator"
24
23
  ],
25
- "author": "Genata",
24
+ "author": "Drichdev",
26
25
  "license": "MIT",
27
26
  "dependencies": {
28
27
  "@faker-js/faker": "^10.0.0"