From 788c7d0b56617306ea1f3070f7f3aa73e1c59e59 Mon Sep 17 00:00:00 2001 From: Igor Donin Date: Thu, 18 Jul 2024 05:54:37 -0300 Subject: [PATCH 01/30] feat(nestjs-query): add support to custom get requests (#6133) Co-authored-by: Batuhan Wilhelm --- .changeset/pretty-gifts-try.md | 7 + .../nestjs-query/src/dataProvider/index.ts | 40 +- .../nestjs-query/test/custom/index.mock.ts | 344 ++++++++++++------ .../nestjs-query/test/custom/index.spec.ts | 200 +++++++++- 4 files changed, 463 insertions(+), 128 deletions(-) create mode 100644 .changeset/pretty-gifts-try.md diff --git a/.changeset/pretty-gifts-try.md b/.changeset/pretty-gifts-try.md new file mode 100644 index 000000000000..e2cd457fa006 --- /dev/null +++ b/.changeset/pretty-gifts-try.md @@ -0,0 +1,7 @@ +--- +"@refinedev/nestjs-query": patch +--- + +Custom requests now correctly support GET requests and makes uses of custom URL and headers. + +Resolves #6112 diff --git a/packages/nestjs-query/src/dataProvider/index.ts b/packages/nestjs-query/src/dataProvider/index.ts index 433c7bbbdf92..45f77305299b 100644 --- a/packages/nestjs-query/src/dataProvider/index.ts +++ b/packages/nestjs-query/src/dataProvider/index.ts @@ -3,7 +3,7 @@ import type { BaseRecord, DataProvider, LogicalFilter } from "@refinedev/core"; import camelcase from "camelcase"; import * as gql from "gql-query-builder"; import type VariableOptions from "gql-query-builder/build/VariableOptions"; -import type { GraphQLClient } from "graphql-request"; +import { GraphQLClient } from "graphql-request"; import gqlTag from "graphql-tag"; import { singular } from "pluralize"; @@ -419,30 +419,37 @@ const dataProvider = (client: GraphQLClient): Required => { return (client as any).url; // url field in GraphQLClient is private }, custom: async ({ url, method, headers, meta }) => { - if (url) { - client.setEndpoint(url); - } + const SUPPORTED_METHODS = ["get", "post"]; + const requestUrl = url || (client as any).url; - if (headers) { - client.setHeaders(headers); + if (!SUPPORTED_METHODS.some((it) => it === method)) { + throw Error(`GraphQL does not support ${method} method.`); } + const validMethod = method as "get" | "post"; + + const _client = new GraphQLClient(requestUrl, { + ...client.requestConfig, + method: validMethod, + headers: { ...client.requestConfig.headers, ...headers }, + }); + const gqlOperation = meta?.gqlMutation ?? meta?.gqlQuery; if (gqlOperation) { - const response: any = await client.request( - gqlOperation, - meta?.variables ?? {}, - ); + const response: any = await _client.request({ + document: gqlOperation, + variables: meta?.variables, + }); return { data: response }; } if (meta?.rawQuery) { - const response = await client.request( - meta.rawQuery, - meta.variables, - ); + const response = await _client.request({ + document: meta.rawQuery, + variables: meta.variables, + }); return { data: response }; } @@ -472,7 +479,10 @@ const dataProvider = (client: GraphQLClient): Required => { variables = gqlMutation.variables; } - const response = await client.request(query, variables); + const response = await _client.request({ + document: query, + variables, + }); return { data: response[meta.operation], diff --git a/packages/nestjs-query/test/custom/index.mock.ts b/packages/nestjs-query/test/custom/index.mock.ts index d5b1b09fe81f..ad3c922feb2f 100644 --- a/packages/nestjs-query/test/custom/index.mock.ts +++ b/packages/nestjs-query/test/custom/index.mock.ts @@ -3,10 +3,75 @@ import nock from "nock"; nock("http://localhost:3003", { encodedQueryParams: true }) .post("/graphql", { query: - "query BlogPostAggregate {\n blogPostAggregate {\n groupBy {\n status\n }\n count {\n status\n }\n }\n}\n", - variables: {}, - operationName: "BlogPostAggregate", + "mutation UpdateManyBlogPosts($input: UpdateManyBlogPostsInput!) {\n updateManyBlogPosts(input: $input) {\n updatedCount\n }\n}\n", + variables: { + input: { + value: { + filter: { + id: { + in: ["42"], + }, + }, + update: { + status: "REJECTED", + }, + }, + type: "UpdateManyBlogPostsInput", + required: true, + }, + }, + operationName: "UpdateManyBlogPosts", + }) + .reply(200, { data: { updateManyBlogPosts: { updatedCount: 1 } } }, [ + "X-Powered-By", + "Express", + "cache-control", + "no-store", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "52", + "ETag", + 'W/"34-q7TcgM8PgtPGtmI2KSKG50FWvSI"', + "Date", + "Tue, 08 Aug 2023 11:40:35 GMT", + "Connection", + "close", + ]); + +nock("http://localhost:3003", { encodedQueryParams: true }) + .post("/graphql", { + query: + "mutation ($input: UpdateManyBlogPostsInput!) {\n updateManyBlogPosts (input: $input) {\n updatedCount\n }\n }", + variables: { + input: { + filter: { id: { in: ["42"] } }, + update: { status: "REJECTED" }, + }, + }, }) + .reply(200, { data: { updateManyBlogPosts: { updatedCount: 1 } } }, [ + "X-Powered-By", + "Express", + "cache-control", + "no-store", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "52", + "ETag", + 'W/"34-q7TcgM8PgtPGtmI2KSKG50FWvSI"', + "Date", + "Tue, 08 Aug 2023 11:40:35 GMT", + "Connection", + "close", + ]); + +nock("http://localhost:3003") + .get("/graphql") + .query( + "query=query%20BlogPostAggregate%20%7B%20blogPostAggregate%20%7B%20groupBy%20%7B%20status%20%7D%20count%20%7B%20status%20%7D%20%7D%20%7D&operationName=BlogPostAggregate", + ) .reply( 200, { @@ -39,29 +104,11 @@ nock("http://localhost:3003", { encodedQueryParams: true }) ], ); -nock("http://localhost:3003", { encodedQueryParams: true }) - .post("/graphql", { - query: - "query GetAllBlogPosts($sorting: [BlogPostSort!], $filter: BlogPostFilter!, $paging: OffsetPaging!) {\n sorted: blogPosts(sorting: $sorting, paging: $paging) {\n nodes {\n id\n title\n createdAt\n }\n }\n filtered: blogPosts(filter: $filter) {\n nodes {\n id\n }\n }\n}\n", - variables: { - sorting: [ - { - field: "id", - direction: "ASC", - }, - ], - filter: { - id: { - eq: 1, - }, - }, - paging: { - limit: 2, - offset: 0, - }, - }, - operationName: "GetAllBlogPosts", - }) +nock("http://localhost:3003") + .get("/graphql") + .query( + "query=query%20GetAllBlogPosts(%24sorting%3A%20%5BBlogPostSort!%5D%20%24filter%3A%20BlogPostFilter!%20%24paging%3A%20OffsetPaging!)%20%7B%20sorted%3A%20blogPosts(sorting%3A%20%24sorting%20paging%3A%20%24paging)%20%7B%20nodes%20%7B%20id%20title%20createdAt%20%7D%20%7D%20filtered%3A%20blogPosts(filter%3A%20%24filter)%20%7B%20nodes%20%7B%20id%20%7D%20%7D%20%7D&variables=%7B%22sorting%22%3A%5B%7B%22field%22%3A%22id%22%2C%22direction%22%3A%22ASC%22%7D%5D%2C%22filter%22%3A%7B%22id%22%3A%7B%22eq%22%3A1%7D%7D%2C%22paging%22%3A%7B%22limit%22%3A2%2C%22offset%22%3A0%7D%7D&operationName=GetAllBlogPosts", + ) .reply( 200, { @@ -103,51 +150,11 @@ nock("http://localhost:3003", { encodedQueryParams: true }) ], ); -nock("http://localhost:3003", { encodedQueryParams: true }) - .post("/graphql", { - query: - "mutation UpdateManyBlogPosts($input: UpdateManyBlogPostsInput!) {\n updateManyBlogPosts(input: $input) {\n updatedCount\n }\n}\n", - variables: { - input: { - value: { - filter: { - id: { - in: ["42"], - }, - }, - update: { - status: "REJECTED", - }, - }, - type: "UpdateManyBlogPostsInput", - required: true, - }, - }, - operationName: "UpdateManyBlogPosts", - }) - .reply(200, { data: { updateManyBlogPosts: { updatedCount: 1 } } }, [ - "X-Powered-By", - "Express", - "cache-control", - "no-store", - "Content-Type", - "application/json; charset=utf-8", - "Content-Length", - "52", - "ETag", - 'W/"34-q7TcgM8PgtPGtmI2KSKG50FWvSI"', - "Date", - "Tue, 08 Aug 2023 11:40:35 GMT", - "Connection", - "close", - ]); - -nock("http://localhost:3003", { encodedQueryParams: true }) - .post("/graphql", { - query: - "query { blogPostAggregate { groupBy { status }, count { status } } }", - variables: {}, - }) +nock("http://localhost:3003") + .get("/graphql") + .query( + "query=query%20%7B%20blogPostAggregate%20%7B%20groupBy%20%7B%20status%20%7D%20count%20%7B%20status%20%7D%20%7D%20%7D&variables=%7B%7D", + ) .reply( 200, { @@ -165,32 +172,28 @@ nock("http://localhost:3003", { encodedQueryParams: true }) [ "X-Powered-By", "Express", + "Access-Control-Allow-Origin", + "*", "cache-control", "no-store", "Content-Type", "application/json; charset=utf-8", "Content-Length", - "202", + "232", "ETag", - 'W/"ca-6w/o6KLhG7ECL6B1j+01HCRQ2WI"', + 'W/"e8-BmQnXB76cWxgdpzFJzlbXG/5e40"', "Date", - "Tue, 08 Aug 2023 11:40:35 GMT", + "Wed, 09 Aug 2023 09:59:49 GMT", "Connection", "close", ], ); -nock("http://localhost:3003", { encodedQueryParams: true }) - .post("/graphql", { - query: - "\n query GetAllBlogPosts(\n $sorting: [BlogPostSort!]\n $filter: BlogPostFilter!\n $paging: OffsetPaging!\n ) {\n sorted: blogPosts(sorting: $sorting, paging: $paging) {\n nodes {\n id\n title\n createdAt\n }\n }\n filtered: blogPosts(filter: $filter) {\n nodes {\n id\n }\n }\n }\n ", - variables: { - sorting: [{ field: "id", direction: "ASC" }], - filter: { id: { eq: 1 } }, - paging: { limit: 2, offset: 0 }, - }, - operationName: "GetAllBlogPosts", - }) +nock("http://localhost:3003") + .get("/graphql") + .query( + "query=query%20GetAllBlogPosts(%20%24sorting%3A%20%5BBlogPostSort!%5D%20%24filter%3A%20BlogPostFilter!%20%24paging%3A%20OffsetPaging!%20)%20%7B%20sorted%3A%20blogPosts(sorting%3A%20%24sorting%20paging%3A%20%24paging)%20%7B%20nodes%20%7B%20id%20title%20createdAt%20%7D%20%7D%20filtered%3A%20blogPosts(filter%3A%20%24filter)%20%7B%20nodes%20%7B%20id%20%7D%20%7D%20%7D&variables=%7B%22sorting%22%3A%5B%7B%22field%22%3A%22id%22%2C%22direction%22%3A%22ASC%22%7D%5D%2C%22filter%22%3A%7B%22id%22%3A%7B%22eq%22%3A1%7D%7D%2C%22paging%22%3A%7B%22limit%22%3A2%2C%22offset%22%3A0%7D%7D&operationName=GetAllBlogPosts", + ) .reply( 200, { @@ -232,30 +235,157 @@ nock("http://localhost:3003", { encodedQueryParams: true }) ], ); -nock("http://localhost:3003", { encodedQueryParams: true }) +nock("http://localhost:3004") + .get("/graphql") + .query( + "query=query%20BlogPostAggregate%20%7B%20blogPostAggregate%20%7B%20groupBy%20%7B%20status%20%7D%20count%20%7B%20status%20%7D%20%7D%20%7D&operationName=BlogPostAggregate", + ) + .reply( + 200, + { + data: { + blogPostAggregate: [ + { groupBy: { status: "DRAFT" }, count: { status: 327 } }, + { + groupBy: { status: "PUBLISHED" }, + count: { status: 330 }, + }, + { groupBy: { status: "REJECTED" }, count: { status: 341 } }, + ], + }, + }, + [ + "X-Powered-By", + "Express", + "cache-control", + "no-store", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "202", + "ETag", + 'W/"ca-6w/o6KLhG7ECL6B1j+01HCRQ2WI"', + "Date", + "Tue, 08 Aug 2023 11:40:35 GMT", + "Connection", + "close", + ], + ); + +nock("http://localhost:3004", { + reqheaders: { + "Custom-Header": (value) => value === "Custom-Header-Value", + "Custom-Header-Before": (value) => value === "Custom-Header-Before", + }, +}) + .get("/graphql") + .query( + "query=query%20TestQuery%20%7B%20testAggregate%20%7B%20id%20%7D%20%7D&operationName=TestQuery", + ) + .reply( + 200, + { + data: { + testAggregate: { + id: "lorem ipsum", + }, + }, + }, + [ + "X-Powered-By", + "Express", + "cache-control", + "no-store", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "202", + "ETag", + 'W/"ca-6w/o6KLhG7ECL6B1j+01HCRQ2WI"', + "Date", + "Tue, 08 Aug 2023 11:40:35 GMT", + "Connection", + "close", + ], + ); + +nock("http://localhost:3004", { + reqheaders: { + "Subsequent-Test": (value) => value === "Subsequent-Test", + }, +}) + .get("/graphql") + .query( + "query=query%20TestQuery%20%7B%20testAggregate%20%7B%20id%20%7D%20%7D&operationName=TestQuery", + ) + .reply( + 200, + { + data: { + testAggregate: { + id: "lorem ipsum", + }, + }, + }, + [ + "X-Powered-By", + "Express", + "cache-control", + "no-store", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "202", + "ETag", + 'W/"ca-6w/o6KLhG7ECL6B1j+01HCRQ2WI"', + "Date", + "Tue, 08 Aug 2023 11:40:35 GMT", + "Connection", + "close", + ], + ); + +nock("http://localhost:3003", { + encodedQueryParams: true, + reqheaders: { + "Subsequent-Test": (value) => value === "Subsequent-Test", + }, +}) .post("/graphql", { query: - "mutation ($input: UpdateManyBlogPostsInput!) {\n updateManyBlogPosts (input: $input) {\n updatedCount\n }\n }", + "query GetOneBlogPost($id: ID!) {\n blogPost(id: $id) {\n id\n title\n content\n status\n category {\n id\n }\n }\n}\n", variables: { - input: { - filter: { id: { in: ["42"] } }, - update: { status: "REJECTED" }, - }, + id: "1", }, + operationName: "GetOneBlogPost", }) - .reply(200, { data: { updateManyBlogPosts: { updatedCount: 1 } } }, [ - "X-Powered-By", - "Express", - "cache-control", - "no-store", - "Content-Type", - "application/json; charset=utf-8", - "Content-Length", - "52", - "ETag", - 'W/"34-q7TcgM8PgtPGtmI2KSKG50FWvSI"', - "Date", - "Tue, 08 Aug 2023 11:40:35 GMT", - "Connection", - "close", - ]); + .reply( + 200, + { + data: { + blogPost: { + id: "1", + title: "updated-foo-2", + content: "updated-bar-2", + status: "PUBLISHED", + category: { id: "3" }, + }, + }, + }, + [ + "X-Powered-By", + "Express", + "cache-control", + "no-store", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "126", + "ETag", + 'W/"7e-Cl5he/nvkiuG9ZY19THgesoMW0g"', + "Date", + "Tue, 08 Aug 2023 11:40:36 GMT", + "Connection", + "close", + ], + ); diff --git a/packages/nestjs-query/test/custom/index.spec.ts b/packages/nestjs-query/test/custom/index.spec.ts index 9f675ec4d411..ff085fdea0f6 100644 --- a/packages/nestjs-query/test/custom/index.spec.ts +++ b/packages/nestjs-query/test/custom/index.spec.ts @@ -8,7 +8,7 @@ import gql from "graphql-tag"; describe("custom", () => { describe("gql", () => { - it("correct get query response", async () => { + it("correct get query response using GET request", async () => { const response = await dataProvider(client).custom?.({ url: "", method: "get", @@ -51,7 +51,7 @@ describe("custom", () => { ).toBeDefined(); }); - it("custom graphql query", async () => { + it("custom graphql query using GET request", async () => { const response = await dataProvider(client).custom({ url: "", method: "get", @@ -95,7 +95,7 @@ describe("custom", () => { expect(response.data.filtered.nodes).toHaveLength(1); }); - it("correct get mutation response", async () => { + it("correct get mutation response using POST request", async () => { const response = await dataProvider(client).custom?.({ url: "", method: "post", @@ -129,10 +129,155 @@ describe("custom", () => { expect(response?.data?.["updateManyBlogPosts"].updatedCount).toBe(1); }); + + it("correct get query response using GET request and custom URL", async () => { + const response = await dataProvider(client).custom?.({ + url: "http://localhost:3004/graphql", + method: "get", + meta: { + gqlQuery: gql` + query BlogPostAggregate { + blogPostAggregate { + groupBy { + status + } + count { + status + } + } + } + `, + operation: "blogPostAggregate", + fields: [{ groupBy: ["status"], count: ["status"] }], + }, + }); + + expect(response?.data?.["blogPostAggregate"]).toHaveLength(3); + expect(response.data?.["blogPostAggregate"][0].groupBy.status).toBe( + "DRAFT", + ); + expect( + response.data?.["blogPostAggregate"][0].count.status, + ).toBeDefined(); + expect(response.data?.["blogPostAggregate"][1].groupBy.status).toBe( + "PUBLISHED", + ); + expect( + response.data?.["blogPostAggregate"][1].count.status, + ).toBeDefined(); + expect(response.data?.["blogPostAggregate"][2].groupBy.status).toBe( + "REJECTED", + ); + expect( + response.data?.["blogPostAggregate"][2].count.status, + ).toBeDefined(); + }); + + it("correctly passes custom URL and custom headers without overriding existing headers using GET", async () => { + client.setHeader("Custom-Header-Before", "Custom-Header-Before"); + + const response = await dataProvider(client).custom?.({ + url: "http://localhost:3004/graphql", + method: "get", + headers: { + "Custom-Header": "Custom-Header-Value", + }, + meta: { + gqlQuery: gql` + query TestQuery { + testAggregate { + id + } + } + `, + operation: "testAggregate", + }, + }); + + expect(response?.data?.testAggregate.id).toBe("lorem ipsum"); + }); + + it("doesnt change URL of subsequent requests", async () => { + client.setHeader("Subsequent-Test", "Subsequent-Test"); + + const response = await dataProvider(client).custom?.({ + url: "http://localhost:3004/graphql", + method: "get", + meta: { + gqlQuery: gql` + query TestQuery { + testAggregate { + id + } + } + `, + operation: "testAggregate", + }, + }); + + expect(response?.data?.testAggregate.id).toBe("lorem ipsum"); + + const nextResponse = await dataProvider(client).getOne({ + resource: "blog_posts", + id: "1", + meta: { + gqlQuery: gql` + query GetOneBlogPost($id: ID!) { + blogPost(id: $id) { + id + title + content + status + category { + id + } + } + } + `, + }, + }); + + expect(nextResponse.data?.id).toBe("1"); + }); + + it("unsupported method throws error", async () => { + const unsupportedMethods = ["delete", "head", "options", "put", "patch"]; + unsupportedMethods.sort(() => Math.random() - 0.5); + const method = unsupportedMethods[0] as any; + + try { + await dataProvider(client).custom?.({ + url: "", + method, + meta: { + operation: "updateManyBlogPosts", + variables: { + input: { + value: { + filter: { + id: { in: ["42"] }, + }, + update: { + status: "REJECTED", + }, + }, + type: "UpdateManyBlogPostsInput", + required: true, + }, + }, + fields: ["updatedCount"], + }, + }); + } catch (e) { + expect((e as Error).message).toBe( + `GraphQL does not support ${method} method.`, + ); + } + }); }); describe("fields (legacy)", () => { - it("correct get query response", async () => { + it("correct get query response using GET request", async () => { const response = await dataProvider(client).custom?.({ url: "", method: "get", @@ -151,7 +296,7 @@ describe("custom", () => { expect(response.data[2].count.status).toBeDefined(); }); - it("custom graphql query", async () => { + it("custom graphql query using GET request", async () => { const response = await dataProvider(client).custom({ url: "", method: "get", @@ -192,7 +337,7 @@ describe("custom", () => { expect(response.data.filtered.nodes).toHaveLength(1); }); - it("correct get mutation response", async () => { + it("correct get mutation response using POST request", async () => { const response = await dataProvider(client).custom?.({ url: "", method: "post", @@ -218,5 +363,48 @@ describe("custom", () => { expect(response?.data.updatedCount).toBe(1); }); + + it("throws error when no operation name is provided", async () => { + try { + await dataProvider(client).custom?.({ + url: "", + method: "post", + meta: { + variables: { + input: { + value: { + filter: { + id: { in: ["42"] }, + }, + update: { + status: "REJECTED", + }, + }, + type: "UpdateManyBlogPostsInput", + required: true, + }, + }, + fields: ["updatedCount"], + }, + }); + } catch (e) { + expect((e as Error).message).toEqual( + "GraphQL operation name required.", + ); + } + }); + + it("throws error when no meta is provided", async () => { + try { + await dataProvider(client).custom?.({ + url: "", + method: "post", + }); + } catch (e) { + expect((e as Error).message).toEqual( + "GraphQL needs operation, fields and variables values in meta object.", + ); + } + }); }); }); From 4b842703dbeb5306fef5c804bc5366e52fa830a0 Mon Sep 17 00:00:00 2001 From: Sergio Rene Tapia-Fikes <47071119+Sergio16T@users.noreply.github.com> Date: Thu, 18 Jul 2024 07:06:05 -0500 Subject: [PATCH 02/30] fix(useDataGrid): overide DataGridPropsType onFilterModelChange (#6151) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ali Emir Şen --- .changeset/fast-hounds-guess.md | 9 +++++++++ .../material-ui/hooks/use-data-grid/index.md | 4 ++-- packages/mui/src/hooks/useDataGrid/index.ts | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 .changeset/fast-hounds-guess.md diff --git a/.changeset/fast-hounds-guess.md b/.changeset/fast-hounds-guess.md new file mode 100644 index 000000000000..f548f66278d2 --- /dev/null +++ b/.changeset/fast-hounds-guess.md @@ -0,0 +1,9 @@ +--- +"@refinedev/mui": patch +--- + +fix(use-data-grid): incompatible types when using data-grid-pro + +useDataGrid overide DataGridPropsType onFilterModelChange. + +[Fixes #5997](https://github.com/refinedev/refine/issues/5997) diff --git a/documentation/docs/ui-integrations/material-ui/hooks/use-data-grid/index.md b/documentation/docs/ui-integrations/material-ui/hooks/use-data-grid/index.md index 8209096cf6d7..89293ba625f7 100644 --- a/documentation/docs/ui-integrations/material-ui/hooks/use-data-grid/index.md +++ b/documentation/docs/ui-integrations/material-ui/hooks/use-data-grid/index.md @@ -786,8 +786,8 @@ When the user filters a column, this function is called with the new filter mode {...dataGridProps} columns={columns} autoHeight - onFilterModelChange={(model, details) => { - dataGridProps.onFilterModelChange(model, details); + onFilterModelChange={(model) => { + dataGridProps.onFilterModelChange(model); // do something else }} /> diff --git a/packages/mui/src/hooks/useDataGrid/index.ts b/packages/mui/src/hooks/useDataGrid/index.ts index a6c0f561cc06..730b509ec2fe 100644 --- a/packages/mui/src/hooks/useDataGrid/index.ts +++ b/packages/mui/src/hooks/useDataGrid/index.ts @@ -33,9 +33,13 @@ import { transformSortModelToCrudSorting, } from "@definitions"; +type DataGridPropsOverride = Omit & { + onFilterModelChange: (model: GridFilterModel) => void; +}; + type DataGridPropsType = Required< Pick< - DataGridProps, + DataGridPropsOverride, | "rows" | "loading" | "rowCount" From ccddff6eba23286d4025a7301de3ebfc24b1b633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20Emir=20=C5=9Een?= Date: Mon, 22 Jul 2024 13:44:24 +0300 Subject: [PATCH 03/30] fix(devtools-internal): fix noop return on hooks for production builds (#6165) --- .changeset/pretty-snails-shake.md | 9 +++++++++ .../devtools-internal/src/use-query-subscription.tsx | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 .changeset/pretty-snails-shake.md diff --git a/.changeset/pretty-snails-shake.md b/.changeset/pretty-snails-shake.md new file mode 100644 index 000000000000..3872a2b2f284 --- /dev/null +++ b/.changeset/pretty-snails-shake.md @@ -0,0 +1,9 @@ +--- +"@refinedev/devtools-internal": patch +--- + +fix(devtools-internal): fix noop return on hooks for production builds + +Currently, `@refinedev/devtools-internal` returns noop function when bundled for production, yet the notation is not correctly interpreted by some bundlers. This PR fixes the issue by moving the empty return and noop functions to a separate definition. + +[Resolves #6030](https://github.com/refinedev/refine/issues/6030) diff --git a/packages/devtools-internal/src/use-query-subscription.tsx b/packages/devtools-internal/src/use-query-subscription.tsx index a79908551d53..7f4945f27b6b 100644 --- a/packages/devtools-internal/src/use-query-subscription.tsx +++ b/packages/devtools-internal/src/use-query-subscription.tsx @@ -7,11 +7,12 @@ import type { QueryClient } from "@tanstack/react-query"; import React, { useContext } from "react"; import { createQueryListener, createMutationListener } from "./listeners"; +const empty = {}; +const noop = () => empty; + export const useQuerySubscription = __DEV_CONDITION__ !== "development" - ? () => { - return {}; - } + ? noop : (queryClient: QueryClient) => { const { ws } = useContext(DevToolsContext); const queryCacheSubscription = React.useRef<() => void>(); From fa2d7a4554da2d5fb2432a011941f9c157b59aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20Emir=20=C5=9Een?= Date: Mon, 22 Jul 2024 14:30:00 +0300 Subject: [PATCH 04/30] chore(core-devtools): add changeset --- .changeset/spotty-rocks-matter.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/spotty-rocks-matter.md diff --git a/.changeset/spotty-rocks-matter.md b/.changeset/spotty-rocks-matter.md new file mode 100644 index 000000000000..783a147dd4f2 --- /dev/null +++ b/.changeset/spotty-rocks-matter.md @@ -0,0 +1,7 @@ +--- +"@refinedev/core": patch +--- + +chore(devtools): bump internal devtools dependency + +Bump `@refinedev/devtools-internal` version. From 61aa3464df0d95c30839726f455ed43e6854730b Mon Sep 17 00:00:00 2001 From: Dominic Preap Date: Thu, 25 Jul 2024 22:57:18 +0700 Subject: [PATCH 05/30] fix(core): update debounce behavior on `onSearch` in `useSelect` (#6125) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ali Emir Şen --- .changeset/thin-adults-complain.md | 9 ++ .../core/src/hooks/useSelect/index.spec.ts | 91 +++++++++++++++++-- packages/core/src/hooks/useSelect/index.ts | 56 +++++++----- 3 files changed, 124 insertions(+), 32 deletions(-) create mode 100644 .changeset/thin-adults-complain.md diff --git a/.changeset/thin-adults-complain.md b/.changeset/thin-adults-complain.md new file mode 100644 index 000000000000..7fbd9b9e0751 --- /dev/null +++ b/.changeset/thin-adults-complain.md @@ -0,0 +1,9 @@ +--- +"@refinedev/core": minor +--- + +fix: update debounce behavior on `onSearch` in `useSelect` + +Now debounce behavior is working correctly on `onSearch` in `useSelect` when using inside `Controller` of react-hook-form. + +Resolves [#6096](https://github.com/refinedev/refine/issues/6096) diff --git a/packages/core/src/hooks/useSelect/index.spec.ts b/packages/core/src/hooks/useSelect/index.spec.ts index f58df9b8fe6d..2b20d167e6c8 100644 --- a/packages/core/src/hooks/useSelect/index.spec.ts +++ b/packages/core/src/hooks/useSelect/index.spec.ts @@ -315,7 +315,7 @@ describe("useSelect Hook", () => { it("should onSearchFromProp work as expected", async () => { const getListMock = jest.fn(() => Promise.resolve({ data: [], total: 0 })); - const { result } = renderHook( + const { result, rerender } = renderHook( () => useSelect({ resource: "posts", @@ -342,21 +342,92 @@ describe("useSelect Hook", () => { }, ); - const { onSearch } = result.current; + await waitFor(() => expect(getListMock).toHaveBeenCalledTimes(1)); - onSearch("1"); - await waitFor(() => { - expect(getListMock).toBeCalledTimes(2); + result.current.onSearch("1"); + // force custom `onSearch` to reinitialize, this should not change `current.onSearch` + rerender(); + result.current.onSearch("2"); + // force custom `onSearch` to reinitialize, this should not change `current.onSearch` + rerender(); + result.current.onSearch("3"); + + await waitFor(() => expect(getListMock).toHaveBeenCalledTimes(2)); + + result.current.onSearch(""); + + await waitFor(() => expect(getListMock).toHaveBeenCalledTimes(3)); + + await waitFor(() => + expect(result.current.queryResult.isSuccess).toBeTruthy(), + ); + }); + + it("should respond to onSearch prop changes without breaking the debounce interval", async () => { + const getListMock = jest.fn(() => Promise.resolve({ data: [], total: 0 })); + const initialOnSearch = jest.fn().mockImplementation((v) => [ + { + field: "title", + operator: "contains", + value: v, + }, + ]); + const secondOnSearch = jest.fn().mockImplementation((v) => [ + { + field: "title", + operator: "contains", + value: v, + }, + ]); + + const { result, rerender } = renderHook< + Parameters[0], + ReturnType + >((props) => useSelect(props), { + initialProps: { + resource: "posts", + onSearch: initialOnSearch, + }, + wrapper: TestWrapper({ + dataProvider: { + default: { + ...MockJSONServer.default!, + getList: getListMock, + }, + }, + resources: [{ name: "posts" }], + }) as any, }); - onSearch(""); - await waitFor(() => { - expect(getListMock).toBeCalledTimes(3); + await waitFor(() => expect(getListMock).toHaveBeenCalledTimes(1)); + + result.current.onSearch("1"); + + rerender({ + resource: "posts", + onSearch: secondOnSearch, }); - await waitFor(() => { - expect(result.current.queryResult.isSuccess).toBeTruthy(); + result.current.onSearch("2"); + + await waitFor(() => expect(getListMock).toHaveBeenCalledTimes(2)); + await waitFor(() => expect(initialOnSearch).toHaveBeenCalledTimes(0)); + await waitFor(() => expect(secondOnSearch).toHaveBeenCalledTimes(1)); + + result.current.onSearch(""); + + rerender({ + resource: "posts", + onSearch: initialOnSearch, }); + + await waitFor(() => expect(getListMock).toHaveBeenCalledTimes(3)); + await waitFor(() => expect(initialOnSearch).toHaveBeenCalledTimes(1)); + await waitFor(() => expect(secondOnSearch).toHaveBeenCalledTimes(1)); + + await waitFor(() => + expect(result.current.queryResult.isSuccess).toBeTruthy(), + ); }); it("should invoke queryOptions methods successfully", async () => { diff --git a/packages/core/src/hooks/useSelect/index.ts b/packages/core/src/hooks/useSelect/index.ts index 3a08f8fde0bf..9a8933cee080 100644 --- a/packages/core/src/hooks/useSelect/index.ts +++ b/packages/core/src/hooks/useSelect/index.ts @@ -1,4 +1,4 @@ -import { useCallback, useMemo, useState } from "react"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import type { QueryObserverResult, @@ -343,26 +343,6 @@ export const useSelect = < dataProviderName, }); - const onSearch = (value: string) => { - if (onSearchFromProp) { - setSearch(onSearchFromProp(value)); - return; - } - - if (!value) { - setSearch([]); - return; - } - - setSearch([ - { - field: searchField, - operator: "contains", - value, - }, - ]); - }; - const { elapsedTime } = useLoadingOvertime({ isLoading: queryResult.isFetching || defaultValueQueryResult.isFetching, interval: overtimeOptions?.interval, @@ -380,11 +360,43 @@ export const useSelect = < [options, selectedOptions], ); + /** + * To avoid any changes in the `onSearch` callback, + * We're storing `onSearchFromProp` in a ref and accessing it in the `onSearch` callback. + */ + const onSearchFromPropRef = useRef(onSearchFromProp); + + const onSearch = useMemo(() => { + return debounce((value: string) => { + if (onSearchFromPropRef.current) { + setSearch(onSearchFromPropRef.current(value)); + return; + } + + if (!value) { + setSearch([]); + return; + } + + setSearch([ + { + field: searchField, + operator: "contains", + value, + }, + ]); + }, debounceValue); + }, [searchField, debounceValue]); + + useEffect(() => { + onSearchFromPropRef.current = onSearchFromProp; + }, [onSearchFromProp]); + return { queryResult, defaultValueQueryResult, options: combinedOptions, - onSearch: debounce(onSearch, debounceValue), + onSearch, overtime: { elapsedTime }, }; }; From 1f7976bd32da311367945370efccd7d9c9b102a7 Mon Sep 17 00:00:00 2001 From: MOHAMMAD SARFRAZ ALAM Date: Thu, 25 Jul 2024 21:28:19 +0530 Subject: [PATCH 06/30] fix(core): useTranslate to import from @hooks in auth login page (#6184) Co-authored-by: Sarfraz Alam Co-authored-by: Batuhan Wilhelm --- .changeset/famous-donuts-bake.md | 5 +++++ .../src/components/pages/auth/components/login/index.tsx | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .changeset/famous-donuts-bake.md diff --git a/.changeset/famous-donuts-bake.md b/.changeset/famous-donuts-bake.md new file mode 100644 index 000000000000..920dad2fc93d --- /dev/null +++ b/.changeset/famous-donuts-bake.md @@ -0,0 +1,5 @@ +--- +"@refinedev/core": patch +--- + +AuthPage in Next.js generates code with i18n but the folder hooks is not created. imported useTranslate from @hooks to fix the issue diff --git a/packages/core/src/components/pages/auth/components/login/index.tsx b/packages/core/src/components/pages/auth/components/login/index.tsx index 90daab4e2bc4..2a50ad4ea8a4 100644 --- a/packages/core/src/components/pages/auth/components/login/index.tsx +++ b/packages/core/src/components/pages/auth/components/login/index.tsx @@ -1,8 +1,13 @@ import React, { useState } from "react"; import { useActiveAuthProvider } from "@definitions/helpers"; -import { useLink, useLogin, useRouterContext, useRouterType } from "@hooks"; -import { useTranslate } from "@hooks/i18n"; +import { + useLink, + useLogin, + useRouterContext, + useRouterType, + useTranslate, +} from "@hooks"; import type { DivPropsType, FormPropsType } from "../.."; import type { LoginFormTypes, LoginPageProps } from "../../types"; From f3e06e8ea3cd65bfe8a8eb0e347aa45b93015764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20Emir=20=C5=9Een?= Date: Fri, 26 Jul 2024 00:59:06 +0300 Subject: [PATCH 07/30] fix(mui): broken `` sizing in `` (#6144) --- .changeset/cold-olives-allow.md | 11 +++++++++++ packages/mui/src/components/themedLayoutV2/index.tsx | 5 ++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 .changeset/cold-olives-allow.md diff --git a/.changeset/cold-olives-allow.md b/.changeset/cold-olives-allow.md new file mode 100644 index 000000000000..b6b67e2c18cb --- /dev/null +++ b/.changeset/cold-olives-allow.md @@ -0,0 +1,11 @@ +--- +"@refinedev/mui": patch +--- + +fix(mui): horizontal scroll is broken in + +Due to the changes in CSS rendering in latest Google Chrome updates, `` components are not properly sized when used inside `` component. The `overflow: clip` property in the layout content is causing either miscalculations on the data grid width or causing an overflow on the container and overlapping with the sidebar. + +This change replaces the `overflow: clip` property with `min-height` and `min-width` properties to ensure the layout content is properly rendered and responsive to the content inside it. + +[Resolves #6077](https://github.com/refinedev/refine/issues/6077) diff --git a/packages/mui/src/components/themedLayoutV2/index.tsx b/packages/mui/src/components/themedLayoutV2/index.tsx index 1084a4273e8d..df25e644ee2b 100644 --- a/packages/mui/src/components/themedLayoutV2/index.tsx +++ b/packages/mui/src/components/themedLayoutV2/index.tsx @@ -29,10 +29,9 @@ export const ThemedLayoutV2: React.FC = ({ display: "flex", flexDirection: "column", flex: 1, - minHeight: "100vh", + minWidth: "1px", + minHeight: "1px", }, - { overflow: "auto" }, - { overflow: "clip" }, ]} > From ff975374efcc05220be4411218c2daf7c19b8995 Mon Sep 17 00:00:00 2001 From: Rita Bancevicius Date: Fri, 26 Jul 2024 03:37:27 -0400 Subject: [PATCH 08/30] feat(react-hook-form): update version constraint from `^7.30.0` to `^7.43.5` (#6161) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ali Emir Şen --- .changeset/metal-eagles-notice.md | 13 ++ .../server-side-validation-chakra-ui.tsx | 2 +- .../forms/server-side-validation-mui.tsx | 2 +- ...server-side-validation-react-hook-form.tsx | 2 +- .../introduction/previews/auth-page.tsx | 2 +- .../introduction/previews/basic-views.tsx | 2 +- .../introduction/previews/example.tsx | 2 +- .../previews/layout-react-router-dom.tsx | 2 +- .../introduction/previews/theming.tsx | 2 +- .../introduction/previews/auth-page.tsx | 2 +- .../introduction/previews/basic-views.tsx | 2 +- .../introduction/previews/example.tsx | 2 +- .../previews/layout-react-router-dom.tsx | 2 +- .../introduction/previews/theming.tsx | 2 +- .../introduction/previews/usage-next-js.tsx | 2 +- .../previews/usage-react-router-dom.tsx | 2 +- .../introduction/previews/usage-remix.tsx | 2 +- examples/base-material-ui/package.json | 2 +- .../blog-material-ui-datagrid/package.json | 2 +- examples/blog-material-ui/package.json | 2 +- examples/blog-ra-chakra-tutorial/package.json | 2 +- examples/blog-react-aria/package.json | 2 +- .../blog-react-hook-dynamic-form/package.json | 2 +- examples/blog-refine-mui/package.json | 2 +- examples/blog-refine-nextui/package.json | 2 +- examples/blog-refine-primereact/package.json | 2 +- .../blog-refine-react-hook-form/package.json | 2 +- examples/blog-win95/package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- examples/finefoods-material-ui/package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- .../form-material-ui-use-form/package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- examples/inferencer-chakra-ui/package.json | 2 +- examples/inferencer-material-ui/package.json | 2 +- examples/mern-dashboard-client/package.json | 2 +- .../package.json | 2 +- examples/store/package.json | 2 +- .../table-material-ui-advanced/package.json | 2 +- .../package.json | 2 +- .../table-react-table-advanced/package.json | 2 +- examples/theme-material-ui-demo/package.json | 2 +- examples/tutorial-material-ui/package.json | 2 +- .../upload-material-ui-base64/package.json | 2 +- .../upload-material-ui-multipart/package.json | 2 +- examples/with-material-ui-vite/package.json | 2 +- packages/chakra-ui/package.json | 4 +- .../v4/separate-imports-react-hook-form.ts | 2 +- packages/inferencer/package.json | 2 +- packages/live-previews/package.json | 2 +- packages/mui/package.json | 4 +- packages/react-hook-form/package.json | 4 +- pnpm-lock.yaml | 124 +++++++++--------- 57 files changed, 133 insertions(+), 120 deletions(-) create mode 100644 .changeset/metal-eagles-notice.md diff --git a/.changeset/metal-eagles-notice.md b/.changeset/metal-eagles-notice.md new file mode 100644 index 000000000000..7407adb30fe6 --- /dev/null +++ b/.changeset/metal-eagles-notice.md @@ -0,0 +1,13 @@ +--- +"@refinedev/react-hook-form": minor +"@refinedev/inferencer": minor +"@refinedev/chakra-ui": minor +"@refinedev/codemod": minor +"@refinedev/mui": minor +--- + +feat(react-hook-form): update version constraint from `^7.30.0` to `^7.43.5` + +Update react-hook-form version to address runtime subscribe error + +[Fixes #6139](https://github.com/refinedev/refine/issues/6139) diff --git a/documentation/docs/guides-concepts/forms/server-side-validation-chakra-ui.tsx b/documentation/docs/guides-concepts/forms/server-side-validation-chakra-ui.tsx index fc93583620d0..153512b5a536 100644 --- a/documentation/docs/guides-concepts/forms/server-side-validation-chakra-ui.tsx +++ b/documentation/docs/guides-concepts/forms/server-side-validation-chakra-ui.tsx @@ -19,7 +19,7 @@ export default function ServerSideValidationChakraUi() { "react-dom": "^18.0.0", "react-router": "latest", "react-router-dom": "^6.8.1", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", }} startRoute="/products/create" files={{ diff --git a/documentation/docs/guides-concepts/forms/server-side-validation-mui.tsx b/documentation/docs/guides-concepts/forms/server-side-validation-mui.tsx index 8579037ea7f8..e2c57bf751f3 100644 --- a/documentation/docs/guides-concepts/forms/server-side-validation-mui.tsx +++ b/documentation/docs/guides-concepts/forms/server-side-validation-mui.tsx @@ -20,7 +20,7 @@ export default function ServerSideValidationMui() { "@mui/x-data-grid": "^6.6.0", "react-router-dom": "latest", "react-router": "latest", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", }} startRoute="/products/create" files={{ diff --git a/documentation/docs/guides-concepts/forms/server-side-validation-react-hook-form.tsx b/documentation/docs/guides-concepts/forms/server-side-validation-react-hook-form.tsx index cc9ba24ad876..742246edd8ee 100644 --- a/documentation/docs/guides-concepts/forms/server-side-validation-react-hook-form.tsx +++ b/documentation/docs/guides-concepts/forms/server-side-validation-react-hook-form.tsx @@ -15,7 +15,7 @@ export default function ServerSideValidationReactHookForm() { "react-dom": "^18.0.0", "react-router": "latest", "react-router-dom": "^6.8.1", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", }} startRoute="/products/create" files={{ diff --git a/documentation/docs/ui-integrations/chakra-ui/introduction/previews/auth-page.tsx b/documentation/docs/ui-integrations/chakra-ui/introduction/previews/auth-page.tsx index dee664e5fdea..a4fdc75b5d57 100644 --- a/documentation/docs/ui-integrations/chakra-ui/introduction/previews/auth-page.tsx +++ b/documentation/docs/ui-integrations/chakra-ui/introduction/previews/auth-page.tsx @@ -20,7 +20,7 @@ export default function AuthPage() { "react-dom": "^18.0.0", "react-router": "latest", "react-router-dom": "^6.8.1", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", }} startRoute="/login" files={{ diff --git a/documentation/docs/ui-integrations/chakra-ui/introduction/previews/basic-views.tsx b/documentation/docs/ui-integrations/chakra-ui/introduction/previews/basic-views.tsx index 43fa89660d03..d981a9324713 100644 --- a/documentation/docs/ui-integrations/chakra-ui/introduction/previews/basic-views.tsx +++ b/documentation/docs/ui-integrations/chakra-ui/introduction/previews/basic-views.tsx @@ -19,7 +19,7 @@ export default function BasicViews() { "react-dom": "^18.0.0", "react-router": "latest", "react-router-dom": "^6.8.1", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", }} startRoute="/products" files={{ diff --git a/documentation/docs/ui-integrations/chakra-ui/introduction/previews/example.tsx b/documentation/docs/ui-integrations/chakra-ui/introduction/previews/example.tsx index 0a38635de2e3..329052545136 100644 --- a/documentation/docs/ui-integrations/chakra-ui/introduction/previews/example.tsx +++ b/documentation/docs/ui-integrations/chakra-ui/introduction/previews/example.tsx @@ -19,7 +19,7 @@ export default function Example() { "react-dom": "^18.0.0", "react-router": "latest", "react-router-dom": "^6.8.1", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", }} startRoute="/products" files={{ diff --git a/documentation/docs/ui-integrations/chakra-ui/introduction/previews/layout-react-router-dom.tsx b/documentation/docs/ui-integrations/chakra-ui/introduction/previews/layout-react-router-dom.tsx index 6550856719f1..7e952ed611b6 100644 --- a/documentation/docs/ui-integrations/chakra-ui/introduction/previews/layout-react-router-dom.tsx +++ b/documentation/docs/ui-integrations/chakra-ui/introduction/previews/layout-react-router-dom.tsx @@ -21,7 +21,7 @@ export default function LayoutReactRouterDom() { "react-dom": "^18.0.0", "react-router": "latest", "react-router-dom": "^6.8.1", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", }} startRoute="/products" files={{ diff --git a/documentation/docs/ui-integrations/chakra-ui/introduction/previews/theming.tsx b/documentation/docs/ui-integrations/chakra-ui/introduction/previews/theming.tsx index 191e30a8fb50..a6eea36f43d7 100644 --- a/documentation/docs/ui-integrations/chakra-ui/introduction/previews/theming.tsx +++ b/documentation/docs/ui-integrations/chakra-ui/introduction/previews/theming.tsx @@ -21,7 +21,7 @@ export default function Usage() { "react-dom": "^18.0.0", "react-router": "latest", "react-router-dom": "^6.8.1", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", }} startRoute="/products" files={{ diff --git a/documentation/docs/ui-integrations/material-ui/introduction/previews/auth-page.tsx b/documentation/docs/ui-integrations/material-ui/introduction/previews/auth-page.tsx index 8ac9d1da5e63..34b2eb7502c0 100644 --- a/documentation/docs/ui-integrations/material-ui/introduction/previews/auth-page.tsx +++ b/documentation/docs/ui-integrations/material-ui/introduction/previews/auth-page.tsx @@ -21,7 +21,7 @@ export default function AuthPage() { "@mui/x-data-grid": "^6.6.0", "react-router-dom": "latest", "react-router": "latest", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", }} startRoute="/login" files={{ diff --git a/documentation/docs/ui-integrations/material-ui/introduction/previews/basic-views.tsx b/documentation/docs/ui-integrations/material-ui/introduction/previews/basic-views.tsx index 46ffec8f3799..82bbc5867c10 100644 --- a/documentation/docs/ui-integrations/material-ui/introduction/previews/basic-views.tsx +++ b/documentation/docs/ui-integrations/material-ui/introduction/previews/basic-views.tsx @@ -20,7 +20,7 @@ export default function BasicViews() { "@mui/x-data-grid": "^6.6.0", "react-router-dom": "latest", "react-router": "latest", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", }} startRoute="/products" files={{ diff --git a/documentation/docs/ui-integrations/material-ui/introduction/previews/example.tsx b/documentation/docs/ui-integrations/material-ui/introduction/previews/example.tsx index 38908c5e65d4..3d39741e9d42 100644 --- a/documentation/docs/ui-integrations/material-ui/introduction/previews/example.tsx +++ b/documentation/docs/ui-integrations/material-ui/introduction/previews/example.tsx @@ -20,7 +20,7 @@ export default function Example() { "@mui/x-data-grid": "^6.6.0", "react-router-dom": "latest", "react-router": "latest", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", }} startRoute="/products" files={{ diff --git a/documentation/docs/ui-integrations/material-ui/introduction/previews/layout-react-router-dom.tsx b/documentation/docs/ui-integrations/material-ui/introduction/previews/layout-react-router-dom.tsx index 6a09a3850216..e0451e67ece1 100644 --- a/documentation/docs/ui-integrations/material-ui/introduction/previews/layout-react-router-dom.tsx +++ b/documentation/docs/ui-integrations/material-ui/introduction/previews/layout-react-router-dom.tsx @@ -22,7 +22,7 @@ export default function LayoutReactRouterDom() { "@mui/x-data-grid": "^6.6.0", "react-router-dom": "latest", "react-router": "latest", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", }} startRoute="/products" files={{ diff --git a/documentation/docs/ui-integrations/material-ui/introduction/previews/theming.tsx b/documentation/docs/ui-integrations/material-ui/introduction/previews/theming.tsx index d4b5eca54c2e..01c5d506cffc 100644 --- a/documentation/docs/ui-integrations/material-ui/introduction/previews/theming.tsx +++ b/documentation/docs/ui-integrations/material-ui/introduction/previews/theming.tsx @@ -22,7 +22,7 @@ export default function Usage() { "@mui/x-data-grid": "^6.6.0", "react-router-dom": "latest", "react-router": "latest", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", }} startRoute="/products" files={{ diff --git a/documentation/docs/ui-integrations/material-ui/introduction/previews/usage-next-js.tsx b/documentation/docs/ui-integrations/material-ui/introduction/previews/usage-next-js.tsx index d5ea114345d6..7219025d7733 100644 --- a/documentation/docs/ui-integrations/material-ui/introduction/previews/usage-next-js.tsx +++ b/documentation/docs/ui-integrations/material-ui/introduction/previews/usage-next-js.tsx @@ -18,7 +18,7 @@ export default function UsageNextjs() { "@mui/material": "^5.14.2", "@mui/system": "latest", "@mui/x-data-grid": "^6.6.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "@refinedev/nextjs-router": "latest", }} // template="nextjs" diff --git a/documentation/docs/ui-integrations/material-ui/introduction/previews/usage-react-router-dom.tsx b/documentation/docs/ui-integrations/material-ui/introduction/previews/usage-react-router-dom.tsx index 71bcc17123ce..13432e023ff8 100644 --- a/documentation/docs/ui-integrations/material-ui/introduction/previews/usage-react-router-dom.tsx +++ b/documentation/docs/ui-integrations/material-ui/introduction/previews/usage-react-router-dom.tsx @@ -18,7 +18,7 @@ export default function UsageReactRouterDom() { "@mui/material": "^5.14.2", "@mui/system": "latest", "@mui/x-data-grid": "^6.6.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "latest", "@refinedev/react-router-v6": "latest", "react-router": "latest", diff --git a/documentation/docs/ui-integrations/material-ui/introduction/previews/usage-remix.tsx b/documentation/docs/ui-integrations/material-ui/introduction/previews/usage-remix.tsx index 6dc9fcb4885a..a312d15f60f0 100644 --- a/documentation/docs/ui-integrations/material-ui/introduction/previews/usage-remix.tsx +++ b/documentation/docs/ui-integrations/material-ui/introduction/previews/usage-remix.tsx @@ -18,7 +18,7 @@ export default function UsageRemix() { "@mui/material": "^5.14.2", "@mui/system": "latest", "@mui/x-data-grid": "^6.6.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "@refinedev/remix-router": "latest", }} startRoute="/products" diff --git a/examples/base-material-ui/package.json b/examples/base-material-ui/package.json index 5ead5a955fc0..778e283d393e 100644 --- a/examples/base-material-ui/package.json +++ b/examples/base-material-ui/package.json @@ -36,7 +36,7 @@ "@uiw/react-md-editor": "^3.19.5", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/blog-material-ui-datagrid/package.json b/examples/blog-material-ui-datagrid/package.json index 27c211a4558d..acea22a81d68 100644 --- a/examples/blog-material-ui-datagrid/package.json +++ b/examples/blog-material-ui-datagrid/package.json @@ -38,7 +38,7 @@ "@refinedev/simple-rest": "^5.0.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1", "styled-components": "^6.1.8" }, diff --git a/examples/blog-material-ui/package.json b/examples/blog-material-ui/package.json index dc0f035cc169..20a244959009 100644 --- a/examples/blog-material-ui/package.json +++ b/examples/blog-material-ui/package.json @@ -39,7 +39,7 @@ "axios": "^1.6.2", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1", "react-scripts": "^5.0.0", "web-vitals": "^1.1.1" diff --git a/examples/blog-ra-chakra-tutorial/package.json b/examples/blog-ra-chakra-tutorial/package.json index 6913aebec1a6..a5bee7a3c1fc 100644 --- a/examples/blog-ra-chakra-tutorial/package.json +++ b/examples/blog-ra-chakra-tutorial/package.json @@ -23,7 +23,7 @@ "axios": "^1.6.2", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/blog-react-aria/package.json b/examples/blog-react-aria/package.json index 3d1d73edf241..1a5b89248529 100644 --- a/examples/blog-react-aria/package.json +++ b/examples/blog-react-aria/package.json @@ -35,7 +35,7 @@ "react": "^18.0.0", "react-aria": "^0.1.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1", "react-scripts": "^5.0.0", "react-stately": "^3.19.0", diff --git a/examples/blog-react-hook-dynamic-form/package.json b/examples/blog-react-hook-dynamic-form/package.json index 6d41a9066b8d..f47c93961e6c 100644 --- a/examples/blog-react-hook-dynamic-form/package.json +++ b/examples/blog-react-hook-dynamic-form/package.json @@ -38,7 +38,7 @@ "cross-env": "^7.0.3", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1", "react-scripts": "^5.0.0", "web-vitals": "^1.1.1" diff --git a/examples/blog-refine-mui/package.json b/examples/blog-refine-mui/package.json index 0ebab1b41957..4ec02fd045f6 100644 --- a/examples/blog-refine-mui/package.json +++ b/examples/blog-refine-mui/package.json @@ -43,7 +43,7 @@ "i18next-xhr-backend": "^3.2.2", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-i18next": "^11.8.11", "react-router-dom": "^6.8.1", "recharts": "^2.1.9" diff --git a/examples/blog-refine-nextui/package.json b/examples/blog-refine-nextui/package.json index e6927e0d24b5..067b3e32a3dd 100644 --- a/examples/blog-refine-nextui/package.json +++ b/examples/blog-refine-nextui/package.json @@ -39,7 +39,7 @@ "i18next-xhr-backend": "^3.2.2", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-i18next": "^11.8.11", "react-router-dom": "^6.8.1", "recharts": "^2.1.9" diff --git a/examples/blog-refine-primereact/package.json b/examples/blog-refine-primereact/package.json index 51455b3aaf06..4310e338b392 100644 --- a/examples/blog-refine-primereact/package.json +++ b/examples/blog-refine-primereact/package.json @@ -35,7 +35,7 @@ "primereact": "^9.6.0", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/blog-refine-react-hook-form/package.json b/examples/blog-refine-react-hook-form/package.json index 2e97f90eb2b8..6f8dc1370280 100644 --- a/examples/blog-refine-react-hook-form/package.json +++ b/examples/blog-refine-react-hook-form/package.json @@ -37,7 +37,7 @@ "@refinedev/simple-rest": "^5.0.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1", "web-vitals": "^1.1.1", "yup": "^0.32.11" diff --git a/examples/blog-win95/package.json b/examples/blog-win95/package.json index 7e357aaffc3b..89c579015cb1 100644 --- a/examples/blog-win95/package.json +++ b/examples/blog-win95/package.json @@ -33,7 +33,7 @@ "@tanstack/react-table": "^8.2.6", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1", "react95": "^4.0.0", "styled-components": "^6.1.8" diff --git a/examples/customization-theme-material-ui/package.json b/examples/customization-theme-material-ui/package.json index 7c1784843e1a..3c853561be2f 100644 --- a/examples/customization-theme-material-ui/package.json +++ b/examples/customization-theme-material-ui/package.json @@ -35,7 +35,7 @@ "@refinedev/simple-rest": "^5.0.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/field-material-ui-use-autocomplete/package.json b/examples/field-material-ui-use-autocomplete/package.json index 0c2913757a79..c87d18771f72 100644 --- a/examples/field-material-ui-use-autocomplete/package.json +++ b/examples/field-material-ui-use-autocomplete/package.json @@ -35,7 +35,7 @@ "@refinedev/simple-rest": "^5.0.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/finefoods-material-ui/package.json b/examples/finefoods-material-ui/package.json index d3788a5762dc..ba280135a3a9 100644 --- a/examples/finefoods-material-ui/package.json +++ b/examples/finefoods-material-ui/package.json @@ -48,7 +48,7 @@ "lodash": "^4.17.21", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-i18next": "^11.8.11", "react-input-mask": "^2.0.4", "react-router-dom": "^6.8.1", diff --git a/examples/form-material-ui-mutation-mode/package.json b/examples/form-material-ui-mutation-mode/package.json index 03c1921b8182..7cab4b31edba 100644 --- a/examples/form-material-ui-mutation-mode/package.json +++ b/examples/form-material-ui-mutation-mode/package.json @@ -35,7 +35,7 @@ "@refinedev/simple-rest": "^5.0.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/form-material-ui-use-drawer-form/package.json b/examples/form-material-ui-use-drawer-form/package.json index 4b8a11b3f2d2..92b68ba6d69f 100644 --- a/examples/form-material-ui-use-drawer-form/package.json +++ b/examples/form-material-ui-use-drawer-form/package.json @@ -36,7 +36,7 @@ "@refinedev/simple-rest": "^5.0.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/form-material-ui-use-form/package.json b/examples/form-material-ui-use-form/package.json index 2bcdfed1c853..cd73b33f2a44 100644 --- a/examples/form-material-ui-use-form/package.json +++ b/examples/form-material-ui-use-form/package.json @@ -35,7 +35,7 @@ "@refinedev/simple-rest": "^5.0.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/form-material-ui-use-modal-form/package.json b/examples/form-material-ui-use-modal-form/package.json index 440732166bf6..629cf1ef51c1 100644 --- a/examples/form-material-ui-use-modal-form/package.json +++ b/examples/form-material-ui-use-modal-form/package.json @@ -35,7 +35,7 @@ "@refinedev/simple-rest": "^5.0.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/form-material-ui-use-steps-form/package.json b/examples/form-material-ui-use-steps-form/package.json index d686a8be51dc..291c0b01517e 100644 --- a/examples/form-material-ui-use-steps-form/package.json +++ b/examples/form-material-ui-use-steps-form/package.json @@ -35,7 +35,7 @@ "@refinedev/simple-rest": "^5.0.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/form-react-hook-form-use-steps-form/package.json b/examples/form-react-hook-form-use-steps-form/package.json index 86fa790ffbd0..9cb5078f7d60 100644 --- a/examples/form-react-hook-form-use-steps-form/package.json +++ b/examples/form-react-hook-form-use-steps-form/package.json @@ -30,7 +30,7 @@ "axios": "^1.6.2", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/inferencer-chakra-ui/package.json b/examples/inferencer-chakra-ui/package.json index 11d1738061ed..27c9f77af3c7 100644 --- a/examples/inferencer-chakra-ui/package.json +++ b/examples/inferencer-chakra-ui/package.json @@ -38,7 +38,7 @@ "i18next-xhr-backend": "^3.2.2", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-i18next": "^11.8.11", "react-router-dom": "^6.8.1" }, diff --git a/examples/inferencer-material-ui/package.json b/examples/inferencer-material-ui/package.json index 3c40a1ba6d53..82832f92c87d 100644 --- a/examples/inferencer-material-ui/package.json +++ b/examples/inferencer-material-ui/package.json @@ -41,7 +41,7 @@ "i18next-xhr-backend": "^3.2.2", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-i18next": "^11.8.11", "react-router-dom": "^6.8.1" }, diff --git a/examples/mern-dashboard-client/package.json b/examples/mern-dashboard-client/package.json index 816c2bb3d212..6f7f868e7558 100644 --- a/examples/mern-dashboard-client/package.json +++ b/examples/mern-dashboard-client/package.json @@ -42,7 +42,7 @@ "react": "^18.0.0", "react-apexcharts": "^1.4.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1", "react-scripts": "^5.0.0", "web-vitals": "^1.1.1" diff --git a/examples/server-side-form-validation-material-ui/package.json b/examples/server-side-form-validation-material-ui/package.json index 155565c5300f..5509e0985549 100644 --- a/examples/server-side-form-validation-material-ui/package.json +++ b/examples/server-side-form-validation-material-ui/package.json @@ -36,7 +36,7 @@ "@uiw/react-md-editor": "^3.19.5", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/store/package.json b/examples/store/package.json index 62591de44f7a..7f9a8fdbda2a 100644 --- a/examples/store/package.json +++ b/examples/store/package.json @@ -39,7 +39,7 @@ "react": "^18.0.0", "react-dom": "^18.0.0", "react-fast-marquee": "^1.3.1", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-merge-refs": "^1.1.0", "react-use-measure": "^2.1.1", "tabbable": "^5.2.1", diff --git a/examples/table-material-ui-advanced/package.json b/examples/table-material-ui-advanced/package.json index 9c155c869c8e..d5362c70b51f 100644 --- a/examples/table-material-ui-advanced/package.json +++ b/examples/table-material-ui-advanced/package.json @@ -38,7 +38,7 @@ "@uiw/react-md-editor": "^3.19.5", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/table-material-ui-table-filter/package.json b/examples/table-material-ui-table-filter/package.json index fd3a228a68f5..6085da3fe346 100644 --- a/examples/table-material-ui-table-filter/package.json +++ b/examples/table-material-ui-table-filter/package.json @@ -36,7 +36,7 @@ "@refinedev/simple-rest": "^5.0.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/table-react-table-advanced/package.json b/examples/table-react-table-advanced/package.json index 434c36e3b002..ccf270081cdc 100644 --- a/examples/table-react-table-advanced/package.json +++ b/examples/table-react-table-advanced/package.json @@ -33,7 +33,7 @@ "@uiw/react-md-editor": "^3.19.5", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/theme-material-ui-demo/package.json b/examples/theme-material-ui-demo/package.json index 885edc88d98a..66e991282c46 100644 --- a/examples/theme-material-ui-demo/package.json +++ b/examples/theme-material-ui-demo/package.json @@ -35,7 +35,7 @@ "@refinedev/simple-rest": "^5.0.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/tutorial-material-ui/package.json b/examples/tutorial-material-ui/package.json index ace5adad7eae..8da11a1aa7b3 100644 --- a/examples/tutorial-material-ui/package.json +++ b/examples/tutorial-material-ui/package.json @@ -37,7 +37,7 @@ "@refinedev/simple-rest": "^5.0.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1", "web-vitals": "^1.1.1" }, diff --git a/examples/upload-material-ui-base64/package.json b/examples/upload-material-ui-base64/package.json index feb66a7a343e..e39358abdd19 100644 --- a/examples/upload-material-ui-base64/package.json +++ b/examples/upload-material-ui-base64/package.json @@ -35,7 +35,7 @@ "@refinedev/simple-rest": "^5.0.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/upload-material-ui-multipart/package.json b/examples/upload-material-ui-multipart/package.json index a18d9c5aed0b..d94e2367a35e 100644 --- a/examples/upload-material-ui-multipart/package.json +++ b/examples/upload-material-ui-multipart/package.json @@ -35,7 +35,7 @@ "@refinedev/simple-rest": "^5.0.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/examples/with-material-ui-vite/package.json b/examples/with-material-ui-vite/package.json index 7e034f40c3c2..4649fb0580ad 100644 --- a/examples/with-material-ui-vite/package.json +++ b/examples/with-material-ui-vite/package.json @@ -38,7 +38,7 @@ "@refinedev/simple-rest": "^5.0.8", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-router-dom": "^6.8.1" }, "devDependencies": { diff --git a/packages/chakra-ui/package.json b/packages/chakra-ui/package.json index 111681123627..359c018a53c7 100644 --- a/packages/chakra-ui/package.json +++ b/packages/chakra-ui/package.json @@ -40,7 +40,7 @@ "@tabler/icons-react": "^3.1.0", "dayjs": "^1.10.7", "framer-motion": "^7.5.3", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-markdown": "^6.0.1", "remark-gfm": "^1.0.0", "tslib": "^2.6.2" @@ -75,7 +75,7 @@ "dayjs": "^1.10.7", "react": "^17.0.0 || ^18.0.0", "react-dom": "^17.0.0 || ^18.0.0", - "react-hook-form": "^7.30.0" + "react-hook-form": "^7.43.5" }, "publishConfig": { "access": "public" diff --git a/packages/codemod/src/transformations/v4/separate-imports-react-hook-form.ts b/packages/codemod/src/transformations/v4/separate-imports-react-hook-form.ts index e168b3376631..77b5ca03032a 100644 --- a/packages/codemod/src/transformations/v4/separate-imports-react-hook-form.ts +++ b/packages/codemod/src/transformations/v4/separate-imports-react-hook-form.ts @@ -8,7 +8,7 @@ import { const REFINE_LIB_PATH = "@pankod/refine-react-hook-form"; const REACT_HOOK_FORM_PATH = "react-hook-form"; -const REACT_HOOK_FORM_VERSION = "^7.30.0"; +const REACT_HOOK_FORM_VERSION = "^7.43.5"; export const separateImportsReactHookForm = ( j: JSCodeshift, diff --git a/packages/inferencer/package.json b/packages/inferencer/package.json index 18ac55eefa79..e706191fb335 100644 --- a/packages/inferencer/package.json +++ b/packages/inferencer/package.json @@ -181,7 +181,7 @@ "dayjs": "^1.10.7", "react": "^17.0.0 || ^18.0.0", "react-dom": "^17.0.0 || ^18.0.0", - "react-hook-form": "^7.30.0" + "react-hook-form": "^7.43.5" }, "peerDependenciesMeta": { "@chakra-ui/react": { diff --git a/packages/live-previews/package.json b/packages/live-previews/package.json index ed747e0e55aa..f3dc6227c5ba 100644 --- a/packages/live-previews/package.json +++ b/packages/live-previews/package.json @@ -65,7 +65,7 @@ "qs": "^6.10.1", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-i18next": "^11.8.11", "react-router-dom": "^6.8.1", "uuid": "^9.0.1" diff --git a/packages/mui/package.json b/packages/mui/package.json index 27545e176c18..079d421b52e6 100644 --- a/packages/mui/package.json +++ b/packages/mui/package.json @@ -44,7 +44,7 @@ "lodash": "^4.17.21", "lodash-es": "^4.17.21", "notistack": "^2.0.4", - "react-hook-form": "^7.30.0", + "react-hook-form": "^7.43.5", "react-markdown": "^6.0.1", "remark-gfm": "^1.0.0", "tslib": "^2.6.2", @@ -86,7 +86,7 @@ "dayjs": "^1.10.7", "react": "^17.0.0 || ^18.0.0", "react-dom": "^17.0.0 || ^18.0.0", - "react-hook-form": "^7.30.0" + "react-hook-form": "^7.43.5" }, "publishConfig": { "access": "public" diff --git a/packages/react-hook-form/package.json b/packages/react-hook-form/package.json index 268a8432f380..0896d26c6a12 100644 --- a/packages/react-hook-form/package.json +++ b/packages/react-hook-form/package.json @@ -42,7 +42,7 @@ "dependencies": { "lodash": "^4.17.21", "lodash-es": "^4.17.21", - "react-hook-form": "^7.30.0" + "react-hook-form": "^7.43.5" }, "devDependencies": { "@esbuild-plugins/node-resolve": "^0.1.4", @@ -68,7 +68,7 @@ "@types/react-dom": "^17.0.0 || ^18.0.0", "react": "^17.0.0 || ^18.0.0", "react-dom": "^17.0.0 || ^18.0.0", - "react-hook-form": "^7.30.0" + "react-hook-form": "^7.43.5" }, "engines": { "node": ">=10" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 27b507393e57..4d74c51a7728 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1520,7 +1520,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -1922,7 +1922,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -2010,7 +2010,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -2159,7 +2159,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -2317,7 +2317,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -3143,7 +3143,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-i18next: specifier: ^11.8.11 @@ -3243,7 +3243,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-i18next: specifier: ^11.8.11 @@ -3340,7 +3340,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -3428,7 +3428,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -3847,7 +3847,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -4648,7 +4648,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -5625,7 +5625,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -5919,7 +5919,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-i18next: specifier: ^11.8.11 @@ -6959,7 +6959,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -7029,7 +7029,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -7096,7 +7096,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -7163,7 +7163,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -7230,7 +7230,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -7380,7 +7380,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -7937,7 +7937,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-i18next: specifier: ^11.8.11 @@ -8301,7 +8301,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-i18next: specifier: ^11.8.11 @@ -8688,7 +8688,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -9386,7 +9386,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -9550,7 +9550,7 @@ importers: specifier: ^1.3.1 version: 1.6.4(react-dom@18.3.0(react@18.3.0))(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-merge-refs: specifier: ^1.1.0 @@ -10273,7 +10273,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -10471,7 +10471,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -10724,7 +10724,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -11391,7 +11391,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -11771,7 +11771,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -12222,7 +12222,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -12289,7 +12289,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -12698,7 +12698,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-router-dom: specifier: ^6.8.1 @@ -13471,7 +13471,7 @@ importers: devDependencies: '@esbuild-plugins/node-resolve': specifier: ^0.1.4 - version: 0.1.4(esbuild@0.20.2) + version: 0.1.4(esbuild@0.17.19) '@refinedev/core': specifier: ^4.52.0 version: link:../core @@ -13489,7 +13489,7 @@ importers: version: 13.5.4 ts-jest: specifier: ^29.1.2 - version: 29.1.2(@babel/core@7.24.4)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.4))(esbuild@0.20.2)(jest@29.7.0(@types/node@20.5.1)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.5.1)(typescript@5.4.5)))(typescript@5.4.5) + version: 29.1.2(@babel/core@7.24.4)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.4))(esbuild@0.17.19)(jest@29.7.0(@types/node@20.5.1)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.5.1)(typescript@5.4.5)))(typescript@5.4.5) tslib: specifier: ^2.6.2 version: 2.6.2 @@ -13517,7 +13517,7 @@ importers: devDependencies: '@esbuild-plugins/node-resolve': specifier: ^0.1.4 - version: 0.1.4(esbuild@0.17.19) + version: 0.1.4(esbuild@0.20.2) '@refinedev/core': specifier: 4.53.0 version: link:../core @@ -13535,7 +13535,7 @@ importers: version: 13.5.4 ts-jest: specifier: ^29.1.2 - version: 29.1.2(@babel/core@7.24.4)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.4))(esbuild@0.17.19)(jest@29.7.0(@types/node@20.5.1)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.5.1)(typescript@5.4.5)))(typescript@5.4.5) + version: 29.1.2(@babel/core@7.24.4)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.4))(esbuild@0.20.2)(jest@29.7.0(@types/node@20.5.1)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.5.1)(typescript@5.4.5)))(typescript@5.4.5) tslib: specifier: ^2.6.2 version: 2.6.2 @@ -13731,7 +13731,7 @@ importers: specifier: ^17.0.0 || ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-markdown: specifier: ^6.0.1 @@ -14880,7 +14880,7 @@ importers: specifier: ^17.0.0 || ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-markdown: specifier: ^6.0.1 @@ -15197,7 +15197,7 @@ importers: specifier: ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-i18next: specifier: ^11.8.11 @@ -15455,7 +15455,7 @@ importers: specifier: ^17.0.0 || ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) react-markdown: specifier: ^6.0.1 @@ -15729,7 +15729,7 @@ importers: specifier: ^17.0.0 || ^18.0.0 version: 18.3.0(react@18.3.0) react-hook-form: - specifier: ^7.30.0 + specifier: ^7.43.5 version: 7.51.3(react@18.3.0) devDependencies: '@esbuild-plugins/node-resolve': @@ -41557,8 +41557,8 @@ snapshots: '@medusajs/modules-sdk': 1.12.10(@types/node@18.19.31) '@medusajs/types': 1.11.15 '@medusajs/utils': 1.11.8(@types/node@18.19.31)(pg@8.11.5) - '@mikro-orm/core': 5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7) - '@mikro-orm/postgresql': 5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@types/node@18.19.31)(pg@8.11.5)) + '@mikro-orm/core': 5.9.7(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5))(@mikro-orm/postgresql@5.9.7) + '@mikro-orm/postgresql': 5.9.7(@mikro-orm/core@5.9.7)(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5)) awilix: 8.0.1 transitivePeerDependencies: - '@mikro-orm/better-sqlite' @@ -41807,9 +41807,9 @@ snapshots: '@medusajs/utils@1.11.8(@types/node@18.19.31)(pg@8.11.5)': dependencies: '@medusajs/types': 1.11.15 - '@mikro-orm/core': 5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7) - '@mikro-orm/migrations': 5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@types/node@18.19.31)(pg@8.11.5) - '@mikro-orm/postgresql': 5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@types/node@18.19.31)(pg@8.11.5)) + '@mikro-orm/core': 5.9.7(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5))(@mikro-orm/postgresql@5.9.7) + '@mikro-orm/migrations': 5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5) + '@mikro-orm/postgresql': 5.9.7(@mikro-orm/core@5.9.7)(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5)) awilix: 8.0.1 bignumber.js: 9.1.2 knex: 2.4.2(pg@8.11.5) @@ -41861,7 +41861,7 @@ snapshots: - supports-color - tedious - '@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7)': + '@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5))(@mikro-orm/postgresql@5.9.7)': dependencies: acorn-loose: 8.3.0 acorn-walk: 8.2.0 @@ -41871,17 +41871,17 @@ snapshots: mikro-orm: 5.9.7 reflect-metadata: 0.1.13 optionalDependencies: - '@mikro-orm/migrations': 5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@types/node@18.19.31)(pg@8.11.5) - '@mikro-orm/postgresql': 5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@types/node@18.19.31)(pg@8.11.5)) + '@mikro-orm/migrations': 5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5) + '@mikro-orm/postgresql': 5.9.7(@mikro-orm/core@5.9.7)(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5)) - '@mikro-orm/knex@5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@types/node@18.19.31)(pg@8.11.5))(pg@8.11.3)': + '@mikro-orm/knex@5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5))(@mikro-orm/postgresql@5.9.7))(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5))(pg@8.11.3)': dependencies: - '@mikro-orm/core': 5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7) + '@mikro-orm/core': 5.9.7(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5))(@mikro-orm/postgresql@5.9.7) fs-extra: 11.1.1 knex: 2.5.1(pg@8.11.3) sqlstring: 2.3.3 optionalDependencies: - '@mikro-orm/migrations': 5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@types/node@18.19.31)(pg@8.11.5) + '@mikro-orm/migrations': 5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5) pg: 8.11.3 transitivePeerDependencies: - pg-native @@ -41890,21 +41890,21 @@ snapshots: '@mikro-orm/knex@5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5))(pg@8.11.5)': dependencies: - '@mikro-orm/core': 5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7) + '@mikro-orm/core': 5.9.7(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5))(@mikro-orm/postgresql@5.9.7) fs-extra: 11.1.1 knex: 2.5.1(pg@8.11.5) sqlstring: 2.3.3 optionalDependencies: - '@mikro-orm/migrations': 5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@types/node@18.19.31)(pg@8.11.5) + '@mikro-orm/migrations': 5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5) pg: 8.11.5 transitivePeerDependencies: - pg-native - supports-color - tedious - '@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@types/node@18.19.31)(pg@8.11.5)': + '@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5)': dependencies: - '@mikro-orm/core': 5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7) + '@mikro-orm/core': 5.9.7(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5))(@mikro-orm/postgresql@5.9.7) '@mikro-orm/knex': 5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5))(pg@8.11.5) fs-extra: 11.1.1 knex: 2.5.1(pg@8.11.5) @@ -41922,13 +41922,13 @@ snapshots: - supports-color - tedious - '@mikro-orm/postgresql@5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@types/node@18.19.31)(pg@8.11.5))': + '@mikro-orm/postgresql@5.9.7(@mikro-orm/core@5.9.7)(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5))': dependencies: - '@mikro-orm/core': 5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7) - '@mikro-orm/knex': 5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@types/node@18.19.31)(pg@8.11.5))(pg@8.11.3) + '@mikro-orm/core': 5.9.7(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5))(@mikro-orm/postgresql@5.9.7) + '@mikro-orm/knex': 5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5))(@mikro-orm/postgresql@5.9.7))(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5))(pg@8.11.3) pg: 8.11.3 optionalDependencies: - '@mikro-orm/migrations': 5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@types/node@18.19.31)(pg@8.11.5) + '@mikro-orm/migrations': 5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5) transitivePeerDependencies: - better-sqlite3 - mssql @@ -54948,8 +54948,8 @@ snapshots: dependencies: '@medusajs/modules-sdk': 1.12.10(@types/node@18.19.31) '@medusajs/utils': 1.11.8(@types/node@18.19.31)(pg@8.11.5) - '@mikro-orm/migrations': 5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@types/node@18.19.31)(pg@8.11.5) - '@mikro-orm/postgresql': 5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7(@mikro-orm/migrations@5.9.7)(@mikro-orm/postgresql@5.9.7))(@types/node@18.19.31)(pg@8.11.5)) + '@mikro-orm/migrations': 5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5) + '@mikro-orm/postgresql': 5.9.7(@mikro-orm/core@5.9.7)(@mikro-orm/migrations@5.9.7(@mikro-orm/core@5.9.7)(@types/node@18.19.31)(pg@8.11.5)) medusa-core-utils: 1.2.1 randomatic: 3.1.1 optionalDependencies: From c3a75139f82de022b54855e87e200ab38c803af5 Mon Sep 17 00:00:00 2001 From: Alican Erdurmaz Date: Mon, 29 Jul 2024 16:24:05 +0300 Subject: [PATCH 09/30] fix(cli): update command doesn't respect semver specifier (#6135) --- .changeset/flat-boats-knock.md | 5 + packages/cli/jest.config.js | 3 + packages/cli/package.json | 2 + .../src/commands/check-updates/index.test.tsx | 173 +++++++++++++++ .../cli/src/commands/check-updates/index.tsx | 101 ++++++++- .../install-required-packages/index.ts | 2 +- packages/cli/src/commands/update/index.ts | 202 +++++++++++++----- .../update/interactive/index.test.tsx | 2 +- .../src/commands/update/interactive/index.ts | 30 ++- .../components/update-warning-table/table.ts | 16 ++ packages/cli/src/definitions/package.ts | 44 +++- packages/cli/src/utils/package/index.ts | 89 ++++++-- packages/cli/src/utils/refine/index.test.tsx | 8 +- packages/codemod/package.json | 3 +- pnpm-lock.yaml | 42 +++- 15 files changed, 615 insertions(+), 107 deletions(-) create mode 100644 .changeset/flat-boats-knock.md diff --git a/.changeset/flat-boats-knock.md b/.changeset/flat-boats-knock.md new file mode 100644 index 000000000000..0e853968d6fe --- /dev/null +++ b/.changeset/flat-boats-knock.md @@ -0,0 +1,5 @@ +--- +"@refinedev/cli": patch +--- + +fix: `yarn refine update` removes semver range specifiers(`^`, `~`) from `package.json`. #6134 diff --git a/packages/cli/jest.config.js b/packages/cli/jest.config.js index ed5afe0a146a..b62df0a5caf3 100644 --- a/packages/cli/jest.config.js +++ b/packages/cli/jest.config.js @@ -1,6 +1,7 @@ const { pathsToModuleNameMapper } = require("ts-jest"); const { compilerOptions } = require("./tsconfig"); +/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ module.exports = { preset: "ts-jest", rootDir: "./", @@ -10,4 +11,6 @@ module.exports = { moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths), modulePaths: ["", "src"], moduleDirectories: ["node_modules", "src"], + resetMocks: true, + clearMocks: true, }; diff --git a/packages/cli/package.json b/packages/cli/package.json index 8a2dfff196df..c52084f82946 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -33,6 +33,7 @@ "types": "node ../shared/generate-declarations.js" }, "dependencies": { + "@npmcli/package-json": "^5.2.0", "@refinedev/devtools-server": "1.1.34", "boxen": "^5.1.2", "cardinal": "^2.1.1", @@ -84,6 +85,7 @@ "@types/marked": "^5.0.1", "@types/marked-terminal": "^3.1.5", "@types/node-fetch": "^2.6.11", + "@types/npmcli__package-json": "^4.0.4", "@types/pluralize": "^0.0.29", "@types/prettier": "^2.7.3", "@types/semver": "^7.5.8", diff --git a/packages/cli/src/commands/check-updates/index.test.tsx b/packages/cli/src/commands/check-updates/index.test.tsx index 9323cb82ac74..64e485523707 100644 --- a/packages/cli/src/commands/check-updates/index.test.tsx +++ b/packages/cli/src/commands/check-updates/index.test.tsx @@ -3,6 +3,8 @@ import type { RefinePackageInstalledVersionData, } from "@definitions/package"; import * as checkUpdates from "./index"; +import * as packageUtils from "@utils/package"; + const { getOutdatedRefinePackages } = checkUpdates; test("Get outdated refine packages", async () => { @@ -16,31 +18,43 @@ test("Get outdated refine packages", async () => { current: "1.0.0", wanted: "1.0.1", latest: "2.0.0", + dependent: "", + location: "", }, "@refinedev/cli": { current: "1.1.1", wanted: "1.1.1", latest: "1.1.0", + dependent: "", + location: "", }, "@pankod/canvas2video": { current: "1.1.1", wanted: "1.1.1", latest: "1.1.1", + dependent: "", + location: "", }, "@owner/package-name": { current: "1.1.1", wanted: "1.1.1", latest: "1.1.0", + dependent: "", + location: "", }, "@owner/package-name1": { current: "N/A", wanted: "undefined", latest: "NaN", + dependent: "", + location: "", }, "@owner/refine-react": { current: "1.0.0", wanted: "1.0.1", latest: "2.0.0", + dependent: "", + location: "", }, }, output: [ @@ -50,6 +64,8 @@ test("Get outdated refine packages", async () => { wanted: "1.0.1", latest: "2.0.0", changelog: "https://c.refine.dev/core", + dependent: "", + location: "", }, ], }, @@ -64,3 +80,160 @@ test("Get outdated refine packages", async () => { expect(result).toEqual(testCase.output); } }); + +describe("getWantedWithPreferredWildcard", () => { + it("package not found in package.json", () => { + jest.spyOn(packageUtils, "getDependenciesWithVersion").mockReturnValue({}); + + const result = checkUpdates.getWantedWithPreferredWildcard( + "@refinedev/core", + "1.0.1", + ); + expect(result).toEqual("^1.0.1"); + }); + + it("with carret", () => { + jest.spyOn(packageUtils, "getDependenciesWithVersion").mockReturnValue({ + "@refinedev/core": "^1.0.0", + }); + + const result = checkUpdates.getWantedWithPreferredWildcard( + "@refinedev/core", + "1.0.1", + ); + expect(result).toEqual("^1.0.1"); + }); + + it("with tilda", () => { + jest.spyOn(packageUtils, "getDependenciesWithVersion").mockReturnValue({ + "@refinedev/core": "~1.0.0", + }); + + const result = checkUpdates.getWantedWithPreferredWildcard( + "@refinedev/core", + "1.0.1", + ); + expect(result).toEqual("~1.0.1"); + }); + + it("without caret and tilda", () => { + jest.spyOn(packageUtils, "getDependenciesWithVersion").mockReturnValue({ + "@refinedev/core": "1.0.0", + }); + + const result = checkUpdates.getWantedWithPreferredWildcard( + "@refinedev/core", + "1.0.1", + ); + expect(result).toEqual("1.0.1"); + }); + + it("with `.x.x`", () => { + jest.spyOn(packageUtils, "getDependenciesWithVersion").mockReturnValue({ + "@refinedev/core": "1.x.x", + }); + + const result = checkUpdates.getWantedWithPreferredWildcard( + "@refinedev/core", + "1.10.1", + ); + expect(result).toEqual("1.x.x"); + }); + + it("with `.x`", () => { + jest.spyOn(packageUtils, "getDependenciesWithVersion").mockReturnValue({ + "@refinedev/core": "1.1.x", + }); + + const result = checkUpdates.getWantedWithPreferredWildcard( + "@refinedev/core", + "1.1.10", + ); + expect(result).toEqual("1.1.x"); + }); + + it("with `latest`", () => { + jest.spyOn(packageUtils, "getDependenciesWithVersion").mockReturnValue({ + "@refinedev/core": "latest", + }); + + const result = checkUpdates.getWantedWithPreferredWildcard( + "@refinedev/core", + "3.1.1", + ); + expect(result).toEqual("latest"); + }); + + it("with range", () => { + jest.spyOn(packageUtils, "getDependenciesWithVersion").mockReturnValue({ + "@refinedev/core": ">=1.0.0 <=1.1.9", + }); + + const result = checkUpdates.getWantedWithPreferredWildcard( + "@refinedev/core", + "1.0.0-rc.10", + ); + expect(result).toEqual(">=1.0.0 <=1.1.9"); + }); + + it("multiple sets", () => { + jest.spyOn(packageUtils, "getDependenciesWithVersion").mockReturnValue({ + "@refinedev/core": "^2 <2.2 || > 2.3", + }); + + const result = checkUpdates.getWantedWithPreferredWildcard( + "@refinedev/core", + "2.3.1", + ); + expect(result).toEqual("^2 <2.2 || > 2.3"); + }); + + it("with `*`", () => { + jest.spyOn(packageUtils, "getDependenciesWithVersion").mockReturnValue({ + "@refinedev/core": "*", + }); + + const result = checkUpdates.getWantedWithPreferredWildcard( + "@refinedev/core", + "3.1.1", + ); + expect(result).toEqual("*"); + }); +}); + +describe("getLatestMinorVersionOfPackage", () => { + it.each([ + { + versionList: [ + "1.0.0", + "1.0.1", + "1.0.2", + "1.1.0", + "1.1.1", + "1.1.2", + "2.0.0", + ], + currentVersion: "1.1.0", + expected: "1.1.2", + }, + { + versionList: ["1.0.0", "1.0.1"], + currentVersion: "1.0.1", + expected: "1.0.1", + }, + { + versionList: [], + currentVersion: "1.0.1", + expected: "1.0.1", + }, + ])("should return %p", async ({ versionList, currentVersion, expected }) => { + jest + .spyOn(packageUtils, "getAllVersionsOfPackage") + .mockResolvedValueOnce(versionList); + const result = await checkUpdates.getLatestMinorVersionOfPackage( + "@refinedev/core", + currentVersion, + ); + expect(result).toEqual(expected); + }); +}); diff --git a/packages/cli/src/commands/check-updates/index.tsx b/packages/cli/src/commands/check-updates/index.tsx index b950aae70af9..d754a031e2e7 100644 --- a/packages/cli/src/commands/check-updates/index.tsx +++ b/packages/cli/src/commands/check-updates/index.tsx @@ -1,6 +1,10 @@ import type { Command } from "commander"; import { printUpdateWarningTable } from "@components/update-warning-table"; -import { pmCommands } from "@utils/package"; +import { + getAllVersionsOfPackage, + getDependenciesWithVersion, + pmCommands, +} from "@utils/package"; import execa from "execa"; import spinner from "@utils/spinner"; import type { @@ -8,6 +12,7 @@ import type { RefinePackageInstalledVersionData, } from "@definitions/package"; import semverDiff from "semver-diff"; +import { maxSatisfying } from "semver"; const load = (program: Command) => { return program @@ -38,25 +43,25 @@ export const isRefineUptoDate = async () => { return refinePackages; }; +/** + * Uses `npm outdated` command to get the list of outdated packages. + * @returns `[]` if no Refine package found. + * @returns `Refine` packages that have updates. + */ export const getOutdatedRefinePackages = async () => { const packages = await getOutdatedPackageList(); if (!packages) return []; const list: RefinePackageInstalledVersionData[] = []; - let changelog: string | undefined = undefined; Object.keys(packages).forEach((packageName) => { const dependency = packages[packageName]; if (packageName.includes("@refinedev")) { - changelog = packageName.replace(/@refinedev\//, "https://c.refine.dev/"); - list.push({ + ...dependency, name: packageName, - current: dependency.current, - wanted: dependency.wanted, - latest: dependency.latest, - changelog, + changelog: packageName.replace(/@refinedev\//, "https://c.refine.dev/"), }); } }); @@ -72,6 +77,9 @@ export const getOutdatedRefinePackages = async () => { return filteredList; }; +/** + * @returns `npm outdated` command response + */ export const getOutdatedPackageList = async () => { const pm = "npm"; @@ -89,4 +97,81 @@ export const getOutdatedPackageList = async () => { return JSON.parse(stdout) as NpmOutdatedResponse | null; }; +/** + * The `npm outdated` command's `wanted` field shows the desired update version (e.g., `^1.2.0` in `package.json` resolves to `1.2.1`). + * This function returns the version that matches the semver range in `package.json` (e.g., `^1.2.0` resolves to `^1.2.1`). + * + * @param packageName The name of the package. + * @param versionWanted The version that the user wants to update to. Wihtout semver range. + * @returns The version that satisfies the semver range in `package.json` with the preferred wildcard. + */ +export const getWantedWithPreferredWildcard = ( + packageName: RefinePackageInstalledVersionData["name"], + versionWanted: RefinePackageInstalledVersionData["wanted"], +): string => { + const dependencies = getDependenciesWithVersion(); + const versionInPackageJson = dependencies[packageName]; + + if (!versionInPackageJson) { + return `^${versionWanted}`; + } + + if (versionInPackageJson === "latest") { + return "latest"; + } + + if (versionInPackageJson === "*") { + return "*"; + } + + // has range + // if the version in the package.json has a range, it means the user has installed the package with a range. + // in that case, we should not change the version. package manager will install the latest version that satisfies the semver range. + if ( + [">", "<", ">=", "<=", "||"].some((char) => + versionInPackageJson.includes(char), + ) + ) { + return versionInPackageJson; + } + + // has `x` + // if the version in the package.json has `x` in it, it means the user has installed the package with a wildcard. + // in that case, we should not change the version. package manager will install the latest version that satisfies the semver range. + if (versionInPackageJson?.includes("x")) { + return `${versionInPackageJson}`; + } + + // has tilda + if (versionInPackageJson?.startsWith("~")) { + return `~${versionWanted}`; + } + + // has caret + if (versionInPackageJson?.startsWith("^")) { + return `^${versionWanted}`; + } + + return versionWanted; +}; + +/** + * + * @param packageName to get the latest minor version of the package available on npm. + * @param version current installed version of the package. This will be used to calculate the latest minor version. + * @returns The latest minor version of the package available on npm. + */ +export const getLatestMinorVersionOfPackage = async ( + packageName: RefinePackageInstalledVersionData["name"], + version: RefinePackageInstalledVersionData["wanted"], +) => { + const versionAll = await getAllVersionsOfPackage(packageName); + + /** + * The `semver` package's `maxSatisfying` function returns the highest version in the list that satisfies the range. + */ + const versionLatest = maxSatisfying(versionAll, `^${version}`); + return versionLatest ?? version; +}; + export default load; diff --git a/packages/cli/src/commands/swizzle/install-required-packages/index.ts b/packages/cli/src/commands/swizzle/install-required-packages/index.ts index 34d227a90f92..2ffecb5ae317 100644 --- a/packages/cli/src/commands/swizzle/install-required-packages/index.ts +++ b/packages/cli/src/commands/swizzle/install-required-packages/index.ts @@ -39,7 +39,7 @@ export const displayManualInstallationCommand = async ( requiredPackages: string[], ) => { const pm = await getPreferedPM(); - const pmCommand = pmCommands[pm.name].install.join(" "); + const pmCommand = pmCommands[pm.name].add.join(" "); const packages = requiredPackages.join(" "); const command = `${pm.name} ${pmCommand} ${packages}`; diff --git a/packages/cli/src/commands/update/index.ts b/packages/cli/src/commands/update/index.ts index b597c82efeea..a0c45acb0331 100644 --- a/packages/cli/src/commands/update/index.ts +++ b/packages/cli/src/commands/update/index.ts @@ -1,17 +1,34 @@ import inquirer from "inquirer"; import center from "center-align"; import { type Command, Option } from "commander"; +import PackageJson from "@npmcli/package-json"; import spinner from "@utils/spinner"; -import { isRefineUptoDate } from "@commands/check-updates"; +import { + getLatestMinorVersionOfPackage, + getWantedWithPreferredWildcard, + isRefineUptoDate, +} from "@commands/check-updates"; import { getPreferedPM, installPackages, pmCommands } from "@utils/package"; import { promptInteractiveRefineUpdate } from "@commands/update/interactive"; -import type { RefinePackageInstalledVersionData } from "@definitions/package"; +import type { + PackageDependency, + RefinePackageInstalledVersionData, +} from "@definitions/package"; import { getVersionTable } from "@components/version-table"; +import chalk from "chalk"; + +type SelectedPackage = PackageDependency; enum Tag { - Wanted = "wanted", - Latest = "latest", - Next = "next", + WANTED = "wanted", + LATEST = "latest", + NEXT = "next", +} + +enum InstallationType { + WANTED = "wanted", + MINOR = "minor", + INTERACTIVE = "interactive", } interface OptionValues { @@ -56,83 +73,160 @@ const action = async (options: OptionValues) => { return; } - let selectedPackages: string[] | null | undefined = null; + let selectedPackages: SelectedPackage | null | undefined = null; if (all) { - runAll(tag, packages); - } else { - const { table, width } = getVersionTable(packages) ?? ""; - - console.log(center("Available Updates", width)); - console.log(table); - - const { allByPrompt } = await inquirer.prompt<{ allByPrompt: boolean }>([ - { - type: "list", - name: "allByPrompt", - message: - "Do you want to update all Refine packages for minor and patch versions?", - choices: [ - { - name: "Yes (Recommended)", - value: true, - }, - { - name: "No, use interactive mode", - value: false, - }, - ], - }, - ]); - - if (allByPrompt) { - selectedPackages = runAll(tag, packages); - } else { - selectedPackages = await promptInteractiveRefineUpdate(packages); + const selectedPackages = await preparePackagesToInstall(tag, packages); + if (!selectedPackages) return; + + if (dryRun) { + printInstallCommand(selectedPackages); + return; } + + runInstallation(selectedPackages); + return; + } + + // print the table of available updates + const { table, width } = getVersionTable(packages) ?? ""; + console.log(center("Available Updates", width)); + console.log(table); + console.log( + `- ${chalk.yellow( + chalk.bold("Current"), + )}: The version of the package that is currently installed`, + ); + console.log( + `- ${chalk.yellow( + chalk.bold("Wanted"), + )}: The maximum version of the package that satisfies the semver range specified in \`package.json\``, + ); + console.log( + `- ${chalk.yellow( + chalk.bold("Latest"), + )}: The latest version of the package available on npm`, + ); + console.log(); + + const { installationType } = await inquirer.prompt<{ + installationType: InstallationType; + }>([ + { + type: "list", + name: "installationType", + message: + "Do you want to update all Refine packages for minor and patch versions?", + choices: [ + { + name: `Update all packages to latest "minor" version without any breaking changes.`, + value: "minor", + }, + { + name: "Update all packages to the latest version that satisfies the semver(`wanted`) range specified in `package.json`", + value: "wanted", + }, + { + name: `Use interactive mode. Choose this option for "major" version updates.`, + value: "interactive", + }, + ], + }, + ]); + + if (installationType === InstallationType.INTERACTIVE) { + selectedPackages = await promptInteractiveRefineUpdate(packages); + } + if (installationType === InstallationType.WANTED) { + selectedPackages = await preparePackagesToInstall(Tag.WANTED, packages); + } + if (installationType === InstallationType.MINOR) { + selectedPackages = await preparePackagesToInstall( + InstallationType.MINOR, + packages, + ); } if (!selectedPackages) return; if (dryRun) { printInstallCommand(selectedPackages); - return; + } else { + runInstallation(selectedPackages); } - - pmInstall(selectedPackages); }; -const runAll = (tag: Tag, packages: RefinePackageInstalledVersionData[]) => { - if (tag === Tag.Wanted) { +const preparePackagesToInstall = async ( + tag: Tag | InstallationType, + packages: RefinePackageInstalledVersionData[], +): Promise => { + if (tag === Tag.WANTED) { const isAllPackagesAtWantedVersion = packages.every( (pkg) => pkg.current === pkg.wanted, ); if (isAllPackagesAtWantedVersion) { - console.log( - "All `Refine` packages are up to date with the wanted version 🎉", - ); + console.log(); + console.log("✅ All `Refine` packages are already at the wanted version"); return null; } } - const packagesWithVersion = packages.map((pkg) => { - const version = tag === Tag.Wanted ? pkg.wanted : tag; - return `${pkg.name}@${version}`; - }); + // empty line for better readability + console.log(); + + const packagesWithVersion: PackageDependency = {}; + for (const pkg of packages) { + let version = pkg.latest; + + if (tag === InstallationType.MINOR) { + const latestMinorVersion = await spinner( + () => getLatestMinorVersionOfPackage(pkg.name, pkg.wanted), + `Checking for the latest minor version of ${pkg.name}`, + ); + version = `^${latestMinorVersion}`; + } + if (tag === Tag.WANTED) { + version = getWantedWithPreferredWildcard(pkg.name, pkg.wanted); + } + if (tag === Tag.LATEST) { + version = `^${pkg.latest}`; + } + if (tag === Tag.NEXT) { + version = Tag.NEXT; + } + + packagesWithVersion[pkg.name] = version; + } return packagesWithVersion; }; -const printInstallCommand = async (packages: string[]) => { +const printInstallCommand = async (packages: SelectedPackage) => { const pm = await getPreferedPM(); - const commandInstall = pmCommands[pm.name].install; - console.log(`${pm.name} ${commandInstall.join(" ")} ${packages.join(" ")}`); + const commandInstall = pmCommands[pm.name].add; + let packagesListAsString = ""; + for (const [name, version] of Object.entries(packages)) { + packagesListAsString += `${name}@${version} `; + } + console.log(); + console.log(`${pm.name} ${commandInstall.join(" ")} ${packagesListAsString}`); }; -const pmInstall = (packages: string[]) => { +const runInstallation = async (packagesToInstall: SelectedPackage) => { console.log("Updating `Refine` packages..."); - console.log(packages.map((pkg) => ` - ${pkg}`).join("\n")); - installPackages(packages); + + // to install packages, first we need to manipulate the package.json file, then install the packages + const packageJson = await PackageJson.load(process.cwd()); + + packageJson.update({ + dependencies: { + ...((packageJson.content.dependencies ?? {}) as { [x: string]: string }), + ...(packagesToInstall ?? {}), + }, + }); + await packageJson.save(); + + installPackages([], "all"); }; export default load; diff --git a/packages/cli/src/commands/update/interactive/index.test.tsx b/packages/cli/src/commands/update/interactive/index.test.tsx index e0cce5cba7d8..0a8e6aa72d99 100644 --- a/packages/cli/src/commands/update/interactive/index.test.tsx +++ b/packages/cli/src/commands/update/interactive/index.test.tsx @@ -28,7 +28,7 @@ test("Validate interactive prompt", () => { test("Categorize UI Group", () => { const testCases = [ { - input: [], + input: [] as any, output: null, }, { diff --git a/packages/cli/src/commands/update/interactive/index.ts b/packages/cli/src/commands/update/interactive/index.ts index 9c85489e5c5d..c05afbded89f 100644 --- a/packages/cli/src/commands/update/interactive/index.ts +++ b/packages/cli/src/commands/update/interactive/index.ts @@ -3,7 +3,10 @@ import semverDiff from "semver-diff"; import chalk from "chalk"; import { findDuplicates } from "@utils/array"; import { parsePackageNameAndVersion } from "@utils/package"; -import type { RefinePackageInstalledVersionData } from "@definitions/package"; +import type { + PackageDependency, + RefinePackageInstalledVersionData, +} from "@definitions/package"; type UIGroup = { patch: { @@ -47,7 +50,18 @@ export const promptInteractiveRefineUpdate = async ( }, ]); - return answers.packages.length > 0 ? answers.packages : null; + if (answers.packages.length > 0) { + // convert to object for easy access + const packagesObject: PackageDependency = {}; + answers.packages.forEach((pckg) => { + const { name, version } = parsePackageNameAndVersion(pckg); + packagesObject[name] = version ?? "latest"; + }); + + return packagesObject; + } + + return null; }; export const validatePrompt = (input: string[]) => { @@ -159,8 +173,8 @@ const createInquirerUI = (uiGroup: UIGroup) => { choices.push({ name: `${pckg.name.padEnd(maxNameLength)} ${pckg.from.padStart( maxFromLength, - )} -> ${pckg.to}`, - value: `${pckg.name}@${pckg.to}`, + )} -> ^${pckg.to}`, + value: `${pckg.name}@^${pckg.to}`, }); }); } @@ -173,8 +187,8 @@ const createInquirerUI = (uiGroup: UIGroup) => { choices.push({ name: `${pckg.name.padEnd(maxNameLength)} ${pckg.from.padStart( maxFromLength, - )} -> ${pckg.to}`, - value: `${pckg.name}@${pckg.to}`, + )} -> ^${pckg.to}`, + value: `${pckg.name}@^${pckg.to}`, }); }); } @@ -187,8 +201,8 @@ const createInquirerUI = (uiGroup: UIGroup) => { choices.push({ name: `${pckg.name.padEnd(maxNameLength)} ${pckg.from.padStart( maxFromLength, - )} -> ${pckg.to}`, - value: `${pckg.name}@${pckg.to}`, + )} -> ^${pckg.to}`, + value: `${pckg.name}@^${pckg.to}`, }); }); } diff --git a/packages/cli/src/components/update-warning-table/table.ts b/packages/cli/src/components/update-warning-table/table.ts index 6f505d34e577..cfd1520a5a99 100644 --- a/packages/cli/src/components/update-warning-table/table.ts +++ b/packages/cli/src/components/update-warning-table/table.ts @@ -18,6 +18,22 @@ export const printUpdateWarningTable = async ( const { table, width } = getVersionTable(data); console.log(); console.log(center("Update Available", width)); + console.log(); + console.log( + `- ${chalk.yellow( + chalk.bold("Current"), + )}: The version of the package that is currently installed`, + ); + console.log( + `- ${chalk.yellow( + chalk.bold("Wanted"), + )}: The maximum version of the package that satisfies the semver range specified in \`package.json\``, + ); + console.log( + `- ${chalk.yellow( + chalk.bold("Latest"), + )}: The latest version of the package available on npm`, + ); console.log(table); console.log( center( diff --git a/packages/cli/src/definitions/package.ts b/packages/cli/src/definitions/package.ts index 46b3cecbd82a..3b57f4e7b1aa 100644 --- a/packages/cli/src/definitions/package.ts +++ b/packages/cli/src/definitions/package.ts @@ -4,20 +4,62 @@ export enum PackageManagerTypes { PNPM = "pnpm", } +/** + * type of `npm outdated` command response + */ export type NpmOutdatedResponse = Record< string, { current: string; wanted: string; latest: string; - dependet?: string; + dependent: string; + location: string; } >; export type RefinePackageInstalledVersionData = { name: string; + /** + * version of the package that is currently installed. Without semver range wildcard. + */ current: string; + /** + * version that the user wants to update to. Without semver range wildcard. + * e.g. `^1.0.0` in `package.json` resolves to `1.0.1` in the this field. + */ wanted: string; + /** + * latest version of the package available on npm + */ latest: string; + /** + * changelog url + */ changelog?: string; + /** + * dependent package name + */ + dependent: string; + /** + * location of the package + */ + location: string; +}; + +/** + * key is the script name and value is the script command + */ +export type PackageDependency = Record; + +export type PackageJson = { + name: string; + version: string; + scripts?: Record; + dependencies?: PackageDependency; + devDependencies?: PackageDependency; + peerDependencies?: PackageDependency; + refine?: { + projectId?: string; + }; }; diff --git a/packages/cli/src/utils/package/index.ts b/packages/cli/src/utils/package/index.ts index 0944188301ab..380d5bb890d4 100644 --- a/packages/cli/src/utils/package/index.ts +++ b/packages/cli/src/utils/package/index.ts @@ -4,9 +4,9 @@ import { existsSync, pathExists, readFileSync, readJSON } from "fs-extra"; import globby from "globby"; import path from "path"; import preferredPM from "preferred-pm"; +import type { PackageJson } from "@definitions/package"; -// TODO: Add package.json type -export const getPackageJson = (): any => { +export const getPackageJson = (): PackageJson => { if (!existsSync("package.json")) { throw new Error("./package.json not found"); } @@ -14,28 +14,28 @@ export const getPackageJson = (): any => { return JSON.parse(readFileSync("package.json", "utf8")); }; -export const getDependencies = (): string[] => { +export const getDependencies = () => { const packageJson = getPackageJson(); return Object.keys(packageJson.dependencies || {}); }; -export const getDependenciesWithVersion = (): string[] => { +export const getDependenciesWithVersion = () => { const packageJson = getPackageJson(); - return packageJson.dependencies; + return packageJson?.dependencies || {}; }; -export const getDevDependencies = (): string[] => { +export const getDevDependencies = () => { const packageJson = getPackageJson(); return Object.keys(packageJson.devDependencies || {}); }; -export const getAllDependencies = (): string[] => { +export const getAllDependencies = () => { return [...getDependencies(), ...getDependencies()]; }; -export const getScripts = (): Record => { +export const getScripts = () => { const packageJson = getPackageJson(); - return packageJson.scripts; + return packageJson?.scripts || {}; }; export const getInstalledRefinePackages = async () => { @@ -125,24 +125,28 @@ export const isPackageHaveRefineConfig = async (packagePath: string) => { export const pmCommands = { npm: { - install: ["install", "--save"], - installDev: ["install", "--save-dev"], + add: ["install", "--save"], + addDev: ["install", "--save-dev"], outdatedJson: ["outdated", "--json"], + install: ["install"], }, yarn: { - install: ["add"], - installDev: ["add", "-D"], + add: ["add"], + addDev: ["add", "-D"], outdatedJson: ["outdated", "--json"], + install: ["install"], }, pnpm: { - install: ["add"], - installDev: ["add", "-D"], + add: ["add"], + addDev: ["add", "-D"], outdatedJson: ["outdated", "--format", "json"], + install: ["install"], }, bun: { - install: ["add"], - installDev: ["add", "--dev"], + add: ["add"], + addDev: ["add", "--dev"], outdatedJson: ["outdated", "--format", "json"], + install: ["install"], }, }; @@ -159,11 +163,15 @@ export const getPreferedPM = async () => { return pm; }; -export const installPackages = async (packages: string[]) => { +export const installPackages = async ( + packages: string[], + type: "all" | "add" = "all", +) => { const pm = await getPreferedPM(); try { - const installCommand = pmCommands[pm.name].install; + const installCommand = + type === "all" ? pmCommands[pm.name].install : pmCommands[pm.name].add; const execution = execa(pm.name, [...installCommand, ...packages], { stdio: "inherit", @@ -194,7 +202,7 @@ export const installPackagesSync = async (packages: string[]) => { const pm = await getPreferedPM(); try { - const installCommand = pmCommands[pm.name].install; + const installCommand = pmCommands[pm.name].add; const execution = execa.sync(pm.name, [...installCommand, ...packages], { stdio: "inherit", @@ -285,3 +293,44 @@ export const hasIncomatiblePackages = (packages: string[]): boolean => { return false; }; + +export const getAllVersionsOfPackage = async ( + packageName: string, +): Promise => { + const pm = "npm"; + + const { stdout, timedOut } = await execa( + pm, + ["view", packageName, "versions", "--json"], + { + reject: false, + timeout: 25 * 1000, + }, + ); + + if (timedOut) { + console.log("❌ Timed out while checking for updates."); + process.exit(1); + } + + let result: + | string[] + | { + error: { + code: string; + }; + } = []; + + try { + result = JSON.parse(stdout); + if (!result || "error" in result) { + console.log("❌ Something went wrong while checking for updates."); + process.exit(1); + } + } catch (error) { + console.log("❌ Something went wrong while checking for updates."); + process.exit(1); + } + + return result; +}; diff --git a/packages/cli/src/utils/refine/index.test.tsx b/packages/cli/src/utils/refine/index.test.tsx index 99a9dac7aa05..711d6a42ea2c 100644 --- a/packages/cli/src/utils/refine/index.test.tsx +++ b/packages/cli/src/utils/refine/index.test.tsx @@ -56,9 +56,11 @@ test("Has default script", () => { ]; testCases.forEach((testCase) => { - jest - .spyOn(utilsPackage, "getPackageJson") - .mockReturnValueOnce(testCase.input); + jest.spyOn(utilsPackage, "getPackageJson").mockReturnValueOnce({ + name: "test", + version: "1.0.0", + ...testCase.input, + }); const result = hasDefaultScript(); diff --git a/packages/codemod/package.json b/packages/codemod/package.json index d26090327d7d..9707b5287a6c 100644 --- a/packages/codemod/package.json +++ b/packages/codemod/package.json @@ -24,7 +24,7 @@ "prepare": "pnpm build" }, "dependencies": { - "@npmcli/package-json": "3.0.0", + "@npmcli/package-json": "^5.2.0", "chalk": "^4.1.2", "cheerio": "1.0.0-rc.9", "execa": "^5.1.1", @@ -40,6 +40,7 @@ "@types/inquirer": "^8.2.5", "@types/jest": "^29.2.4", "@types/jscodeshift": "^0.11.11", + "@types/npmcli__package-json": "^4.0.4", "jest": "^29.3.1", "ts-jest": "^29.1.2", "tslib": "^2.6.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4d74c51a7728..109443f6996a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13809,6 +13809,9 @@ importers: packages/cli: dependencies: + '@npmcli/package-json': + specifier: ^5.2.0 + version: 5.2.0 '@refinedev/devtools-server': specifier: 1.1.34 version: link:../devtools-server @@ -13957,6 +13960,9 @@ importers: '@types/node-fetch': specifier: ^2.6.11 version: 2.6.11 + '@types/npmcli__package-json': + specifier: ^4.0.4 + version: 4.0.4 '@types/pluralize': specifier: ^0.0.29 version: 0.0.29 @@ -13985,8 +13991,8 @@ importers: packages/codemod: dependencies: '@npmcli/package-json': - specifier: 3.0.0 - version: 3.0.0 + specifier: ^5.2.0 + version: 5.2.0 chalk: specifier: ^4.1.2 version: 4.1.2 @@ -14027,6 +14033,9 @@ importers: '@types/jscodeshift': specifier: ^0.11.11 version: 0.11.11 + '@types/npmcli__package-json': + specifier: ^4.0.4 + version: 4.0.4 jest: specifier: ^29.3.1 version: 29.7.0(@types/node@20.5.1)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.5.1)(typescript@5.4.5)) @@ -20684,14 +20693,14 @@ packages: resolution: {integrity: sha512-gp8pRXC2oOxu0DUE1/M3bYtb1b3/DbJ5aM113+XJBgfXdussRAsX0YOrOhdd8WvnAR6auDBvJomGAkLKA5ydxA==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - '@npmcli/package-json@3.0.0': - resolution: {integrity: sha512-NnuPuM97xfiCpbTEJYtEuKz6CFbpUHtaT0+5via5pQeI25omvQDFbp1GcGJ/c4zvL/WX0qbde6YiLgfZbWFgvg==} - engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - '@npmcli/package-json@4.0.1': resolution: {integrity: sha512-lRCEGdHZomFsURroh522YvA/2cVb9oPIJrjHanCJZkiasz1BzcnLr3tBJhlV7S86MBJBuAQ33is2D60YitZL2Q==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + '@npmcli/package-json@5.2.0': + resolution: {integrity: sha512-qe/kiqqkW0AGtvBjL8TJKZk/eBBSpnJkUWvHdQ9jM2lKHXRYYJuyNpJPlJw3c8QjC2ow6NZYiLExhUaeJelbxQ==} + engines: {node: ^16.14.0 || >=18.0.0} + '@npmcli/promise-spawn@6.0.2': resolution: {integrity: sha512-gGq0NJkIGSwdbUt4yhdF8ZrmkGKVz9vAdVzpOfnom+V8PLSmSOVhZwbNvZZS1EYcJN5hzzKBxmmVVAInM6HQLg==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} @@ -23048,6 +23057,9 @@ packages: '@types/normalize-package-data@2.4.4': resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} + '@types/npmcli__package-json@4.0.4': + resolution: {integrity: sha512-6QjlFUSHBmZJWuC08bz1ZCx6tm4t+7+OJXAdvM6tL2pI7n6Bh5SIp/YxQvnOLFf8MzCXs2ijyFgrzaiu1UFBGA==} + '@types/papaparse@5.3.14': resolution: {integrity: sha512-LxJ4iEFcpqc6METwp9f6BV6VVc43m6MfH0VqFosHvrUgfXiFe6ww7R3itkOQ+TCK6Y+Iv/+RnnvtRZnkc5Kc9g==} @@ -43250,10 +43262,6 @@ snapshots: '@npmcli/node-gyp@3.0.0': {} - '@npmcli/package-json@3.0.0': - dependencies: - json-parse-even-better-errors: 3.0.1 - '@npmcli/package-json@4.0.1': dependencies: '@npmcli/git': 4.1.0 @@ -43266,6 +43274,18 @@ snapshots: transitivePeerDependencies: - bluebird + '@npmcli/package-json@5.2.0': + dependencies: + '@npmcli/git': 5.0.6 + glob: 10.4.2 + hosted-git-info: 7.0.1 + json-parse-even-better-errors: 3.0.1 + normalize-package-data: 6.0.0 + proc-log: 4.2.0 + semver: 7.6.0 + transitivePeerDependencies: + - bluebird + '@npmcli/promise-spawn@6.0.2': dependencies: which: 3.0.1 @@ -46425,6 +46445,8 @@ snapshots: '@types/normalize-package-data@2.4.4': {} + '@types/npmcli__package-json@4.0.4': {} + '@types/papaparse@5.3.14': dependencies: '@types/node': 18.19.31 From 20499cac091de94dcb4856a5253c68f216f022aa Mon Sep 17 00:00:00 2001 From: Aiswarya PM <31305967+aishuarya@users.noreply.github.com> Date: Mon, 29 Jul 2024 19:15:51 +0530 Subject: [PATCH 10/30] fix(nestjsx-crud): handle empty filters (#6160) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ali Emir Şen --- .changeset/itchy-houses-provide.md | 9 +++++++++ packages/nestjsx-crud/src/utils/handleFilter.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/itchy-houses-provide.md diff --git a/.changeset/itchy-houses-provide.md b/.changeset/itchy-houses-provide.md new file mode 100644 index 000000000000..c3081b601071 --- /dev/null +++ b/.changeset/itchy-houses-provide.md @@ -0,0 +1,9 @@ +--- +"@refinedev/nestjsx-crud": patch +--- + +fix: update empty filter checks + +Updated the conditions to properly check empty filters + +[Fixes #6146](https://github.com/refinedev/refine/issues/6146) diff --git a/packages/nestjsx-crud/src/utils/handleFilter.ts b/packages/nestjsx-crud/src/utils/handleFilter.ts index 2f650865009f..4f466b5c4c29 100644 --- a/packages/nestjsx-crud/src/utils/handleFilter.ts +++ b/packages/nestjsx-crud/src/utils/handleFilter.ts @@ -36,7 +36,7 @@ export const handleFilter = ( query: RequestQueryBuilder, filters?: CrudFilters, ) => { - if (filters) { + if (Array.isArray(filters) && filters.length > 0) { query.search(generateSearchFilter(filters)); } return query; From 5a8e94aa4afe0faf3ea1de93a4b00e0b44dd1ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20Emir=20=C5=9Een?= Date: Tue, 30 Jul 2024 01:35:44 +0300 Subject: [PATCH 11/30] fix(auth-page): replace wrong translation keys (#6199) --- .changeset/popular-bees-smash.md | 23 ++++++++++++++++ .changeset/warm-pots-relax.md | 7 +++++ .../auth/components/forgotPassword/index.tsx | 12 ++++++--- .../pages/auth/components/register/index.tsx | 27 ++++++++++++++----- .../auth/components/forgotPassword/index.tsx | 19 +++++++++---- .../pages/auth/components/register/index.tsx | 21 ++++++++++----- .../auth/components/forgotPassword/index.tsx | 7 +++-- .../pages/auth/components/register/index.tsx | 5 +++- .../auth/components/forgotPassword/index.tsx | 12 ++++++--- .../pages/auth/components/register/index.tsx | 18 ++++++++++--- 10 files changed, 122 insertions(+), 29 deletions(-) create mode 100644 .changeset/popular-bees-smash.md create mode 100644 .changeset/warm-pots-relax.md diff --git a/.changeset/popular-bees-smash.md b/.changeset/popular-bees-smash.md new file mode 100644 index 000000000000..207e07171d80 --- /dev/null +++ b/.changeset/popular-bees-smash.md @@ -0,0 +1,23 @@ +--- +"@refinedev/chakra-ui": patch +"@refinedev/mantine": patch +"@refinedev/antd": patch +"@refinedev/mui": patch +--- + +fix(auth-page): fix wrong translation keys in `type="register"` and `type="forgotPassword"` + +In `type="forgotPassword"`: + +- `"pages.register.buttons.haveAccount"` is replaced with `"pages.forgotPassword.buttons.haveAccount"` +- `"pages.login.signin"` is replaced with `"pages.forgotPassword.signin"` + +In `type="register"`: + +- `"pages.login.divider"` is replaced with `"pages.register.divider"` +- `"pages.login.buttons.haveAccount"` is replaced with `"pages.register.buttons.haveAccount"` +- `"pages.login.signin"` is replaced with `"pages.register.signin"` + +Wrong keys are kept as fallbacks in case the new keys are not found in the translation file. If you are using those keys in your project, make sure to update them accordingly. Fallback keys will be removed in future releases. + +[Resolves #5816](https://github.com/refinedev/refine/issues/5816) diff --git a/.changeset/warm-pots-relax.md b/.changeset/warm-pots-relax.md new file mode 100644 index 000000000000..a9bf7d8d34c6 --- /dev/null +++ b/.changeset/warm-pots-relax.md @@ -0,0 +1,7 @@ +--- +"@refinedev/chakra-ui": patch +--- + +fix(auth-page): fix wrong translation key in `type="register"` + +Previously, sign in link in Register page was using wrong translation key "pages.register.buttons.noAccount". Now it is replaced with "pages.register.buttons.haveAccount". diff --git a/packages/antd/src/components/pages/auth/components/forgotPassword/index.tsx b/packages/antd/src/components/pages/auth/components/forgotPassword/index.tsx index a603f7658369..410869b89ae6 100644 --- a/packages/antd/src/components/pages/auth/components/forgotPassword/index.tsx +++ b/packages/antd/src/components/pages/auth/components/forgotPassword/index.tsx @@ -151,8 +151,11 @@ export const ForgotPasswordPage: React.FC = ({ }} > {translate( - "pages.register.buttons.haveAccount", - "Have an account? ", + "pages.forgotPassword.buttons.haveAccount", + translate( + "pages.register.buttons.haveAccount", + "Have an account? ", + ), )}{" "} = ({ }} to="/login" > - {translate("pages.login.signin", "Sign in")} + {translate( + "pages.forgotPassword.signin", + translate("pages.login.signin", "Sign in"), + )} )} diff --git a/packages/antd/src/components/pages/auth/components/register/index.tsx b/packages/antd/src/components/pages/auth/components/register/index.tsx index c6e92d2b8a0f..b36c9d84b9b5 100644 --- a/packages/antd/src/components/pages/auth/components/register/index.tsx +++ b/packages/antd/src/components/pages/auth/components/register/index.tsx @@ -123,7 +123,10 @@ export const RegisterPage: React.FC = ({ color: token.colorTextLabel, }} > - {translate("pages.login.divider", "or")} + {translate( + "pages.register.divider", + translate("pages.login.divider", "or"), + )} )} @@ -208,8 +211,11 @@ export const RegisterPage: React.FC = ({ }} > {translate( - "pages.login.buttons.haveAccount", - "Have an account?", + "pages.register.buttons.haveAccount", + translate( + "pages.login.buttons.haveAccount", + "Have an account?", + ), )}{" "} = ({ }} to="/login" > - {translate("pages.login.signin", "Sign in")} + {translate( + "pages.register.signin", + translate("pages.login.signin", "Sign in"), + )} )} @@ -251,7 +260,10 @@ export const RegisterPage: React.FC = ({ fontSize: 12, }} > - {translate("pages.login.buttons.haveAccount", "Have an account?")}{" "} + {translate( + "pages.register.buttons.haveAccount", + translate("pages.login.buttons.haveAccount", "Have an account?"), + )}{" "} = ({ }} to="/login" > - {translate("pages.login.signin", "Sign in")} + {translate( + "pages.register.signin", + translate("pages.login.signin", "Sign in"), + )} diff --git a/packages/chakra-ui/src/components/pages/auth/components/forgotPassword/index.tsx b/packages/chakra-ui/src/components/pages/auth/components/forgotPassword/index.tsx index c6838aa940d1..a5d12b4cc6a6 100644 --- a/packages/chakra-ui/src/components/pages/auth/components/forgotPassword/index.tsx +++ b/packages/chakra-ui/src/components/pages/auth/components/forgotPassword/index.tsx @@ -117,8 +117,11 @@ export const ForgotPasswordPage: React.FC = ({ pattern: { value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i, message: translate( - "pages.login.errors.validEmail", - "Invalid email address", + "pages.forgotPassword.errors.validEmail", + translate( + "pages.login.errors.validEmail", + "Invalid email address", + ), ), }, })} @@ -130,12 +133,18 @@ export const ForgotPasswordPage: React.FC = ({ {translate( - "pages.register.buttons.haveAccount", - "Have an account?", + "pages.forgotPassword.buttons.haveAccount", + translate( + "pages.register.buttons.haveAccount", + "Have an account?", + ), )} - {translate("pages.login.signin", "Sign in")} + {translate( + "pages.forgotPassword.signin", + translate("pages.login.signin", "Sign in"), + )} )} diff --git a/packages/chakra-ui/src/components/pages/auth/components/register/index.tsx b/packages/chakra-ui/src/components/pages/auth/components/register/index.tsx index ce52fb89ee70..69c489d79dce 100644 --- a/packages/chakra-ui/src/components/pages/auth/components/register/index.tsx +++ b/packages/chakra-ui/src/components/pages/auth/components/register/index.tsx @@ -195,8 +195,11 @@ export const RegisterPage: React.FC = ({ > {translate( - "pages.login.buttons.haveAccount", - "Have an account?", + "pages.register.buttons.haveAccount", + translate( + "pages.login.buttons.haveAccount", + "Have an account?", + ), )} = ({ as={Link} to="/login" > - {translate("pages.login.signin", "Sign in")} + {translate( + "pages.register.signin", + translate("pages.login.signin", "Sign in"), + )} )} @@ -217,8 +223,8 @@ export const RegisterPage: React.FC = ({ {translate( - "pages.login.buttons.noAccount", - "Don’t have an account?", + "pages.register.buttons.haveAccount", + "Have an account?", )} = ({ fontWeight="bold" to="/login" > - {translate("pages.login.signin", "Sign in")} + {translate( + "pages.register.signin", + translate("pages.login.signin", "Sign in"), + )} )} diff --git a/packages/mantine/src/components/pages/auth/components/forgotPassword/index.tsx b/packages/mantine/src/components/pages/auth/components/forgotPassword/index.tsx index 7cfbb3a9a163..1b720a768e39 100644 --- a/packages/mantine/src/components/pages/auth/components/forgotPassword/index.tsx +++ b/packages/mantine/src/components/pages/auth/components/forgotPassword/index.tsx @@ -122,8 +122,11 @@ export const ForgotPasswordPage: React.FC = ({ {translate( - "pages.login.forgotPassword.haveAccount", - "Have an account?", + "pages.forgotPassword.buttons.haveAccount", + translate( + "pages.login.forgotPassword.haveAccount", + "Have an account? ", + ), )}{" "} {translate("pages.forgotPassword.signin", "Sign in")} diff --git a/packages/mantine/src/components/pages/auth/components/register/index.tsx b/packages/mantine/src/components/pages/auth/components/register/index.tsx index 6f44f1a46491..efb9d3a49d6c 100644 --- a/packages/mantine/src/components/pages/auth/components/register/index.tsx +++ b/packages/mantine/src/components/pages/auth/components/register/index.tsx @@ -123,7 +123,10 @@ export const RegisterPage: React.FC = ({ )} diff --git a/packages/mui/src/components/pages/auth/components/forgotPassword/index.tsx b/packages/mui/src/components/pages/auth/components/forgotPassword/index.tsx index 73ea8bd9be96..af25b487f103 100644 --- a/packages/mui/src/components/pages/auth/components/forgotPassword/index.tsx +++ b/packages/mui/src/components/pages/auth/components/forgotPassword/index.tsx @@ -140,8 +140,11 @@ export const ForgotPasswordPage: React.FC = ({ {translate( - "pages.register.buttons.haveAccount", - "Have an account?", + "pages.forgotPassword.buttons.haveAccount", + translate( + "pages.register.buttons.haveAccount", + "Have an account? ", + ), )} {" "} = ({ fontSize="12px" color="primary.light" > - {translate("pages.login.signin", "Sign in")} + {translate( + "pages.forgotPassword.signin", + translate("pages.login.signin", "Sign in"), + )} )} diff --git a/packages/mui/src/components/pages/auth/components/register/index.tsx b/packages/mui/src/components/pages/auth/components/register/index.tsx index 664264a094cb..3a69faa8563d 100644 --- a/packages/mui/src/components/pages/auth/components/register/index.tsx +++ b/packages/mui/src/components/pages/auth/components/register/index.tsx @@ -131,7 +131,10 @@ export const RegisterPage: React.FC = ({ marginY: "16px", }} > - {translate("pages.login.divider", "or")} + {translate( + "pages.register.divider", + translate("pages.login.divider", "or"), + )} )} @@ -238,7 +241,13 @@ export const RegisterPage: React.FC = ({ }} > - {translate("pages.login.buttons.haveAccount", "Have an account?")} + {translate( + "pages.register.buttons.haveAccount", + translate( + "pages.login.buttons.haveAccount", + "Have an account?", + ), + )} = ({ fontSize="12px" fontWeight="bold" > - {translate("pages.login.signin", "Sign in")} + {translate( + "pages.register.signin", + translate("pages.login.signin", "Sign in"), + )} )} From e2b467528f6a799c3219e3a8fefd4834a0ca0431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20Emir=20=C5=9Een?= Date: Tue, 30 Jul 2024 01:38:35 +0300 Subject: [PATCH 12/30] feat(cli): add example translation file to i18n provider template (#6196) --- .changeset/quick-rats-eat.md | 11 ++ .../sub-commands/provider/create-providers.ts | 58 +++++- .../cli/templates/assets/i18n/locale/en.json | 174 ++++++++++++++++++ .../public/locales/en/common.json | 6 +- 4 files changed, 245 insertions(+), 4 deletions(-) create mode 100644 .changeset/quick-rats-eat.md create mode 100644 packages/cli/templates/assets/i18n/locale/en.json diff --git a/.changeset/quick-rats-eat.md b/.changeset/quick-rats-eat.md new file mode 100644 index 000000000000..2085f2fded76 --- /dev/null +++ b/.changeset/quick-rats-eat.md @@ -0,0 +1,11 @@ +--- +"@refinedev/cli": patch +--- + +feat(cli): create base translation files for i18n provider in add provider command + +Currently `refine add provider i18n` command is only creating a demo i18n provider implementation but misses the translation files. This PR adds the base translation files for the i18n provider which is used by Refine internally in hooks, notifications and components. + +Now `locale/en.json` will be added with primarily used translation keys and values for the i18n provider. + +[Resolves #5918](https://github.com/refinedev/refine/issues/5918) diff --git a/packages/cli/src/commands/add/sub-commands/provider/create-providers.ts b/packages/cli/src/commands/add/sub-commands/provider/create-providers.ts index a1c2d9c27506..71cdc3024e05 100644 --- a/packages/cli/src/commands/add/sub-commands/provider/create-providers.ts +++ b/packages/cli/src/commands/add/sub-commands/provider/create-providers.ts @@ -1,7 +1,13 @@ import { getProjectType } from "@utils/project"; -import { getProviderPath } from "@utils/resource"; -import { copySync, mkdirSync, pathExistsSync } from "fs-extra"; -import { join } from "path"; +import { getFilesPathByProject, getProviderPath } from "@utils/resource"; +import { + copySync, + existsSync, + mkdirSync, + pathExistsSync, + readdirSync, +} from "fs-extra"; +import { join, relative } from "path"; import { availableProviders, type Provider, @@ -9,6 +15,7 @@ import { } from "./providers"; const baseTemplatePath = `${__dirname}/../templates/provider`; +const baseAssetsPath = `${__dirname}/../templates/assets`; export const createProviders = ( providerIds: ProviderId[], @@ -16,9 +23,11 @@ export const createProviders = ( ) => { providerIds.forEach((providerId) => { const { fileName, templateFileName } = getProviderOptions(providerId); + const projectFilesBasePath = getFilesPathByProject(getProjectType()); const folderPath = pathFromArgs ?? getDefaultPath(); const filePath = join(folderPath, fileName); const fullPath = join(process.cwd(), folderPath, fileName); + const projectFilesPath = join(process.cwd(), projectFilesBasePath); if (pathExistsSync(fullPath)) { console.error(`❌ Provider (${filePath}) already exist!`); @@ -32,6 +41,49 @@ export const createProviders = ( copySync(`${baseTemplatePath}/${templateFileName}`, fullPath); console.log(`🎉 Provider (${filePath}) created successfully!`); + + const copiedAssets: string[] = []; + const failedAssets: string[] = []; + + if (pathExistsSync(`${baseAssetsPath}/${providerId}`)) { + try { + readdirSync(`${baseAssetsPath}/${providerId}`, { + recursive: true, + withFileTypes: true, + }).forEach((file) => { + if (!file.isDirectory()) { + const fromPath = join(file.path, file.name); + const destinationPath = join( + projectFilesPath, + relative(join(baseAssetsPath, providerId), file.path), + file.name, + ); + const relativeDestinationPath = join( + projectFilesBasePath, + relative(projectFilesPath, destinationPath), + ); + + if (existsSync(destinationPath)) { + failedAssets.push(relativeDestinationPath); + } else { + try { + copySync(fromPath, destinationPath); + copiedAssets.push(relativeDestinationPath); + } catch (error) { + failedAssets.push(relativeDestinationPath); + } + } + } + }); + } catch (error) {} + } + + if (copiedAssets.length) { + console.log(`🎉 Created additional assets: ${copiedAssets.join(", ")}`); + } + if (failedAssets.length) { + console.error(`❌ Failed to create assets: ${failedAssets.join(", ")}`); + } }); }; diff --git a/packages/cli/templates/assets/i18n/locale/en.json b/packages/cli/templates/assets/i18n/locale/en.json new file mode 100644 index 000000000000..ba17fb597de4 --- /dev/null +++ b/packages/cli/templates/assets/i18n/locale/en.json @@ -0,0 +1,174 @@ +{ + "pages": { + "login": { + "__description": "These keys are used by the components.", + "title": "Sign in to your account", + "signin": "Sign in", + "signup": "Sign up", + "divider": "or", + "fields": { + "email": "Email", + "password": "Password" + }, + "errors": { + "validEmail": "Invalid email address", + "requiredEmail": "Email is required", + "requiredPassword": "Password is required" + }, + "buttons": { + "submit": "Login", + "forgotPassword": "Forgot password?", + "noAccount": "Don’t have an account?", + "rememberMe": "Remember me" + } + }, + "forgotPassword": { + "__description": "These key are used by the components.", + "title": "Forgot your password?", + "signin": "Sign in", + "fields": { + "email": "Email" + }, + "errors": { + "validEmail": "Invalid email address", + "requiredEmail": "Email is required" + }, + "buttons": { + "submit": "Send reset instructions", + "haveAccount": "Have an account?" + } + }, + "register": { + "__description": "These keys are used by the components.", + "title": "Sign up for your account", + "signin": "Sign in", + "divider": "or", + "fields": { + "email": "Email", + "password": "Password" + }, + "errors": { + "validEmail": "Invalid email address", + "requiredEmail": "Email is required", + "requiredPassword": "Password is required" + }, + "buttons": { + "submit": "Register", + "haveAccount": "Have an account?" + } + }, + "updatePassword": { + "__description": "These keys are used by the components.", + "title": "Update password", + "fields": { + "password": "New Password", + "confirmPassword": "Confirm new password" + }, + "errors": { + "confirmPasswordNotMatch": "Passwords do not match", + "requiredPassword": "Password required", + "requiredConfirmPassword": "Confirm password is required" + }, + "buttons": { + "submit": "Update" + } + }, + "error": { + "__description": "These keys are used by the components.", + "info": "You may have forgotten to add the {{action}} component to {{resource}} resource.", + "404": "Sorry, the page you visited does not exist.", + "resource404": "Are you sure you have created the {{resource}} resource.", + "backHome": "Back Home" + } + }, + "actions": { + "__description": "These keys are used by the @refinedev/kbar package.", + "list": "List", + "create": "Create", + "edit": "Edit", + "show": "Show" + }, + "buttons": { + "__description": "These keys are used by the buttons and breadcrumbs.", + "create": "Create", + "save": "Save", + "logout": "Logout", + "delete": "Delete", + "edit": "Edit", + "cancel": "Cancel", + "confirm": "Are you sure?", + "filter": "Filter", + "clear": "Clear", + "refresh": "Refresh", + "show": "Show", + "undo": "Undo", + "import": "Import", + "clone": "Clone", + "notAccessTitle": "You don't have permission to access" + }, + "warnWhenUnsavedChanges": "Are you sure you want to leave? You have unsaved changes.", + "notifications": { + "__description": "These keys are used by the notification provider.", + "success": "Successful", + "error": "Error (status code: {{statusCode}})", + "undoable": "You have {{seconds}} seconds to undo", + "createSuccess": "Successfully created {{resource}}", + "createError": "There was an error creating {{resource}} (status code: {{statusCode}})", + "deleteSuccess": "Successfully deleted {{resource}}", + "deleteError": "Error when deleting {{resource}} (status code: {{statusCode}})", + "editSuccess": "Successfully edited {{resource}}", + "editError": "Error when editing {{resource}} (status code: {{statusCode}})", + "importProgress": "Importing: {{processed}}/{{total}}" + }, + "loading": "Loading", + "dashboard": { + "__description": "This key is used by components to display the dashboard item in sidebar.", + "title": "Dashboard" + }, + "posts": { + "__description": "These keys are used in translations for the 'posts' resource.", + "posts": "Posts", + "fields": { + "id": "Id", + "title": "Title", + "category": "Category", + "status": { + "title": "Status", + "published": "Published", + "draft": "Draft", + "rejected": "Rejected" + }, + "content": "Content", + "createdAt": "Created At" + }, + "titles": { + "create": "Create Post", + "edit": "Edit Post", + "list": "Posts", + "show": "Show Post" + } + }, + "table": { + "__description": "This key is used by Inferencer components in 'list' views.", + "actions": "Actions" + }, + "documentTitle": { + "__description": "These keys are used by the components.", + "default": "refine", + "suffix": " | Refine", + "post": { + "list": "Posts | Refine", + "show": "#{{id}} Show Post | Refine", + "edit": "#{{id}} Edit Post | Refine", + "create": "Create new Post | Refine", + "clone": "#{{id}} Clone Post | Refine" + } + }, + "autoSave": { + "__description": "These keys are used by the and the auto-save feature.", + "success": "saved", + "error": "auto save failure", + "loading": "saving...", + "idle": "waiting for changes" + } +} diff --git a/packages/live-previews/public/locales/en/common.json b/packages/live-previews/public/locales/en/common.json index c0c9995c9282..48db44d759ca 100644 --- a/packages/live-previews/public/locales/en/common.json +++ b/packages/live-previews/public/locales/en/common.json @@ -23,6 +23,7 @@ }, "forgotPassword": { "title": "Forgot your password?", + "signin": "Sign in", "fields": { "email": "Email" }, @@ -31,11 +32,14 @@ "requiredEmail": "Email is required" }, "buttons": { - "submit": "Send reset instructions" + "submit": "Send reset instructions", + "haveAccount": "Have an account?" } }, "register": { "title": "Sign up for your account", + "signin": "Sign in", + "divider": "or", "fields": { "email": "Email", "password": "Password" From 399ff2f9b785a1eebf59235fe6a5663d8b943ad3 Mon Sep 17 00:00:00 2001 From: Sergio Rene Tapia-Fikes <47071119+Sergio16T@users.noreply.github.com> Date: Tue, 30 Jul 2024 07:33:52 -0500 Subject: [PATCH 13/30] feat(supabase): add support for between in dataProvider. maps values to gte & lte. (#6206) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ali Emir Şen --- .changeset/hot-cougars-dream.md | 7 +++++++ packages/supabase/src/utils/generateFilter.ts | 9 +++++++++ 2 files changed, 16 insertions(+) create mode 100644 .changeset/hot-cougars-dream.md diff --git a/.changeset/hot-cougars-dream.md b/.changeset/hot-cougars-dream.md new file mode 100644 index 000000000000..0dba6d21ea30 --- /dev/null +++ b/.changeset/hot-cougars-dream.md @@ -0,0 +1,7 @@ +--- +"@refinedev/supabase": patch +--- + +feat: added support for between filter in supabase dataProvider. Maps values to gte & lte. + +[Feat #6119](https://github.com/refinedev/refine/issues/6119) diff --git a/packages/supabase/src/utils/generateFilter.ts b/packages/supabase/src/utils/generateFilter.ts index 9c43d9e3ce33..e1f96ca00010 100644 --- a/packages/supabase/src/utils/generateFilter.ts +++ b/packages/supabase/src/utils/generateFilter.ts @@ -26,6 +26,15 @@ export const generateFilter = (filter: CrudFilter, query: any) => { return query.lt(filter.field, filter.value); case "lte": return query.lte(filter.field, filter.value); + case "between": + if (filter.value.length !== 2) { + throw new Error( + `[@refinedev/supabase]: Unexpected length ${filter.value.length}. Between operator expects a range between 2 values.`, + ); + } + return query + .gte(filter.field, filter.value[0]) + .lte(filter.field, filter.value[1]); case "contains": return query.ilike(filter.field, `%${filter.value}%`); case "containss": From 261021c2710e2163e93d79b09ebb1e9a10db372f Mon Sep 17 00:00:00 2001 From: Alican Erdurmaz Date: Tue, 30 Jul 2024 15:34:58 +0300 Subject: [PATCH 14/30] feat(devtools): improve onboarding page design (#6202) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ali Emir Şen --- .changeset/odd-rats-travel.md | 9 ++ packages/devtools-ui/package.json | 1 + .../src/components/add-package-drawer.tsx | 5 +- .../src/components/add-package.item.tsx | 6 +- .../devtools-ui/src/components/button.tsx | 44 ++++++- packages/devtools-ui/src/components/input.tsx | 43 ++++++- .../src/components/monitor-filters.tsx | 10 +- .../devtools-ui/src/components/packages.tsx | 12 +- packages/devtools-ui/src/pages/onboarding.tsx | 116 +++++++++++++----- pnpm-lock.yaml | 45 +++---- 10 files changed, 216 insertions(+), 75 deletions(-) create mode 100644 .changeset/odd-rats-travel.md diff --git a/.changeset/odd-rats-travel.md b/.changeset/odd-rats-travel.md new file mode 100644 index 000000000000..5b91a7efd66d --- /dev/null +++ b/.changeset/odd-rats-travel.md @@ -0,0 +1,9 @@ +--- +"@refinedev/devtools-ui": patch +--- + +feat: Onboarding page of the DevTools improved. + +- Loading animation added. +- Client-side form validation added. +- Error handling improved. diff --git a/packages/devtools-ui/package.json b/packages/devtools-ui/package.json index 5d60e7311dac..d5b46b7ccbb2 100644 --- a/packages/devtools-ui/package.json +++ b/packages/devtools-ui/package.json @@ -55,6 +55,7 @@ "lodash-es": "^4.17.21", "prism-react-renderer": "^1.3.5", "react-gravatar": "^2.6.3", + "react-hook-form": "^7.43.5", "react-json-view-lite": "^1.3.0", "react-router-dom": "^6.8.1", "semver-diff": "^3.1.1" diff --git a/packages/devtools-ui/src/components/add-package-drawer.tsx b/packages/devtools-ui/src/components/add-package-drawer.tsx index 386405144d14..ceb85b323495 100644 --- a/packages/devtools-ui/src/components/add-package-drawer.tsx +++ b/packages/devtools-ui/src/components/add-package-drawer.tsx @@ -338,14 +338,13 @@ export const AddPackageDrawer = ({ > ); }, diff --git a/packages/devtools-ui/src/components/input.tsx b/packages/devtools-ui/src/components/input.tsx index ae408c9214c7..9b9a507e525b 100644 --- a/packages/devtools-ui/src/components/input.tsx +++ b/packages/devtools-ui/src/components/input.tsx @@ -8,6 +8,10 @@ type Props = { value?: string; onChange?: (value: string) => void; className?: string; + onBlur?: React.FocusEventHandler | undefined; + error?: string; + disabled?: boolean; + loading?: boolean; }; export const Input = ({ @@ -17,9 +21,13 @@ export const Input = ({ value, onChange, className, + disabled, + error, + onBlur, + loading, }: Props) => { return ( -