@drichdev/genata 1.0.0
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/LICENSE +21 -0
- package/README.md +304 -0
- package/dist/examples.d.ts +49 -0
- package/dist/examples.d.ts.map +1 -0
- package/dist/examples.js +224 -0
- package/dist/generators/base.d.ts +65 -0
- package/dist/generators/base.d.ts.map +1 -0
- package/dist/generators/base.js +199 -0
- package/dist/generators/batch.d.ts +12 -0
- package/dist/generators/batch.d.ts.map +1 -0
- package/dist/generators/batch.js +61 -0
- package/dist/generators/field.d.ts +10 -0
- package/dist/generators/field.d.ts.map +1 -0
- package/dist/generators/field.js +78 -0
- package/dist/generators/index.d.ts +7 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +19 -0
- package/dist/index.d.ts +96 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +77 -0
- package/dist/types/index.d.ts +24 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/utils/faker.d.ts +18 -0
- package/dist/utils/faker.d.ts.map +1 -0
- package/dist/utils/faker.js +42 -0
- package/dist/validators/index.d.ts +16 -0
- package/dist/validators/index.d.ts.map +1 -0
- package/dist/validators/index.js +87 -0
- package/package.json +42 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Basic data generators
|
|
4
|
+
* Security: All inputs are validated and sanitized
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.TextGenerators = exports.DataTypeGenerators = exports.DateGenerators = exports.CompanyGenerators = exports.InternetGenerators = exports.LocationGenerators = exports.PersonGenerators = void 0;
|
|
8
|
+
const faker_1 = require("../utils/faker");
|
|
9
|
+
const validators_1 = require("../validators");
|
|
10
|
+
exports.PersonGenerators = {
|
|
11
|
+
firstName: (options) => {
|
|
12
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
13
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
14
|
+
return faker.person.firstName();
|
|
15
|
+
},
|
|
16
|
+
lastName: (options) => {
|
|
17
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
18
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
19
|
+
return faker.person.lastName();
|
|
20
|
+
},
|
|
21
|
+
fullName: (options) => {
|
|
22
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
23
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
24
|
+
return faker.person.fullName();
|
|
25
|
+
},
|
|
26
|
+
email: (options) => {
|
|
27
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
28
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
29
|
+
return faker.internet.email().toLowerCase();
|
|
30
|
+
},
|
|
31
|
+
username: (options) => {
|
|
32
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
33
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
34
|
+
return faker.internet.username().toLowerCase();
|
|
35
|
+
},
|
|
36
|
+
password: (options) => {
|
|
37
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
38
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
39
|
+
const length = options?.length || 16;
|
|
40
|
+
if (length < 8 || length > 128) {
|
|
41
|
+
throw new Error("Password length must be between 8 and 128 characters");
|
|
42
|
+
}
|
|
43
|
+
return faker.internet.password({ length });
|
|
44
|
+
},
|
|
45
|
+
phone: (options) => {
|
|
46
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
47
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
48
|
+
return faker.phone.number();
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
exports.LocationGenerators = {
|
|
52
|
+
address: (options) => {
|
|
53
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
54
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
55
|
+
return faker.location.streetAddress();
|
|
56
|
+
},
|
|
57
|
+
city: (options) => {
|
|
58
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
59
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
60
|
+
return faker.location.city();
|
|
61
|
+
},
|
|
62
|
+
country: (options) => {
|
|
63
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
64
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
65
|
+
return faker.location.country();
|
|
66
|
+
},
|
|
67
|
+
zipCode: (options) => {
|
|
68
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
69
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
70
|
+
return faker.location.zipCode();
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
exports.InternetGenerators = {
|
|
74
|
+
url: (options) => {
|
|
75
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
76
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
77
|
+
return faker.internet.url();
|
|
78
|
+
},
|
|
79
|
+
ipv4: (options) => {
|
|
80
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
81
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
82
|
+
return faker.internet.ipv4();
|
|
83
|
+
},
|
|
84
|
+
ipv6: (options) => {
|
|
85
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
86
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
87
|
+
return faker.internet.ipv6();
|
|
88
|
+
},
|
|
89
|
+
creditCard: (options) => {
|
|
90
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
91
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
92
|
+
return faker.finance.creditCardNumber();
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
exports.CompanyGenerators = {
|
|
96
|
+
company: (options) => {
|
|
97
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
98
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
99
|
+
return faker.company.name();
|
|
100
|
+
},
|
|
101
|
+
jobTitle: (options) => {
|
|
102
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
103
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
104
|
+
return faker.person.jobTitle();
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
exports.DateGenerators = {
|
|
108
|
+
date: (options) => {
|
|
109
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
110
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
111
|
+
return faker.date.past().toISOString().split("T")[0];
|
|
112
|
+
},
|
|
113
|
+
dateTime: (options) => {
|
|
114
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
115
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
116
|
+
return faker.date.recent().toISOString();
|
|
117
|
+
},
|
|
118
|
+
futureDate: (options) => {
|
|
119
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
120
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
121
|
+
return faker.date.future().toISOString().split("T")[0];
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
exports.DataTypeGenerators = {
|
|
125
|
+
uuid: (options) => {
|
|
126
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
127
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
128
|
+
return faker.string.uuid();
|
|
129
|
+
},
|
|
130
|
+
boolean: (options) => {
|
|
131
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
132
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
133
|
+
return faker.datatype.boolean();
|
|
134
|
+
},
|
|
135
|
+
integer: (options) => {
|
|
136
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
137
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
138
|
+
const min = options?.min ?? 0;
|
|
139
|
+
const max = options?.max ?? 100;
|
|
140
|
+
if (min >= max) {
|
|
141
|
+
throw new Error("Min must be less than max");
|
|
142
|
+
}
|
|
143
|
+
return faker.number.int({ min, max });
|
|
144
|
+
},
|
|
145
|
+
float: (options) => {
|
|
146
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
147
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
148
|
+
const min = options?.min ?? 0;
|
|
149
|
+
const max = options?.max ?? 100;
|
|
150
|
+
const decimals = options?.decimals ?? 2;
|
|
151
|
+
if (min >= max) {
|
|
152
|
+
throw new Error("Min must be less than max");
|
|
153
|
+
}
|
|
154
|
+
if (decimals < 0 || decimals > 10) {
|
|
155
|
+
throw new Error("Decimals must be between 0 and 10");
|
|
156
|
+
}
|
|
157
|
+
return faker.number.float({ min, max, fractionDigits: decimals });
|
|
158
|
+
},
|
|
159
|
+
hex: (options) => {
|
|
160
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
161
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
162
|
+
const length = options?.length ?? 8;
|
|
163
|
+
if (length < 1 || length > 256) {
|
|
164
|
+
throw new Error("Hex length must be between 1 and 256");
|
|
165
|
+
}
|
|
166
|
+
return faker.string.hexadecimal({ length });
|
|
167
|
+
},
|
|
168
|
+
color: (options) => {
|
|
169
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
170
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
171
|
+
return faker.color.rgb();
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
exports.TextGenerators = {
|
|
175
|
+
sentence: (options) => {
|
|
176
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
177
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
178
|
+
return faker.lorem.sentence();
|
|
179
|
+
},
|
|
180
|
+
paragraph: (options) => {
|
|
181
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
182
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
183
|
+
const sentences = options?.sentences ?? 3;
|
|
184
|
+
if (sentences < 1 || sentences > 20) {
|
|
185
|
+
throw new Error("Sentences must be between 1 and 20");
|
|
186
|
+
}
|
|
187
|
+
return faker.lorem.paragraphs(sentences);
|
|
188
|
+
},
|
|
189
|
+
word: (options) => {
|
|
190
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
191
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
192
|
+
return faker.lorem.word();
|
|
193
|
+
},
|
|
194
|
+
slug: (options) => {
|
|
195
|
+
(0, validators_1.validateGeneratorOptions)(options || {});
|
|
196
|
+
const faker = (0, faker_1.getFaker)(options);
|
|
197
|
+
return faker.lorem.slug();
|
|
198
|
+
},
|
|
199
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batch data generation - Generate multiple records at once
|
|
3
|
+
*/
|
|
4
|
+
import type { FieldDefinition, BatchGeneratorOptions } from "../types";
|
|
5
|
+
export declare function generateBatch(fields: FieldDefinition[], options?: BatchGeneratorOptions): Record<string, unknown>[];
|
|
6
|
+
/**
|
|
7
|
+
* Generate a single batch with progress tracking
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateBatchWithProgress(fields: FieldDefinition[], options?: BatchGeneratorOptions & {
|
|
10
|
+
onProgress?: (progress: number) => void;
|
|
11
|
+
}): Record<string, unknown>[];
|
|
12
|
+
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/generators/batch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAIvE,wBAAgB,aAAa,CAC3B,MAAM,EAAE,eAAe,EAAE,EACzB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CA6B3B;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,eAAe,EAAE,EACzB,OAAO,CAAC,EAAE,qBAAqB,GAAG;IAAE,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GAC5E,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAiC3B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Batch data generation - Generate multiple records at once
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateBatch = generateBatch;
|
|
7
|
+
exports.generateBatchWithProgress = generateBatchWithProgress;
|
|
8
|
+
const validators_1 = require("../validators");
|
|
9
|
+
const field_1 = require("./field");
|
|
10
|
+
function generateBatch(fields, options) {
|
|
11
|
+
(0, validators_1.validateBatchOptions)(options || {});
|
|
12
|
+
if (!Array.isArray(fields) || fields.length === 0) {
|
|
13
|
+
throw new Error("Fields must be a non-empty array");
|
|
14
|
+
}
|
|
15
|
+
// Validate all field types before generating
|
|
16
|
+
fields.forEach((field) => {
|
|
17
|
+
(0, validators_1.validateFieldType)(field.type);
|
|
18
|
+
});
|
|
19
|
+
const count = options?.count ?? 100;
|
|
20
|
+
const data = [];
|
|
21
|
+
for (let i = 0; i < count; i++) {
|
|
22
|
+
const row = {};
|
|
23
|
+
for (const field of fields) {
|
|
24
|
+
row[field.name] = (0, field_1.generateField)(field.type, {
|
|
25
|
+
...options,
|
|
26
|
+
index: i,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
data.push(row);
|
|
30
|
+
}
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Generate a single batch with progress tracking
|
|
35
|
+
*/
|
|
36
|
+
function generateBatchWithProgress(fields, options) {
|
|
37
|
+
(0, validators_1.validateBatchOptions)(options || {});
|
|
38
|
+
if (!Array.isArray(fields) || fields.length === 0) {
|
|
39
|
+
throw new Error("Fields must be a non-empty array");
|
|
40
|
+
}
|
|
41
|
+
fields.forEach((field) => {
|
|
42
|
+
(0, validators_1.validateFieldType)(field.type);
|
|
43
|
+
});
|
|
44
|
+
const count = options?.count ?? 100;
|
|
45
|
+
const data = [];
|
|
46
|
+
const onProgress = options?.onProgress;
|
|
47
|
+
for (let i = 0; i < count; i++) {
|
|
48
|
+
const row = {};
|
|
49
|
+
for (const field of fields) {
|
|
50
|
+
row[field.name] = (0, field_1.generateField)(field.type, {
|
|
51
|
+
...options,
|
|
52
|
+
index: i,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
data.push(row);
|
|
56
|
+
if (onProgress) {
|
|
57
|
+
onProgress(Math.round(((i + 1) / count) * 100));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return data;
|
|
61
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field-level data generation based on field type
|
|
3
|
+
*/
|
|
4
|
+
import type { FieldType, GeneratorOptions } from "../types";
|
|
5
|
+
interface FieldGenerationOptions extends GeneratorOptions {
|
|
6
|
+
index?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function generateField(type: FieldType, options?: FieldGenerationOptions): unknown;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=field.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Field-level data generation based on field type
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateField = generateField;
|
|
7
|
+
const base_1 = require("./base");
|
|
8
|
+
function generateField(type, options) {
|
|
9
|
+
const index = options?.index ?? 0;
|
|
10
|
+
switch (type) {
|
|
11
|
+
// Personal Information
|
|
12
|
+
case "first_name":
|
|
13
|
+
return base_1.PersonGenerators.firstName(options);
|
|
14
|
+
case "last_name":
|
|
15
|
+
return base_1.PersonGenerators.lastName(options);
|
|
16
|
+
case "full_name":
|
|
17
|
+
return base_1.PersonGenerators.fullName(options);
|
|
18
|
+
case "email":
|
|
19
|
+
return base_1.PersonGenerators.email(options);
|
|
20
|
+
case "username":
|
|
21
|
+
return base_1.PersonGenerators.username(options);
|
|
22
|
+
case "password":
|
|
23
|
+
return base_1.PersonGenerators.password(options);
|
|
24
|
+
case "phone":
|
|
25
|
+
return base_1.PersonGenerators.phone(options);
|
|
26
|
+
// Location
|
|
27
|
+
case "address":
|
|
28
|
+
return base_1.LocationGenerators.address(options);
|
|
29
|
+
case "city":
|
|
30
|
+
return base_1.LocationGenerators.city(options);
|
|
31
|
+
case "country":
|
|
32
|
+
return base_1.LocationGenerators.country(options);
|
|
33
|
+
case "zip":
|
|
34
|
+
return base_1.LocationGenerators.zipCode(options);
|
|
35
|
+
// Internet
|
|
36
|
+
case "url":
|
|
37
|
+
return base_1.InternetGenerators.url(options);
|
|
38
|
+
case "ipv4":
|
|
39
|
+
return base_1.InternetGenerators.ipv4(options);
|
|
40
|
+
case "ipv6":
|
|
41
|
+
return base_1.InternetGenerators.ipv6(options);
|
|
42
|
+
case "credit_card":
|
|
43
|
+
return base_1.InternetGenerators.creditCard(options);
|
|
44
|
+
// Company
|
|
45
|
+
case "company":
|
|
46
|
+
return base_1.CompanyGenerators.company(options);
|
|
47
|
+
case "job_title":
|
|
48
|
+
return base_1.CompanyGenerators.jobTitle(options);
|
|
49
|
+
// Date/Time
|
|
50
|
+
case "date":
|
|
51
|
+
return base_1.DateGenerators.date(options);
|
|
52
|
+
case "datetime":
|
|
53
|
+
return base_1.DateGenerators.dateTime(options);
|
|
54
|
+
// Data Types
|
|
55
|
+
case "uuid":
|
|
56
|
+
return base_1.DataTypeGenerators.uuid(options);
|
|
57
|
+
case "boolean":
|
|
58
|
+
return base_1.DataTypeGenerators.boolean(options);
|
|
59
|
+
case "int":
|
|
60
|
+
case "number":
|
|
61
|
+
return base_1.DataTypeGenerators.integer(options);
|
|
62
|
+
case "float":
|
|
63
|
+
return base_1.DataTypeGenerators.float(options);
|
|
64
|
+
case "zero_one":
|
|
65
|
+
return base_1.DataTypeGenerators.integer({ ...options, min: 0, max: 1 });
|
|
66
|
+
case "id_increment":
|
|
67
|
+
return index + 1;
|
|
68
|
+
// Text
|
|
69
|
+
case "paragraph":
|
|
70
|
+
return base_1.TextGenerators.paragraph(options);
|
|
71
|
+
case "sentence":
|
|
72
|
+
return base_1.TextGenerators.sentence(options);
|
|
73
|
+
case "color":
|
|
74
|
+
return base_1.DataTypeGenerators.color(options);
|
|
75
|
+
default:
|
|
76
|
+
throw new Error(`Unknown field type: ${type}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generators index - Export all generators
|
|
3
|
+
*/
|
|
4
|
+
export { generateBatch, generateBatchWithProgress } from "./batch";
|
|
5
|
+
export { generateField } from "./field";
|
|
6
|
+
export { PersonGenerators, LocationGenerators, InternetGenerators, CompanyGenerators, DateGenerators, DataTypeGenerators, TextGenerators, } from "./base";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generators/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,cAAc,GACf,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generators index - Export all generators
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TextGenerators = exports.DataTypeGenerators = exports.DateGenerators = exports.CompanyGenerators = exports.InternetGenerators = exports.LocationGenerators = exports.PersonGenerators = exports.generateField = exports.generateBatchWithProgress = exports.generateBatch = void 0;
|
|
7
|
+
var batch_1 = require("./batch");
|
|
8
|
+
Object.defineProperty(exports, "generateBatch", { enumerable: true, get: function () { return batch_1.generateBatch; } });
|
|
9
|
+
Object.defineProperty(exports, "generateBatchWithProgress", { enumerable: true, get: function () { return batch_1.generateBatchWithProgress; } });
|
|
10
|
+
var field_1 = require("./field");
|
|
11
|
+
Object.defineProperty(exports, "generateField", { enumerable: true, get: function () { return field_1.generateField; } });
|
|
12
|
+
var base_1 = require("./base");
|
|
13
|
+
Object.defineProperty(exports, "PersonGenerators", { enumerable: true, get: function () { return base_1.PersonGenerators; } });
|
|
14
|
+
Object.defineProperty(exports, "LocationGenerators", { enumerable: true, get: function () { return base_1.LocationGenerators; } });
|
|
15
|
+
Object.defineProperty(exports, "InternetGenerators", { enumerable: true, get: function () { return base_1.InternetGenerators; } });
|
|
16
|
+
Object.defineProperty(exports, "CompanyGenerators", { enumerable: true, get: function () { return base_1.CompanyGenerators; } });
|
|
17
|
+
Object.defineProperty(exports, "DateGenerators", { enumerable: true, get: function () { return base_1.DateGenerators; } });
|
|
18
|
+
Object.defineProperty(exports, "DataTypeGenerators", { enumerable: true, get: function () { return base_1.DataTypeGenerators; } });
|
|
19
|
+
Object.defineProperty(exports, "TextGenerators", { enumerable: true, get: function () { return base_1.TextGenerators; } });
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genata Core - Main API
|
|
3
|
+
* Simple and intuitive interface for data generation
|
|
4
|
+
*
|
|
5
|
+
* Usage examples:
|
|
6
|
+
* - genata.email() - generates a random email
|
|
7
|
+
* - genata.person.firstName() - generates a first name
|
|
8
|
+
* - genata.generateBatch([...]) - generates multiple records
|
|
9
|
+
*/
|
|
10
|
+
import { PersonGenerators, LocationGenerators, InternetGenerators, CompanyGenerators, DateGenerators, DataTypeGenerators, TextGenerators, generateBatch, generateBatchWithProgress } from "./generators";
|
|
11
|
+
import type { FieldDefinition, BatchGeneratorOptions } from "./types";
|
|
12
|
+
/**
|
|
13
|
+
* Main Genata API
|
|
14
|
+
*/
|
|
15
|
+
declare const genata: {
|
|
16
|
+
email: () => string;
|
|
17
|
+
firstName: () => string;
|
|
18
|
+
lastName: () => string;
|
|
19
|
+
fullName: () => string;
|
|
20
|
+
username: () => string;
|
|
21
|
+
password: (options?: {
|
|
22
|
+
length?: number;
|
|
23
|
+
}) => string;
|
|
24
|
+
phone: () => string;
|
|
25
|
+
person: {
|
|
26
|
+
firstName: (options?: import("./types").GeneratorOptions) => string;
|
|
27
|
+
lastName: (options?: import("./types").GeneratorOptions) => string;
|
|
28
|
+
fullName: (options?: import("./types").GeneratorOptions) => string;
|
|
29
|
+
email: (options?: import("./types").GeneratorOptions) => string;
|
|
30
|
+
username: (options?: import("./types").GeneratorOptions) => string;
|
|
31
|
+
password: (options?: import("./types").GeneratorOptions & {
|
|
32
|
+
length?: number;
|
|
33
|
+
}) => string;
|
|
34
|
+
phone: (options?: import("./types").GeneratorOptions) => string;
|
|
35
|
+
};
|
|
36
|
+
location: {
|
|
37
|
+
address: (options?: import("./types").GeneratorOptions) => string;
|
|
38
|
+
city: (options?: import("./types").GeneratorOptions) => string;
|
|
39
|
+
country: (options?: import("./types").GeneratorOptions) => string;
|
|
40
|
+
zipCode: (options?: import("./types").GeneratorOptions) => string;
|
|
41
|
+
};
|
|
42
|
+
internet: {
|
|
43
|
+
url: (options?: import("./types").GeneratorOptions) => string;
|
|
44
|
+
ipv4: (options?: import("./types").GeneratorOptions) => string;
|
|
45
|
+
ipv6: (options?: import("./types").GeneratorOptions) => string;
|
|
46
|
+
creditCard: (options?: import("./types").GeneratorOptions) => string;
|
|
47
|
+
};
|
|
48
|
+
company: {
|
|
49
|
+
company: (options?: import("./types").GeneratorOptions) => string;
|
|
50
|
+
jobTitle: (options?: import("./types").GeneratorOptions) => string;
|
|
51
|
+
};
|
|
52
|
+
date: {
|
|
53
|
+
date: (options?: import("./types").GeneratorOptions & {
|
|
54
|
+
format?: string;
|
|
55
|
+
}) => string;
|
|
56
|
+
dateTime: (options?: import("./types").GeneratorOptions) => string;
|
|
57
|
+
futureDate: (options?: import("./types").GeneratorOptions) => string;
|
|
58
|
+
};
|
|
59
|
+
datatype: {
|
|
60
|
+
uuid: (options?: import("./types").GeneratorOptions) => string;
|
|
61
|
+
boolean: (options?: import("./types").GeneratorOptions) => boolean;
|
|
62
|
+
integer: (options?: import("./types").GeneratorOptions & {
|
|
63
|
+
min?: number;
|
|
64
|
+
max?: number;
|
|
65
|
+
}) => number;
|
|
66
|
+
float: (options?: import("./types").GeneratorOptions & {
|
|
67
|
+
min?: number;
|
|
68
|
+
max?: number;
|
|
69
|
+
decimals?: number;
|
|
70
|
+
}) => number;
|
|
71
|
+
hex: (options?: import("./types").GeneratorOptions & {
|
|
72
|
+
length?: number;
|
|
73
|
+
}) => string;
|
|
74
|
+
color: (options?: import("./types").GeneratorOptions) => string;
|
|
75
|
+
};
|
|
76
|
+
text: {
|
|
77
|
+
sentence: (options?: import("./types").GeneratorOptions) => string;
|
|
78
|
+
paragraph: (options?: import("./types").GeneratorOptions & {
|
|
79
|
+
sentences?: number;
|
|
80
|
+
}) => string;
|
|
81
|
+
word: (options?: import("./types").GeneratorOptions) => string;
|
|
82
|
+
slug: (options?: import("./types").GeneratorOptions) => string;
|
|
83
|
+
};
|
|
84
|
+
generateBatch: (fields: FieldDefinition[], options?: BatchGeneratorOptions) => Record<string, unknown>[];
|
|
85
|
+
generateBatchWithProgress: (fields: FieldDefinition[], options?: BatchGeneratorOptions & {
|
|
86
|
+
onProgress?: (progress: number) => void;
|
|
87
|
+
}) => Record<string, unknown>[];
|
|
88
|
+
setSeed: (seed: number) => void;
|
|
89
|
+
resetSeed: () => void;
|
|
90
|
+
setLocale: (locale: string) => void;
|
|
91
|
+
};
|
|
92
|
+
export default genata;
|
|
93
|
+
export * from "./types";
|
|
94
|
+
export * from "./validators";
|
|
95
|
+
export { PersonGenerators, LocationGenerators, InternetGenerators, CompanyGenerators, DateGenerators, DataTypeGenerators, TextGenerators, generateBatch, generateBatchWithProgress, };
|
|
96
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,EACd,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,yBAAyB,EAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAItE;;GAEG;AACH,QAAA,MAAM,MAAM;;;;;;yBAOW;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;kBAOnC,CAAC;;;;;;;;;;;;;;;;;;;;;;kBA+C+3C,CAAC;;;;;;;;;eAAq+B,CAAC;eAAa,CAAC;;;eAAkW,CAAC;eAAa,CAAC;oBAAkB,CAAC;;;kBAAwhB,CAAC;;;;;;;qBAA2uB,CAAC;;;;;4BAvCz/H,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,eAAe,MAAM,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,yBAAyB,GAC1B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Genata Core - Main API
|
|
4
|
+
* Simple and intuitive interface for data generation
|
|
5
|
+
*
|
|
6
|
+
* Usage examples:
|
|
7
|
+
* - genata.email() - generates a random email
|
|
8
|
+
* - genata.person.firstName() - generates a first name
|
|
9
|
+
* - genata.generateBatch([...]) - generates multiple records
|
|
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
|
+
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
|
+
const faker_1 = require("./utils/faker");
|
|
38
|
+
const validators_1 = require("./validators");
|
|
39
|
+
/**
|
|
40
|
+
* Main Genata API
|
|
41
|
+
*/
|
|
42
|
+
const genata = {
|
|
43
|
+
// Direct access to most common generators
|
|
44
|
+
email: () => generators_1.PersonGenerators.email(),
|
|
45
|
+
firstName: () => generators_1.PersonGenerators.firstName(),
|
|
46
|
+
lastName: () => generators_1.PersonGenerators.lastName(),
|
|
47
|
+
fullName: () => generators_1.PersonGenerators.fullName(),
|
|
48
|
+
username: () => generators_1.PersonGenerators.username(),
|
|
49
|
+
password: (options) => generators_1.PersonGenerators.password(options),
|
|
50
|
+
phone: () => generators_1.PersonGenerators.phone(),
|
|
51
|
+
// Grouped generators by category
|
|
52
|
+
person: generators_1.PersonGenerators,
|
|
53
|
+
location: generators_1.LocationGenerators,
|
|
54
|
+
internet: generators_1.InternetGenerators,
|
|
55
|
+
company: generators_1.CompanyGenerators,
|
|
56
|
+
date: generators_1.DateGenerators,
|
|
57
|
+
datatype: generators_1.DataTypeGenerators,
|
|
58
|
+
text: generators_1.TextGenerators,
|
|
59
|
+
// Batch generation
|
|
60
|
+
generateBatch: (fields, options) => (0, generators_1.generateBatch)(fields, options),
|
|
61
|
+
generateBatchWithProgress: (fields, options) => (0, generators_1.generateBatchWithProgress)(fields, options),
|
|
62
|
+
// Configuration
|
|
63
|
+
setSeed: (seed) => {
|
|
64
|
+
(0, validators_1.validateGeneratorOptions)({ seed });
|
|
65
|
+
(0, faker_1.initializeFaker)({ seed });
|
|
66
|
+
},
|
|
67
|
+
resetSeed: () => {
|
|
68
|
+
(0, faker_1.resetFaker)();
|
|
69
|
+
},
|
|
70
|
+
setLocale: (locale) => {
|
|
71
|
+
(0, validators_1.validateGeneratorOptions)({ locale });
|
|
72
|
+
(0, faker_1.initializeFaker)({ locale });
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
exports.default = genata;
|
|
76
|
+
__exportStar(require("./types"), exports);
|
|
77
|
+
__exportStar(require("./validators"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types and interfaces for Genata data generation
|
|
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";
|
|
5
|
+
export interface GeneratorOptions {
|
|
6
|
+
seed?: number;
|
|
7
|
+
locale?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface FieldDefinition {
|
|
10
|
+
name: string;
|
|
11
|
+
type: FieldType;
|
|
12
|
+
options?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export interface BatchGeneratorOptions extends GeneratorOptions {
|
|
15
|
+
count?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface GeneratorConfig {
|
|
18
|
+
minLength?: number;
|
|
19
|
+
maxLength?: number;
|
|
20
|
+
format?: string;
|
|
21
|
+
pattern?: string;
|
|
22
|
+
excludeSpecialChars?: boolean;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Faker wrapper with seeding support
|
|
3
|
+
*/
|
|
4
|
+
import { Faker } from "@faker-js/faker";
|
|
5
|
+
import type { GeneratorOptions } from "../types";
|
|
6
|
+
/**
|
|
7
|
+
* Initialize the global faker instance with optional seed
|
|
8
|
+
*/
|
|
9
|
+
export declare function initializeFaker(options?: GeneratorOptions): Faker;
|
|
10
|
+
/**
|
|
11
|
+
* Get the current faker instance
|
|
12
|
+
*/
|
|
13
|
+
export declare function getFaker(options?: GeneratorOptions): Faker;
|
|
14
|
+
/**
|
|
15
|
+
* Reset faker to a new random state
|
|
16
|
+
*/
|
|
17
|
+
export declare function resetFaker(): void;
|
|
18
|
+
//# sourceMappingURL=faker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"faker.d.ts","sourceRoot":"","sources":["../../src/utils/faker.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAM,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAIjD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,KAAK,CAejE;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,KAAK,CAE1D;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAEjC"}
|