UNPKG

17.4 kBTypeScriptView Raw
1// Type definitions for faker 5.5
2// Project: http://marak.com/faker.js/
3// Definitions by: Ben Swartz <https://github.com/bensw>
4// Bas Pennings <https://github.com/basp>
5// Yuki Kokubun <https://github.com/Kuniwak>
6// Matt Bishop <https://github.com/mattbishop>
7// Leonardo Testa <https://github.com/testica>
8// Sebastian Pettersson <https://github.com/TastefulElk>
9// Daniel Montesinos <https://github.com/damonpam>
10// Shinya Ohyanagi <https://github.com/heavenshell>
11// Piotr Kuczynski <https://github.com/pkuczynski>
12// Jérémie Parker <https://github.com/p-j>
13// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
14
15declare const fakerStatic: Faker.FakerStatic;
16
17declare namespace Faker {
18 interface FakerStatic {
19 locale: string;
20 setLocale(locale: string): void;
21
22 address: {
23 zipCodeByState(state: string): string;
24 zipCode(format?: string): string;
25 city(format?: string): string;
26 cityName(): string;
27 cityPrefix(): string;
28 citySuffix(): string;
29 streetName(): string;
30 streetAddress(useFullAddress?: boolean): string;
31 streetSuffix(): string;
32 streetPrefix(): string;
33 secondaryAddress(): string;
34 county(): string;
35 country(): string;
36 countryCode(alphaCode?: string): string;
37 state(useAbbr?: boolean): string;
38 stateAbbr(): string;
39 latitude(max?: number, min?: number, precision?: number): string;
40 longitude(max?: number, min?: number, precision?: number): string;
41 direction(useAbbr?: boolean): string;
42 cardinalDirection(useAbbr?: boolean): string;
43 ordinalDirection(useAbbr?: boolean): string;
44 nearbyGPSCoordinate(
45 coordinate?: ReadonlyArray<number | string>,
46 radius?: number,
47 isMetric?: boolean,
48 ): string[];
49 timeZone(): string;
50 };
51
52 commerce: {
53 color(): string;
54 department(): string;
55 productName(): string;
56 price(min?: number, max?: number, dec?: number, symbol?: string): string;
57 productAdjective(): string;
58 productMaterial(): string;
59 product(): string;
60 productDescription(): string;
61 };
62
63 company: {
64 suffixes(): string[];
65 companyName(format?: number): string;
66 companySuffix(): string;
67 catchPhrase(): string;
68 bs(): string;
69 catchPhraseAdjective(): string;
70 catchPhraseDescriptor(): string;
71 catchPhraseNoun(): string;
72 bsAdjective(): string;
73 bsBuzz(): string;
74 bsNoun(): string;
75 };
76
77 database: {
78 column(): string;
79 type(): string;
80 collation(): string;
81 engine(): string;
82 };
83
84 datatype: {
85 number(max?: number): number;
86 number(options?: { min?: number | undefined; max?: number | undefined; precision?: number | undefined }): number;
87 float(precision?: number): number;
88 float(options?: { min?: number | undefined; max?: number | undefined; precision?: number | undefined }): number;
89 datetime(max?: number): Date;
90 datetime(options?: { min?: number | undefined; max?: number | undefined }): Date;
91 string(length?: number): string;
92 uuid(): string;
93 boolean(): boolean;
94 hexaDecimal(count?: number): string;
95 json(): string;
96 array(length?: number): Array<string | number>;
97 };
98
99 date: {
100 past(years?: number, refDate?: string | Date): Date;
101 future(years?: number, refDate?: string | Date): Date;
102 between(from: string | number | Date, to: string | Date): Date;
103 recent(days?: number, refDate?: string | Date): Date;
104 soon(days?: number, refDate?: string | Date): Date;
105 month(options?: { abbr?: boolean | undefined; context?: boolean | undefined }): string;
106 weekday(options?: { abbr?: boolean | undefined; context?: boolean | undefined }): string;
107 };
108
109 fake(str: string): string;
110
111 finance: {
112 account(length?: number): string;
113 accountName(): string;
114 routingNumber(): string;
115 mask(length?: number, parens?: boolean, elipsis?: boolean): string;
116 amount(min?: number, max?: number, dec?: number, symbol?: string): string;
117 transactionType(): string;
118 currencyCode(): string;
119 currencyName(): string;
120 currencySymbol(): string;
121 bitcoinAddress(): string;
122 iban(formatted?: boolean, countryCode?: string): string;
123 bic(): string;
124 litecoinAddress(): string;
125 creditCardNumber(provider?: string): string;
126 creditCardCVV(): string;
127 ethereumAddress(): string;
128 transactionDescription(): string;
129 };
130
131 git: {
132 branch(): string;
133 commitEntry(options?: { merge: boolean }): string;
134 commitMessage(): string;
135 commitSha(): string;
136 shortSha(): string;
137 };
138
139 hacker: {
140 abbreviation(): string;
141 adjective(): string;
142 noun(): string;
143 verb(): string;
144 ingverb(): string;
145 phrase(): string;
146 };
147
148 helpers: {
149 randomize<T>(array: T[]): T;
150 randomize(): string;
151 slugify(string?: string): string;
152 replaceSymbolWithNumber(string?: string, symbol?: string): string;
153 replaceSymbols(string?: string): string;
154 replaceCreditCardSymbols(string?: string, symbol?: string): string;
155 repeatString(string: string, num?: number): string;
156 regexpStyleStringParse(string: string): string;
157 shuffle<T>(o: T[]): T[];
158 shuffle(): string[];
159 mustache(
160 str: string,
161 data: { [key: string]: string | ((substring: string, ...args: any[]) => string) },
162 ): string;
163 createCard(): Card;
164 contextualCard(): ContextualCard;
165 userCard(): UserCard;
166 createTransaction(): Transaction;
167 };
168
169 image: {
170 image(): string;
171 avatar(): string;
172 imageUrl(width?: number, height?: number, category?: string, randomize?: boolean, https?: boolean): string;
173 abstract(width?: number, height?: number): string;
174 animals(width?: number, height?: number): string;
175 business(width?: number, height?: number): string;
176 cats(width?: number, height?: number): string;
177 city(width?: number, height?: number): string;
178 food(width?: number, height?: number): string;
179 nightlife(width?: number, height?: number): string;
180 fashion(width?: number, height?: number): string;
181 people(width?: number, height?: number): string;
182 nature(width?: number, height?: number): string;
183 sports(width?: number, height?: number): string;
184 technics(width?: number, height?: number): string;
185 transport(width?: number, height?: number): string;
186 dataUri(width?: number, height?: number, color?: string): string;
187 };
188
189 internet: {
190 avatar(): string;
191 email(firstName?: string, lastName?: string, provider?: string): string;
192 exampleEmail(firstName?: string, lastName?: string): string;
193 userName(firstName?: string, lastName?: string): string;
194 protocol(): string;
195 url(): string;
196 domainName(): string;
197 domainSuffix(): string;
198 domainWord(): string;
199 ip(): string;
200 ipv6(): string;
201 port(): number;
202 userAgent(): string;
203 color(baseRed255?: number, baseGreen255?: number, baseBlue255?: number): string;
204 mac(sep?: string): string;
205 password(len?: number, memorable?: boolean, pattern?: string | RegExp, prefix?: string): string;
206 };
207
208 lorem: {
209 word(length?: number): string;
210 words(num?: number): string;
211 sentence(wordCount?: number, range?: number): string;
212 slug(wordCount?: number): string;
213 sentences(sentenceCount?: number): string;
214 paragraph(sentenceCount?: number): string;
215 paragraphs(paragraphCount?: number, separator?: string): string;
216 text(times?: number): string;
217 lines(lineCount?: number): string;
218 };
219
220 name: {
221 firstName(gender?: number): string;
222 lastName(gender?: number): string;
223 middleName(gender?: number): string;
224 findName(firstName?: string, lastName?: string, gender?: number): string;
225 jobTitle(): string;
226 gender(): string;
227 prefix(): string;
228 suffix(): string;
229 title(): string;
230 jobDescriptor(): string;
231 jobArea(): string;
232 jobType(): string;
233 };
234
235 music: {
236 genre(): string;
237 };
238
239 phone: {
240 phoneNumber(format?: string): string;
241 phoneNumberFormat(phoneFormatsArrayIndex?: number): string;
242 phoneFormats(): string;
243 };
244
245 random: {
246 /** @deprecated faker.random.number is now located in faker.datatype.number */
247 number(max?: number): number;
248 /** @deprecated faker.random.number is now located in faker.datatype.number */
249 number(options?: { min?: number | undefined; max?: number | undefined; precision?: number | undefined }): number;
250 /** @deprecated faker.random.float is now located in faker.datatype.float */
251 float(max?: number): number;
252 /** @deprecated faker.random.float is now located in faker.datatype.float */
253 float(options?: { min?: number | undefined; max?: number | undefined; precision?: number | undefined }): number;
254 arrayElement(): string;
255 arrayElement<T>(array: T[]): T;
256 arrayElement<T>(array: ReadonlyArray<T>): T;
257 arrayElements(count?: number): string[];
258 arrayElements<T>(array: T[], count?: number): T[];
259 arrayElements<T>(array: ReadonlyArray<T>, count?: number): ReadonlyArray<T>;
260 objectElement(object?: { [key: string]: any }, field?: 'key'): string;
261 objectElement<T>(object?: { [key: string]: T }, field?: any): T;
262 /** @deprecated faker.random.uuid is now located in faker.datatype.uuid */
263 uuid(): string;
264 /** @deprecated faker.random.boolean is now located in faker.datatype.boolean */
265 boolean(): boolean;
266 word(type?: string): string;
267 words(count?: number): string;
268 image(): string;
269 locale(): string;
270 alpha(options?: { count?: number | undefined; upcase?: boolean | undefined }): string;
271 alphaNumeric(count?: number): string;
272 /** @deprecated faker.random.hexaDecimal is now located in faker.datatype.hexaDecimal */
273 hexaDecimal(count?: number): string;
274 };
275
276 system: {
277 fileName(): string;
278 commonFileName(ext?: string): string;
279 mimeType(): string;
280 commonFileType(): string;
281 commonFileExt(): string;
282 fileType(): string;
283 fileExt(mimeType?: string): string;
284 directoryPath(): string;
285 filePath(): string;
286 semver(): string;
287 };
288
289 time: {
290 recent(): number;
291 recent(outputType: 'unix'): number;
292 recent(outputType: 'abbr' | 'wide'): string;
293 };
294
295 seed(value: number): void;
296 seedValue?: number | undefined;
297
298 vehicle: {
299 vehicle(): string;
300 manufacturer(): string;
301 model(): string;
302 type(): string;
303 fuel(): string;
304 vin(): string;
305 color(): string;
306 vrm(): string;
307 bicycle(): string;
308 };
309
310 unique<T extends (...args: any) => any>(
311 method: T,
312 args?: Parameters<T>,
313 opts?: { maxTime?: number | undefined; maxRetries?: number | undefined },
314 ): ReturnType<T>;
315 }
316
317 interface Card {
318 name: string;
319 username: string;
320 email: string;
321 address: FullAddress;
322 phone: string;
323 website: string;
324 company: Company;
325 posts: Post[];
326 accountHistory: string[];
327 }
328
329 interface FullAddress {
330 streetA: string;
331 streetB: string;
332 streetC: string;
333 streetD: string;
334 city: string;
335 state: string;
336 county: string;
337 zipcode: string;
338 geo: Geo;
339 }
340
341 interface Geo {
342 lat: string;
343 lng: string;
344 }
345
346 interface Company {
347 name: string;
348 catchPhrase: string;
349 bs: string;
350 }
351
352 interface Post {
353 words: string;
354 sentence: string;
355 sentences: string;
356 paragraph: string;
357 }
358
359 interface ContextualCard {
360 name: string;
361 username: string;
362 avatar: string;
363 email: string;
364 dob: Date;
365 phone: string;
366 address: Address;
367 website: string;
368 company: Company;
369 }
370
371 interface Address {
372 street: string;
373 suite: string;
374 city: string;
375 state: string;
376 zipcode: string;
377 geo: Geo;
378 }
379
380 interface UserCard {
381 name: string;
382 username: string;
383 email: string;
384 address: Address;
385 phone: string;
386 website: string;
387 company: Company;
388 }
389
390 interface Transaction {
391 amount: string;
392 date: Date;
393 business: string;
394 name: string;
395 type: string;
396 account: string;
397 }
398}
399
400declare module 'faker' {
401 export = fakerStatic;
402}
403
404declare module 'faker/locale/az' {
405 export = fakerStatic;
406}
407
408declare module 'faker/locale/ar' {
409 export = fakerStatic;
410}
411
412declare module 'faker/locale/cz' {
413 export = fakerStatic;
414}
415
416declare module 'faker/locale/de' {
417 export = fakerStatic;
418}
419
420declare module 'faker/locale/de_AT' {
421 export = fakerStatic;
422}
423
424declare module 'faker/locale/de_CH' {
425 export = fakerStatic;
426}
427
428declare module 'faker/locale/en' {
429 export = fakerStatic;
430}
431
432declare module 'faker/locale/en_AU' {
433 export = fakerStatic;
434}
435
436declare module 'faker/locale/en_AU_ocker' {
437 export = fakerStatic;
438}
439
440declare module 'faker/locale/en_BORK' {
441 export = fakerStatic;
442}
443
444declare module 'faker/locale/en_CA' {
445 export = fakerStatic;
446}
447
448declare module 'faker/locale/en_GB' {
449 export = fakerStatic;
450}
451
452declare module 'faker/locale/en_IE' {
453 export = fakerStatic;
454}
455
456declare module 'faker/locale/en_IND' {
457 export = fakerStatic;
458}
459
460declare module 'faker/locale/en_US' {
461 export = fakerStatic;
462}
463
464declare module 'faker/locale/en_ZA' {
465 export = fakerStatic;
466}
467
468declare module 'faker/locale/es' {
469 export = fakerStatic;
470}
471
472declare module 'faker/locale/es_MX' {
473 export = fakerStatic;
474}
475
476declare module 'faker/locale/fa' {
477 export = fakerStatic;
478}
479
480declare module 'faker/locale/fi' {
481 export = fakerStatic;
482}
483
484declare module 'faker/locale/fr' {
485 export = fakerStatic;
486}
487
488declare module 'faker/locale/fr_CA' {
489 export = fakerStatic;
490}
491
492declare module 'faker/locale/fr_CH' {
493 export = fakerStatic;
494}
495
496declare module 'faker/locale/ge' {
497 export = fakerStatic;
498}
499
500declare module 'faker/locale/id_ID' {
501 export = fakerStatic;
502}
503
504declare module 'faker/locale/it' {
505 export = fakerStatic;
506}
507
508declare module 'faker/locale/ja' {
509 export = fakerStatic;
510}
511
512declare module 'faker/locale/ko' {
513 export = fakerStatic;
514}
515
516declare module 'faker/locale/nb_NO' {
517 export = fakerStatic;
518}
519
520declare module 'faker/locale/nep' {
521 export = fakerStatic;
522}
523
524declare module 'faker/locale/nl' {
525 export = fakerStatic;
526}
527
528declare module 'faker/locale/nl_BE' {
529 export = fakerStatic;
530}
531
532declare module 'faker/locale/pl' {
533 export = fakerStatic;
534}
535
536declare module 'faker/locale/pt_BR' {
537 export = fakerStatic;
538}
539
540declare module 'faker/locale/pt_PT' {
541 export = fakerStatic;
542}
543
544declare module 'faker/locale/ro' {
545 export = fakerStatic;
546}
547
548declare module 'faker/locale/ru' {
549 export = fakerStatic;
550}
551
552declare module 'faker/locale/sk' {
553 export = fakerStatic;
554}
555
556declare module 'faker/locale/sv' {
557 export = fakerStatic;
558}
559
560declare module 'faker/locale/tr' {
561 export = fakerStatic;
562}
563
564declare module 'faker/locale/uk' {
565 export = fakerStatic;
566}
567
568declare module 'faker/locale/vi' {
569 export = fakerStatic;
570}
571
572declare module 'faker/locale/zh_CN' {
573 export = fakerStatic;
574}
575
576declare module 'faker/locale/zh_TW' {
577 export = fakerStatic;
578}