From 32e7a9358449673407f0d355ea34092245ee5df2 Mon Sep 17 00:00:00 2001 From: Guilherme Mierzwa Date: Mon, 30 Oct 2023 18:34:12 -0300 Subject: [PATCH] feat(faker): update deprecated methods --- .../pages/reference/configuration/full-example.md | 10 +++++----- docs/src/pages/reference/configuration/output.md | 8 ++++---- packages/msw/src/getters/scalar.ts | 2 +- samples/angular-app/orval.config.ts | 10 +++++----- .../angular-app/src/api/endpoints/pets/pets.msw.ts | 12 ++++++------ .../petstoreFromFileSpecWithTransformer.ts | 8 ++++---- samples/basic/orval.config.ts | 8 ++++---- samples/nx-fastify-react/apps/api/src/main.ts | 8 ++++---- .../petstoreFromFileSpecWithTransformer.msw.ts | 2 +- samples/react-app/orval.config.ts | 10 +++++----- .../petstoreFromFileSpecWithTransformer.msw.ts | 14 +++++++------- .../petstoreFromFileSpecWithTransformer.msw.ts | 2 +- .../petstoreFromFileSpecWithTransformer.msw.ts | 2 +- samples/svelte-query/orval.config.ts | 10 +++++----- .../petstoreFromFileSpecWithTransformer.msw.ts | 14 +++++++------- .../petstoreFromFileSpecWithTransformer.msw.ts | 2 +- 16 files changed, 61 insertions(+), 61 deletions(-) diff --git a/docs/src/pages/reference/configuration/full-example.md b/docs/src/pages/reference/configuration/full-example.md index b10f98e1e..4812d5d07 100644 --- a/docs/src/pages/reference/configuration/full-example.md +++ b/docs/src/pages/reference/configuration/full-example.md @@ -21,7 +21,7 @@ module.exports = { mock: { properties: () => { return { - id: () => faker.datatype.number({ min: 1, max: 99999 }), + id: () => faker.number.int({ min: 1, max: 99999 }), }; }, }, @@ -29,10 +29,10 @@ module.exports = { showPetById: { mock: { data: () => ({ - id: faker.datatype.number({ min: 1, max: 99 }), - name: faker.name.firstName(), + id: faker.number.int({ min: 1, max: 99 }), + name: faker.person.firstName(), tag: faker.helpers.arrayElement([ - faker.random.word(), + faker.word.sample(), undefined, ]), }), @@ -41,7 +41,7 @@ module.exports = { }, mock: { properties: { - '/tag|name/': () => faker.name.lastName(), + '/tag|name/': () => faker.person.lastName(), }, delay: 500, }, diff --git a/docs/src/pages/reference/configuration/output.md b/docs/src/pages/reference/configuration/output.md index 8a850adde..ee03fcad4 100644 --- a/docs/src/pages/reference/configuration/output.md +++ b/docs/src/pages/reference/configuration/output.md @@ -888,7 +888,7 @@ module.exports = { mock: { properties: () => { return { - id: () => faker.datatype.number({ min: 1, max: 99999 }), + id: () => faker.number.int({ min: 1, max: 99999 }), }; }, }, @@ -896,10 +896,10 @@ module.exports = { showPetById: { mock: { data: () => ({ - id: faker.datatype.number({ min: 1, max: 99 }), - name: faker.name.firstName(), + id: faker.number.int({ min: 1, max: 99 }), + name: faker.person.firstName(), tag: faker.helpers.arrayElement([ - faker.random.word(), + faker.word.sample(), undefined, ]), }), diff --git a/packages/msw/src/getters/scalar.ts b/packages/msw/src/getters/scalar.ts index 6ba86f6cc..eee4ef39c 100644 --- a/packages/msw/src/getters/scalar.ts +++ b/packages/msw/src/getters/scalar.ts @@ -177,7 +177,7 @@ export const getMockScalar = ({ return { value: - `Array.from({ length: faker.datatype.number({ ` + + `Array.from({ length: faker.number.int({ ` + `min: ${mockOptions?.arrayMin}, ` + `max: ${mockOptions?.arrayMax} }) ` + `}, (_, i) => i + 1).map(() => (${mapValue}))`, diff --git a/samples/angular-app/orval.config.ts b/samples/angular-app/orval.config.ts index 7312c77e6..ab2711d47 100644 --- a/samples/angular-app/orval.config.ts +++ b/samples/angular-app/orval.config.ts @@ -18,7 +18,7 @@ export default defineConfig({ mock: { properties: () => { return { - id: () => faker.datatype.number({ min: 1, max: 99999 }), + id: () => faker.number.int({ min: 1, max: 99999 }), }; }, }, @@ -26,10 +26,10 @@ export default defineConfig({ showPetById: { mock: { data: () => ({ - id: faker.datatype.number({ min: 1, max: 99 }), - name: faker.name.firstName(), + id: faker.number.int({ min: 1, max: 99 }), + name: faker.person.firstName(), tag: faker.helpers.arrayElement([ - faker.random.word(), + faker.word.sample(), undefined, ]), }), @@ -38,7 +38,7 @@ export default defineConfig({ }, mock: { properties: { - '/tag|name/': () => faker.name.lastName(), + '/tag|name/': () => faker.person.lastName(), }, }, }, diff --git a/samples/angular-app/src/api/endpoints/pets/pets.msw.ts b/samples/angular-app/src/api/endpoints/pets/pets.msw.ts index 99f4c1191..c7c02e1d8 100644 --- a/samples/angular-app/src/api/endpoints/pets/pets.msw.ts +++ b/samples/angular-app/src/api/endpoints/pets/pets.msw.ts @@ -9,19 +9,19 @@ import { rest } from 'msw'; export const getListPetsMock = () => Array.from( - { length: faker.datatype.number({ min: 1, max: 10 }) }, + { length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1, ).map(() => ({ id: faker.number.int({ min: undefined, max: undefined }), - name: (() => faker.name.lastName())(), - tag: (() => faker.name.lastName())(), + name: (() => faker.person.lastName())(), + tag: (() => faker.person.lastName())(), })); export const getShowPetByIdMock = () => (() => ({ - id: faker.datatype.number({ min: 1, max: 99 }), - name: faker.name.firstName(), - tag: faker.helpers.arrayElement([faker.random.word(), void 0]), + id: faker.number.int({ min: 1, max: 99 }), + name: faker.person.firstName(), + tag: faker.helpers.arrayElement([faker.word.sample(), void 0]), }))(); export const getPetsMSW = () => [ diff --git a/samples/basic/api/endpoints/petstoreFromFileSpecWithTransformer.ts b/samples/basic/api/endpoints/petstoreFromFileSpecWithTransformer.ts index 80a844671..31a9dbe5e 100644 --- a/samples/basic/api/endpoints/petstoreFromFileSpecWithTransformer.ts +++ b/samples/basic/api/endpoints/petstoreFromFileSpecWithTransformer.ts @@ -54,7 +54,7 @@ export type ShowPetByIdResult = AxiosResponse; export const getListPetsMock = () => Array.from( - { length: faker.datatype.number({ min: 1, max: 10 }) }, + { length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1, ).map(() => ({ id: faker.number.int({ min: undefined, max: undefined }), @@ -64,9 +64,9 @@ export const getListPetsMock = () => export const getShowPetByIdMock = () => (() => ({ - id: faker.datatype.number({ min: 1, max: 99 }), - name: faker.name.firstName(), - tag: faker.helpers.arrayElement([faker.random.word(), void 0]), + id: faker.number.int({ min: 1, max: 99 }), + name: faker.person.firstName(), + tag: faker.helpers.arrayElement([faker.word.sample(), void 0]), }))(); export const getSwaggerPetstoreMSW = () => [ diff --git a/samples/basic/orval.config.ts b/samples/basic/orval.config.ts index 6b4510a83..396feecf9 100644 --- a/samples/basic/orval.config.ts +++ b/samples/basic/orval.config.ts @@ -19,7 +19,7 @@ export default defineConfig({ mock: { properties: () => { return { - id: faker.datatype.number({ min: 1, max: 9 }), + id: faker.number.int({ min: 1, max: 9 }), }; }, }, @@ -27,10 +27,10 @@ export default defineConfig({ showPetById: { mock: { data: () => ({ - id: faker.datatype.number({ min: 1, max: 99 }), - name: faker.name.firstName(), + id: faker.number.int({ min: 1, max: 99 }), + name: faker.person.firstName(), tag: faker.helpers.arrayElement([ - faker.random.word(), + faker.word.sample(), undefined, ]), }), diff --git a/samples/nx-fastify-react/apps/api/src/main.ts b/samples/nx-fastify-react/apps/api/src/main.ts index a12b751d6..a6fff730d 100644 --- a/samples/nx-fastify-react/apps/api/src/main.ts +++ b/samples/nx-fastify-react/apps/api/src/main.ts @@ -58,10 +58,10 @@ app.ready(async () => { }); export const getGetPetsMock = () => - [...Array(faker.datatype.number({ min: 1, max: 10 }))].map(() => ({ - id: faker.datatype.number(), - name: faker.random.word(), - tag: faker.random.word(), + [...Array(faker.number.int({ min: 1, max: 10 }))].map(() => ({ + id: faker.number.int(), + name: faker.word.sample(), + tag: faker.word.sample(), })); app.get( diff --git a/samples/react-app-with-swr/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts b/samples/react-app-with-swr/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts index 4d900db5f..4ed3efa8e 100644 --- a/samples/react-app-with-swr/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts +++ b/samples/react-app-with-swr/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts @@ -9,7 +9,7 @@ import { rest } from 'msw'; export const getListPetsMock = () => Array.from( - { length: faker.datatype.number({ min: 1, max: 10 }) }, + { length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1, ).map(() => ({ '@id': faker.helpers.arrayElement([faker.word.sample(), undefined]), diff --git a/samples/react-app/orval.config.ts b/samples/react-app/orval.config.ts index 3f67bdd70..7ead39244 100644 --- a/samples/react-app/orval.config.ts +++ b/samples/react-app/orval.config.ts @@ -19,7 +19,7 @@ export default defineConfig({ mock: { properties: () => { return { - '[].id': () => faker.datatype.number({ min: 1, max: 99999 }), + '[].id': () => faker.number.int({ min: 1, max: 99999 }), }; }, }, @@ -27,10 +27,10 @@ export default defineConfig({ showPetById: { mock: { data: () => ({ - id: faker.datatype.number({ min: 1, max: 99 }), - name: faker.name.firstName(), + id: faker.number.int({ min: 1, max: 99 }), + name: faker.person.firstName(), tag: faker.helpers.arrayElement([ - faker.random.word(), + faker.word.sample(), undefined, ]), }), @@ -39,7 +39,7 @@ export default defineConfig({ }, mock: { properties: { - '/tag|name/': () => faker.name.lastName(), + '/tag|name/': () => faker.person.lastName(), }, }, }, diff --git a/samples/react-app/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts b/samples/react-app/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts index 6e8859be4..35eacf747 100644 --- a/samples/react-app/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts +++ b/samples/react-app/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts @@ -9,19 +9,19 @@ import { rest } from 'msw'; export const getListPetsMock = () => Array.from( - { length: faker.datatype.number({ min: 1, max: 10 }) }, + { length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1, ).map(() => ({ - id: (() => faker.datatype.number({ min: 1, max: 99999 }))(), - name: (() => faker.name.lastName())(), - tag: (() => faker.name.lastName())(), + id: (() => faker.number.int({ min: 1, max: 99999 }))(), + name: (() => faker.person.lastName())(), + tag: (() => faker.person.lastName())(), })); export const getShowPetByIdMock = () => (() => ({ - id: faker.datatype.number({ min: 1, max: 99 }), - name: faker.name.firstName(), - tag: faker.helpers.arrayElement([faker.random.word(), void 0]), + id: faker.number.int({ min: 1, max: 99 }), + name: faker.person.firstName(), + tag: faker.helpers.arrayElement([faker.word.sample(), void 0]), }))(); export const getSwaggerPetstoreMSW = () => [ diff --git a/samples/react-query/basic/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts b/samples/react-query/basic/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts index c53e06c19..885eca9aa 100644 --- a/samples/react-query/basic/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts +++ b/samples/react-query/basic/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts @@ -9,7 +9,7 @@ import { rest } from 'msw'; export const getListPetsMock = () => Array.from( - { length: faker.datatype.number({ min: 1, max: 10 }) }, + { length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1, ).map(() => faker.helpers.arrayElement([ diff --git a/samples/react-query/custom-client/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts b/samples/react-query/custom-client/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts index 0c499f0cd..941768cba 100644 --- a/samples/react-query/custom-client/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts +++ b/samples/react-query/custom-client/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts @@ -9,7 +9,7 @@ import { rest } from 'msw'; export const getListPetsMock = () => Array.from( - { length: faker.datatype.number({ min: 1, max: 10 }) }, + { length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1, ).map(() => ({ '@id': faker.helpers.arrayElement([faker.word.sample(), undefined]), diff --git a/samples/svelte-query/orval.config.ts b/samples/svelte-query/orval.config.ts index bdb272971..671474866 100644 --- a/samples/svelte-query/orval.config.ts +++ b/samples/svelte-query/orval.config.ts @@ -20,7 +20,7 @@ export default defineConfig({ mock: { properties: () => { return { - '[].id': () => faker.datatype.number({ min: 1, max: 99999 }), + '[].id': () => faker.number.int({ min: 1, max: 99999 }), }; }, }, @@ -28,10 +28,10 @@ export default defineConfig({ showPetById: { mock: { data: () => ({ - id: faker.datatype.number({ min: 1, max: 99 }), - name: faker.name.firstName(), + id: faker.number.int({ min: 1, max: 99 }), + name: faker.person.firstName(), tag: faker.helpers.arrayElement([ - faker.datatype.string(), + faker.string.sample(), undefined, ]), }), @@ -40,7 +40,7 @@ export default defineConfig({ }, mock: { properties: { - '/tag|name/': () => faker.name.lastName(), + '/tag|name/': () => faker.person.lastName(), }, }, }, diff --git a/samples/svelte-query/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts b/samples/svelte-query/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts index 1633b01d2..126a1fb85 100644 --- a/samples/svelte-query/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts +++ b/samples/svelte-query/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts @@ -9,19 +9,19 @@ import { rest } from 'msw'; export const getListPetsMock = () => Array.from( - { length: faker.datatype.number({ min: 1, max: 10 }) }, + { length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1, ).map(() => ({ - id: (() => faker.datatype.number({ min: 1, max: 99999 }))(), - name: (() => faker.name.lastName())(), - tag: (() => faker.name.lastName())(), + id: (() => faker.number.int({ min: 1, max: 99999 }))(), + name: (() => faker.person.lastName())(), + tag: (() => faker.person.lastName())(), })); export const getShowPetByIdMock = () => (() => ({ - id: faker.datatype.number({ min: 1, max: 99 }), - name: faker.name.firstName(), - tag: faker.helpers.arrayElement([faker.datatype.string(), void 0]), + id: faker.number.int({ min: 1, max: 99 }), + name: faker.person.firstName(), + tag: faker.helpers.arrayElement([faker.string.sample(), void 0]), }))(); export const getSwaggerPetstoreMSW = () => [ diff --git a/samples/vue-query/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts b/samples/vue-query/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts index 635424a2f..49c961898 100644 --- a/samples/vue-query/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts +++ b/samples/vue-query/src/api/endpoints/petstoreFromFileSpecWithTransformer.msw.ts @@ -9,7 +9,7 @@ import { rest } from 'msw'; export const getListPetsMock = () => Array.from( - { length: faker.datatype.number({ min: 1, max: 10 }) }, + { length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1, ).map(() => ({ email: faker.helpers.arrayElement([faker.internet.email(), undefined]),