fauxy 0.0.2 → 0.0.3
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/dist/index.d.ts +129 -1
- package/package.json +1 -1
- package/src/declare-types/index.d.ts +24 -1
- package/src/faker/index.ts +30 -0
- package/src/faker/locales.ts +74 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RequestHandler } from 'msw';
|
|
2
2
|
export { HttpResponse, RequestHandler, delay, http, passthrough } from 'msw';
|
|
3
3
|
import { SetupWorkerApi } from 'msw/browser';
|
|
4
|
+
import { Faker } from '@faker-js/faker';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Utils
|
|
@@ -136,8 +137,135 @@ declare class FakerWrapper<T extends FakerWrapperType> {
|
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
|
|
140
|
+
type Locale =
|
|
141
|
+
| 'af_ZA'
|
|
142
|
+
| 'ar'
|
|
143
|
+
| 'az'
|
|
144
|
+
| 'base'
|
|
145
|
+
| 'bn_BD'
|
|
146
|
+
| 'cs_CZ'
|
|
147
|
+
| 'cy'
|
|
148
|
+
| 'da'
|
|
149
|
+
| 'de'
|
|
150
|
+
| 'de_AT'
|
|
151
|
+
| 'de_CH'
|
|
152
|
+
| 'dv'
|
|
153
|
+
| 'el'
|
|
154
|
+
| 'en'
|
|
155
|
+
| 'en_AU'
|
|
156
|
+
| 'en_AU_ocker'
|
|
157
|
+
| 'en_BORK'
|
|
158
|
+
| 'en_CA'
|
|
159
|
+
| 'en_GB'
|
|
160
|
+
| 'en_GH'
|
|
161
|
+
| 'en_HK'
|
|
162
|
+
| 'en_IE'
|
|
163
|
+
| 'en_IN'
|
|
164
|
+
| 'en_NG'
|
|
165
|
+
| 'en_US'
|
|
166
|
+
| 'en_ZA'
|
|
167
|
+
| 'eo'
|
|
168
|
+
| 'es'
|
|
169
|
+
| 'es_MX'
|
|
170
|
+
| 'fa'
|
|
171
|
+
| 'fi'
|
|
172
|
+
| 'fr'
|
|
173
|
+
| 'fr_BE'
|
|
174
|
+
| 'fr_CA'
|
|
175
|
+
| 'fr_CH'
|
|
176
|
+
| 'fr_LU'
|
|
177
|
+
| 'fr_SN'
|
|
178
|
+
| 'he'
|
|
179
|
+
| 'hr'
|
|
180
|
+
| 'hu'
|
|
181
|
+
| 'hy'
|
|
182
|
+
| 'id_ID'
|
|
183
|
+
| 'it'
|
|
184
|
+
| 'ja'
|
|
185
|
+
| 'ka_GE'
|
|
186
|
+
| 'ko'
|
|
187
|
+
| 'ku_ckb'
|
|
188
|
+
| 'lv'
|
|
189
|
+
| 'mk'
|
|
190
|
+
| 'nb_NO'
|
|
191
|
+
| 'ne'
|
|
192
|
+
| 'nl'
|
|
193
|
+
| 'nl_BE'
|
|
194
|
+
| 'pl'
|
|
195
|
+
| 'pt_BR'
|
|
196
|
+
| 'pt_PT'
|
|
197
|
+
| 'ro'
|
|
198
|
+
| 'ro_MD'
|
|
199
|
+
| 'ru'
|
|
200
|
+
| 'sk'
|
|
201
|
+
| 'sr_RS_latin'
|
|
202
|
+
| 'sv'
|
|
203
|
+
| 'ta_IN'
|
|
204
|
+
| 'th'
|
|
205
|
+
| 'tr'
|
|
206
|
+
| 'uk'
|
|
207
|
+
| 'ur'
|
|
208
|
+
| 'uz_UZ_latin'
|
|
209
|
+
| 'vi'
|
|
210
|
+
| 'yo_NG'
|
|
211
|
+
| 'zh_CN'
|
|
212
|
+
| 'zh_TW'
|
|
213
|
+
| 'zu_ZA'
|
|
214
|
+
|
|
215
|
+
type FakerModules = Pick<
|
|
216
|
+
Faker,
|
|
217
|
+
| 'airline'
|
|
218
|
+
| 'animal'
|
|
219
|
+
| 'book'
|
|
220
|
+
| 'color'
|
|
221
|
+
| 'commerce'
|
|
222
|
+
| 'company'
|
|
223
|
+
| 'database'
|
|
224
|
+
| 'datatype'
|
|
225
|
+
| 'date'
|
|
226
|
+
| 'finance'
|
|
227
|
+
| 'food'
|
|
228
|
+
| 'git'
|
|
229
|
+
| 'hacker'
|
|
230
|
+
| 'helpers'
|
|
231
|
+
| 'image'
|
|
232
|
+
| 'internet'
|
|
233
|
+
| 'location'
|
|
234
|
+
| 'lorem'
|
|
235
|
+
| 'music'
|
|
236
|
+
| 'number'
|
|
237
|
+
| 'person'
|
|
238
|
+
| 'phone'
|
|
239
|
+
| 'science'
|
|
240
|
+
| 'string'
|
|
241
|
+
| 'system'
|
|
242
|
+
| 'vehicle'
|
|
243
|
+
| 'word'
|
|
244
|
+
>
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Starts the MSW mock service worker with given request handlers.
|
|
248
|
+
*/
|
|
139
249
|
declare const mockApi: (handlers: RequestHandler[]) => SetupWorkerApi
|
|
140
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Faker utility function for generating data using FakerWrapper.
|
|
253
|
+
*/
|
|
141
254
|
declare function fake(): typeof FakerWrapper
|
|
255
|
+
declare function fake<T extends (...p: any[]) => any>(
|
|
256
|
+
fn: T,
|
|
257
|
+
...args: Parameters<T>
|
|
258
|
+
): FakerWrapper<'instance'>
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Sets the current locale for faker modules.
|
|
262
|
+
*/
|
|
263
|
+
declare function setLocale(locale: Locale): void
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Collection of Faker modules (airline, person, date, etc.).
|
|
267
|
+
* These are dynamically rebuilt when locale changes.
|
|
268
|
+
*/
|
|
269
|
+
declare const fakerModules: FakerModules
|
|
142
270
|
|
|
143
|
-
export { fake, mockApi };
|
|
271
|
+
export { fake, fakerModules, mockApi, setLocale };
|
package/package.json
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import { HttpResponse, RequestHandler, delay, http, passthrough } from 'msw'
|
|
2
2
|
import { SetupWorkerApi } from 'msw/browser'
|
|
3
|
+
import { FakerModules } from '@/faker'
|
|
3
4
|
import { FakerWrapper } from '@/faker/fakerWrapper'
|
|
5
|
+
import { Locale } from '@/faker/locales'
|
|
4
6
|
|
|
5
7
|
export { HttpResponse, RequestHandler, http, delay, passthrough }
|
|
6
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Starts the MSW mock service worker with given request handlers.
|
|
11
|
+
*/
|
|
7
12
|
export declare const mockApi: (handlers: RequestHandler[]) => SetupWorkerApi
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Faker utility function for generating data using FakerWrapper.
|
|
16
|
+
*/
|
|
17
|
+
export function fake(): typeof FakerWrapper
|
|
18
|
+
export function fake<T extends (...p: any[]) => any>(
|
|
19
|
+
fn: T,
|
|
20
|
+
...args: Parameters<T>
|
|
21
|
+
): FakerWrapper<'instance'>
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Sets the current locale for faker modules.
|
|
25
|
+
*/
|
|
26
|
+
export declare function setLocale(locale: Locale): void
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Collection of Faker modules (airline, person, date, etc.).
|
|
30
|
+
* These are dynamically rebuilt when locale changes.
|
|
31
|
+
*/
|
|
32
|
+
export declare const fakerModules: FakerModules
|
package/src/faker/index.ts
CHANGED
|
@@ -33,6 +33,36 @@ export const fakerModules = {
|
|
|
33
33
|
vehicle: initialInstance.vehicle,
|
|
34
34
|
word: initialInstance.word,
|
|
35
35
|
}
|
|
36
|
+
export type FakerModules = Pick<
|
|
37
|
+
Faker,
|
|
38
|
+
| 'airline'
|
|
39
|
+
| 'animal'
|
|
40
|
+
| 'book'
|
|
41
|
+
| 'color'
|
|
42
|
+
| 'commerce'
|
|
43
|
+
| 'company'
|
|
44
|
+
| 'database'
|
|
45
|
+
| 'datatype'
|
|
46
|
+
| 'date'
|
|
47
|
+
| 'finance'
|
|
48
|
+
| 'food'
|
|
49
|
+
| 'git'
|
|
50
|
+
| 'hacker'
|
|
51
|
+
| 'helpers'
|
|
52
|
+
| 'image'
|
|
53
|
+
| 'internet'
|
|
54
|
+
| 'location'
|
|
55
|
+
| 'lorem'
|
|
56
|
+
| 'music'
|
|
57
|
+
| 'number'
|
|
58
|
+
| 'person'
|
|
59
|
+
| 'phone'
|
|
60
|
+
| 'science'
|
|
61
|
+
| 'string'
|
|
62
|
+
| 'system'
|
|
63
|
+
| 'vehicle'
|
|
64
|
+
| 'word'
|
|
65
|
+
>
|
|
36
66
|
|
|
37
67
|
const buildModules = (locale: Locale) => {
|
|
38
68
|
const newInstance = new Faker({ locale: [locales[locale], locales.en, locales.base] })
|
package/src/faker/locales.ts
CHANGED
|
@@ -149,4 +149,77 @@ export const locales = {
|
|
|
149
149
|
zh_TW,
|
|
150
150
|
zu_ZA,
|
|
151
151
|
} as const
|
|
152
|
-
export type Locale =
|
|
152
|
+
export type Locale =
|
|
153
|
+
| 'af_ZA'
|
|
154
|
+
| 'ar'
|
|
155
|
+
| 'az'
|
|
156
|
+
| 'base'
|
|
157
|
+
| 'bn_BD'
|
|
158
|
+
| 'cs_CZ'
|
|
159
|
+
| 'cy'
|
|
160
|
+
| 'da'
|
|
161
|
+
| 'de'
|
|
162
|
+
| 'de_AT'
|
|
163
|
+
| 'de_CH'
|
|
164
|
+
| 'dv'
|
|
165
|
+
| 'el'
|
|
166
|
+
| 'en'
|
|
167
|
+
| 'en_AU'
|
|
168
|
+
| 'en_AU_ocker'
|
|
169
|
+
| 'en_BORK'
|
|
170
|
+
| 'en_CA'
|
|
171
|
+
| 'en_GB'
|
|
172
|
+
| 'en_GH'
|
|
173
|
+
| 'en_HK'
|
|
174
|
+
| 'en_IE'
|
|
175
|
+
| 'en_IN'
|
|
176
|
+
| 'en_NG'
|
|
177
|
+
| 'en_US'
|
|
178
|
+
| 'en_ZA'
|
|
179
|
+
| 'eo'
|
|
180
|
+
| 'es'
|
|
181
|
+
| 'es_MX'
|
|
182
|
+
| 'fa'
|
|
183
|
+
| 'fi'
|
|
184
|
+
| 'fr'
|
|
185
|
+
| 'fr_BE'
|
|
186
|
+
| 'fr_CA'
|
|
187
|
+
| 'fr_CH'
|
|
188
|
+
| 'fr_LU'
|
|
189
|
+
| 'fr_SN'
|
|
190
|
+
| 'he'
|
|
191
|
+
| 'hr'
|
|
192
|
+
| 'hu'
|
|
193
|
+
| 'hy'
|
|
194
|
+
| 'id_ID'
|
|
195
|
+
| 'it'
|
|
196
|
+
| 'ja'
|
|
197
|
+
| 'ka_GE'
|
|
198
|
+
| 'ko'
|
|
199
|
+
| 'ku_ckb'
|
|
200
|
+
| 'lv'
|
|
201
|
+
| 'mk'
|
|
202
|
+
| 'nb_NO'
|
|
203
|
+
| 'ne'
|
|
204
|
+
| 'nl'
|
|
205
|
+
| 'nl_BE'
|
|
206
|
+
| 'pl'
|
|
207
|
+
| 'pt_BR'
|
|
208
|
+
| 'pt_PT'
|
|
209
|
+
| 'ro'
|
|
210
|
+
| 'ro_MD'
|
|
211
|
+
| 'ru'
|
|
212
|
+
| 'sk'
|
|
213
|
+
| 'sr_RS_latin'
|
|
214
|
+
| 'sv'
|
|
215
|
+
| 'ta_IN'
|
|
216
|
+
| 'th'
|
|
217
|
+
| 'tr'
|
|
218
|
+
| 'uk'
|
|
219
|
+
| 'ur'
|
|
220
|
+
| 'uz_UZ_latin'
|
|
221
|
+
| 'vi'
|
|
222
|
+
| 'yo_NG'
|
|
223
|
+
| 'zh_CN'
|
|
224
|
+
| 'zh_TW'
|
|
225
|
+
| 'zu_ZA'
|