From cdcd678634c9210d0bcc179e5badebe26d91a45f Mon Sep 17 00:00:00 2001 From: Christiaan Westerbeek Date: Thu, 1 Sep 2022 14:21:39 +0200 Subject: [PATCH 01/11] Allow passing extra headers via meta --- src/dataProvider/index.ts | 57 +++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/src/dataProvider/index.ts b/src/dataProvider/index.ts index d129d2e..a081d2d 100644 --- a/src/dataProvider/index.ts +++ b/src/dataProvider/index.ts @@ -1,4 +1,17 @@ -import { fetchUtils, DataProvider, Identifier } from 'ra-core'; +import { + fetchUtils, + DataProvider, + Identifier, + GetListParams, + GetOneParams, + GetManyParams, + GetManyReferenceParams, + UpdateParams, + UpdateManyParams, + CreateParams, + DeleteParams, + DeleteManyParams, +} from 'ra-core'; /** * Maps react-admin queries to a postgrest REST API @@ -174,7 +187,7 @@ const defaultPrimaryKeys = new Map(); export default (apiUrl, httpClient = fetchUtils.fetchJson, defaultListOp = 'eq', primaryKeys: Map = defaultPrimaryKeys): DataProvider => ({ - getList: (resource, params) => { + getList: (resource, params: Partial = {}) => { const primaryKey = getPrimaryKey(resource, primaryKeys); const { page, perPage } = params.pagination; @@ -193,7 +206,8 @@ export default (apiUrl, httpClient = fetchUtils.fetchJson, defaultListOp = 'eq', const options = { headers: new Headers({ Accept: 'application/json', - Prefer: 'count=exact' + Prefer: 'count=exact', + ...(params.meta?.headers || {}), }) }; @@ -220,7 +234,7 @@ export default (apiUrl, httpClient = fetchUtils.fetchJson, defaultListOp = 'eq', }); }, - getOne: (resource, params) => { + getOne: (resource, params: Partial = {}) => { const id = params.id; const primaryKey = getPrimaryKey(resource, primaryKeys); @@ -229,13 +243,16 @@ export default (apiUrl, httpClient = fetchUtils.fetchJson, defaultListOp = 'eq', const url = `${apiUrl}/${resource}?${query}`; return httpClient(url, { - headers: new Headers({ 'accept': 'application/vnd.pgrst.object+json' }), + headers: new Headers({ + 'accept': 'application/vnd.pgrst.object+json', + ...(params.meta?.headers || {}), + }), }).then(({ json }) => ({ data: dataWithId(json, primaryKey), })) }, - getMany: (resource, params) => { + getMany: (resource, params: Partial = {}) => { const ids = params.ids; const primaryKey = getPrimaryKey(resource, primaryKeys); @@ -246,7 +263,7 @@ export default (apiUrl, httpClient = fetchUtils.fetchJson, defaultListOp = 'eq', return httpClient(url).then(({ json }) => ({ data: json.map(data => dataWithId(data, primaryKey)) })); }, - getManyReference: (resource, params) => { + getManyReference: (resource, params: Partial = {}) => { const { page, perPage } = params.pagination; const { field, order } = params.sort; const parsedFilter = parseFilters(params.filter, defaultListOp); @@ -269,7 +286,8 @@ export default (apiUrl, httpClient = fetchUtils.fetchJson, defaultListOp = 'eq', const options = { headers: new Headers({ Accept: 'application/json', - Prefer: 'count=exact' + Prefer: 'count=exact', + ...(params.meta?.headers || {}), }) } @@ -296,7 +314,7 @@ export default (apiUrl, httpClient = fetchUtils.fetchJson, defaultListOp = 'eq', }); }, - update: (resource, params) => { + update: (resource, params: Partial = {}) => { const { id, data } = params; const primaryKey = getPrimaryKey(resource, primaryKeys); @@ -316,13 +334,14 @@ export default (apiUrl, httpClient = fetchUtils.fetchJson, defaultListOp = 'eq', headers: new Headers({ 'Accept': 'application/vnd.pgrst.object+json', 'Prefer': 'return=representation', - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + ...(params.meta?.headers || {}), }), body, }).then(({ json }) => ({ data: dataWithId(json, primaryKey) })); }, - updateMany: (resource, params) => { + updateMany: (resource, params: Partial = {}) => { const ids = params.ids; const primaryKey = getPrimaryKey(resource, primaryKeys); @@ -347,6 +366,7 @@ export default (apiUrl, httpClient = fetchUtils.fetchJson, defaultListOp = 'eq', headers: new Headers({ 'Prefer': 'return=representation', 'Content-Type': 'application/json', + ...(params.meta?.headers || {}), }), body, }).then(({ json }) => ({ @@ -354,7 +374,7 @@ export default (apiUrl, httpClient = fetchUtils.fetchJson, defaultListOp = 'eq', })); }, - create: (resource, params) => { + create: (resource, params: Partial = {}) => { const primaryKey = getPrimaryKey(resource, primaryKeys); const url = `${apiUrl}/${resource}`; @@ -364,7 +384,8 @@ export default (apiUrl, httpClient = fetchUtils.fetchJson, defaultListOp = 'eq', headers: new Headers({ 'Accept': 'application/vnd.pgrst.object+json', 'Prefer': 'return=representation', - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + ...(params.meta?.headers || {}), }), body: JSON.stringify(params.data), }).then(({ json }) => ({ @@ -375,7 +396,7 @@ export default (apiUrl, httpClient = fetchUtils.fetchJson, defaultListOp = 'eq', })); }, - delete: (resource, params) => { + delete: (resource, params: Partial = {}) => { const id = params.id; const primaryKey = getPrimaryKey(resource, primaryKeys); @@ -388,12 +409,13 @@ export default (apiUrl, httpClient = fetchUtils.fetchJson, defaultListOp = 'eq', headers: new Headers({ 'Accept': 'application/vnd.pgrst.object+json', 'Prefer': 'return=representation', - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + ...(params.meta?.headers || {}), }), }).then(({ json }) => ({ data: dataWithId(json, primaryKey) })); }, - deleteMany: (resource, params) => { + deleteMany: (resource, params: Partial = {}) => { const ids = params.ids; const primaryKey = getPrimaryKey(resource, primaryKeys); @@ -405,7 +427,8 @@ export default (apiUrl, httpClient = fetchUtils.fetchJson, defaultListOp = 'eq', method: 'DELETE', headers: new Headers({ 'Prefer': 'return=representation', - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + ...(params.meta?.headers || {}), }), }).then(({ json }) => ({ data: json.map(data => encodeId(data, primaryKey)) })); }, From 69c7c4974eca6adc4bc343b920deee307f4e7a4a Mon Sep 17 00:00:00 2001 From: Raphael Scheible Date: Sat, 8 Apr 2023 01:21:34 +0200 Subject: [PATCH 02/11] add new features --- CHANGELOG.md | 5 ++++- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e1c525..c7b7270 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,10 @@ Find all notable changes of this project in this file. ## unpublished (v2.0.0) -- package updates +- update dependencies +- [#48](https://github.com/raphiniert-com/ra-data-postgrest/issues/48) solved by pull request [#55](https://github.com/raphiniert-com/ra-data-postgrest/pull/55), the create method should return the data returned by postgrest and not the posted data - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek) +- [#41](https://github.com/raphiniert-com/ra-data-postgrest/pull/41), allow columns filtering for getList and getManyReference - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek) +- [#39](https://github.com/raphiniert-com/ra-data-postgrest/pull/39), allow passing extra headers via meta for react-admin hooks - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek) ## v1.2.1 - 2023-04-07 diff --git a/README.md b/README.md index 958759f..1860e65 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,48 @@ const dataProvider = postgrestRestProvider( ); ``` +### Passing extra headers via meta +Postgrest supports calling functions with a single JSON parameter by sending the header Prefer: params=single-object with your request according to its [docs](https://postgrest.org/en/stable/api.html#calling-functions-with-a-single-json-parameter). + +Within the data provider one can add any kind of header to the request while calling react-admin hooks, e.g.: +``` +const [create, { isLoading, error }] = useCreate( + 'rpc/my-function', + { + data: { ... }, + meta: { headers: { Prefer: 'params=single-object' } }, + } +); +``` + +### Vertical filtering +Postgrest supports a feature of [Vertical Filtering (Columns)](https://postgrest.org/en/stable/api.html#vertical-filtering-columns). Within the react-admin hooks this feature can be used as in the following example: +``` +const { data, total, isLoading, error } = useGetList( + 'posts', + { + pagination: { page: 1, perPage: 10 }, + sort: { field: 'published_at', order: 'DESC' } + meta: { columns: ['id', 'title'] } + } +); +``` + +Further, one should be able to leverage this feature to rename columns: +``` +columns: ['id', 'somealias:title'] +``` +, to cast columns: +``` +columns: ['id::text', 'title'] +``` +and even get bits from a json or jsonb column" +``` +columns: ['id', 'json_data->>blood_type', 'json_data->phones'] +``` + +**Note**: currently this feature is limited to `getList` and `getManyReference`. `getOne` and `getMany` is still missing. + ## Developers notes The current development of this library was done with node v19.10 and npm 8.19.3. In this version the unit tests and the development environment should work. From 728627115a064c0911904c5742ced701ef1ed1cd Mon Sep 17 00:00:00 2001 From: Raphael Scheible Date: Sun, 9 Apr 2023 01:12:44 +0200 Subject: [PATCH 03/11] cleanup --- src/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index b711b25..93c35a7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -239,7 +239,6 @@ export default ( }) ); - // TODO: query? const url = `${apiUrl}/${resource}`; return httpClient(url, { @@ -256,7 +255,6 @@ export default ( create: (resource, params) => { const primaryKey = getPrimaryKey(resource, primaryKeys); - // TODO: query? const url = `${apiUrl}/${resource}`; return httpClient(url, { From 7f6a804c5931e367a7e70724dfea614c2bc07cc8 Mon Sep 17 00:00:00 2001 From: Raphael Scheible Date: Sun, 9 Apr 2023 01:12:57 +0200 Subject: [PATCH 04/11] edit description --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1860e65..462aaaa 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,7 @@ and even get bits from a json or jsonb column" columns: ['id', 'json_data->>blood_type', 'json_data->phones'] ``` -**Note**: currently this feature is limited to `getList` and `getManyReference`. `getOne` and `getMany` is still missing. +**Note**: not working for `create` and `updateMany`. ## Developers notes From a7c65ba14d28ef0f4f44eb17379729548d8f368b Mon Sep 17 00:00:00 2001 From: Raphael Scheible Date: Sun, 9 Apr 2023 01:17:46 +0200 Subject: [PATCH 05/11] refresh changelog --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7b7270..df20bcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,12 @@ Find all notable changes of this project in this file. ## unpublished (v2.0.0) -- update dependencies +- updated dependencies +- updated `urlBuilder` and integrated URL encoding - [#48](https://github.com/raphiniert-com/ra-data-postgrest/issues/48) solved by pull request [#55](https://github.com/raphiniert-com/ra-data-postgrest/pull/55), the create method should return the data returned by postgrest and not the posted data - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek) - [#41](https://github.com/raphiniert-com/ra-data-postgrest/pull/41), allow columns filtering for getList and getManyReference - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek) -- [#39](https://github.com/raphiniert-com/ra-data-postgrest/pull/39), allow passing extra headers via meta for react-admin hooks - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek) +- added support of [#41](https://github.com/raphiniert-com/ra-data-postgrest/pull/41) for other functions, but `create` and `updateMany` + ## v1.2.1 - 2023-04-07 From 30468df571ed5c554da00781ca3e83ba4c3d5b74 Mon Sep 17 00:00:00 2001 From: Raphael Scheible Date: Sun, 9 Apr 2023 01:24:00 +0200 Subject: [PATCH 06/11] make sort param optional in getList --- src/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 93c35a7..d876f25 100644 --- a/src/index.ts +++ b/src/index.ts @@ -62,17 +62,20 @@ export default ( const primaryKey = getPrimaryKey(resource, primaryKeys); const { page, perPage } = params.pagination; - const { field, order } = params.sort; + const { field, order } = params.sort || {}; const { filter, select } = parseFilters(params, defaultListOp); let query = { - order: getOrderBy(field, order, primaryKey), offset: String((page - 1) * perPage), limit: String(perPage), // append filters ...filter }; + if (field) { + query.order = getOrderBy(field, order, primaryKey); + } + if (select) { query.select = select; } From 1c92c3349a5f5b4302427455e337665e4685ad48 Mon Sep 17 00:00:00 2001 From: Raphael Scheible Date: Sun, 9 Apr 2023 01:24:42 +0200 Subject: [PATCH 07/11] format code --- src/index.ts | 6 +++--- src/urlBuilder.ts | 31 +++++++++++++++++-------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/index.ts b/src/index.ts index d876f25..fc1c394 100644 --- a/src/index.ts +++ b/src/index.ts @@ -69,7 +69,7 @@ export default ( offset: String((page - 1) * perPage), limit: String(perPage), // append filters - ...filter + ...filter, }; if (field) { @@ -130,7 +130,7 @@ export default ( const primaryKey = getPrimaryKey(resource, primaryKeys); const query = getQuery(primaryKey, ids, resource, params.meta); - const url = `${apiUrl}/${resource}?${qs.stringify(query)}`; + const url = `${apiUrl}/${resource}?${qs.stringify(query)}`; return httpClient(url).then(({ json }) => ({ data: json.map(data => dataWithId(data, primaryKey)), @@ -150,7 +150,7 @@ export default ( order: getOrderBy(field, order, primaryKey), offset: String((page - 1) * perPage), limit: String(perPage), - ...filter + ...filter, } : { order: getOrderBy(field, order, primaryKey), diff --git a/src/urlBuilder.ts b/src/urlBuilder.ts index e4dea34..470703a 100644 --- a/src/urlBuilder.ts +++ b/src/urlBuilder.ts @@ -47,14 +47,14 @@ const postgrestOperators = [ type ParsedFiltersResult = { filter: any; select: any; -} +}; export type PostgRestOperator = (typeof postgrestOperators)[number]; export const parseFilters = ( params: any, defaultListOp: PostgRestOperator -) : Partial => { +): Partial => { const { filter, meta = {} } = params; let result: Partial = {}; @@ -90,7 +90,10 @@ export const parseFilters = ( } else { if (!Array.isArray(result[splitKey[0]])) { // second operator, we transform to an array - result.filter[splitKey[0]] = [result.filter[splitKey[0]], op]; + result.filter[splitKey[0]] = [ + result.filter[splitKey[0]], + op, + ]; } else { // third and subsequent, we add to array result.filter[splitKey[0]].push(op); @@ -171,12 +174,11 @@ export const getQuery = ( if (isCompoundKey(primaryKey)) { result = { or: `(${ids.map(id => { - const primaryKeyParams = decodeId(id, primaryKey); - return `and(${primaryKey - .map((key, i) => `${key}.eq.${primaryKeyParams[i]}`) - .join(',')})`; - }) - })` + const primaryKeyParams = decodeId(id, primaryKey); + return `and(${primaryKey + .map((key, i) => `${key}.eq.${primaryKeyParams[i]}`) + .join(',')})`; + })})`, }; } else { result = { @@ -192,19 +194,20 @@ export const getQuery = ( if (resource.startsWith('rpc/')) { result = {}; primaryKey.map( - (key: string, i: any) => result[key] = `${primaryKeyParams[i]}` - ); + (key: string, i: any) => + (result[key] = `${primaryKeyParams[i]}`) + ); } else { result = { and: `(${primaryKey.map( (key: string, i: any) => `${key}.eq.${primaryKeyParams[i]}` - )})` + )})`, }; } } else { - result = { - [primaryKey[0]]: `eq.${id}` + result = { + [primaryKey[0]]: `eq.${id}`, }; } } From 66de8e82c3be43ca64eb228d9532a4a1b0f80dc4 Mon Sep 17 00:00:00 2001 From: Raphael Scheible Date: Sun, 9 Apr 2023 01:35:48 +0200 Subject: [PATCH 08/11] enable passing of extra headers via meta --- src/index.ts | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/index.ts b/src/index.ts index fc1c394..099fbad 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,16 @@ -import { fetchUtils, DataProvider } from 'ra-core'; +import { + fetchUtils, + DataProvider, + GetListParams, + GetOneParams, + GetManyParams, + GetManyReferenceParams, + UpdateParams, + UpdateManyParams, + CreateParams, + DeleteParams, + DeleteManyParams, +} from 'ra-core'; import { PrimaryKey, PostgRestOperator, @@ -58,7 +70,7 @@ export default ( defaultListOp: PostgRestOperator = 'eq', primaryKeys: Map = defaultPrimaryKeys ): DataProvider => ({ - getList: (resource, params) => { + getList: (resource, params: Partial = {}) => { const primaryKey = getPrimaryKey(resource, primaryKeys); const { page, perPage } = params.pagination; @@ -85,6 +97,7 @@ export default ( headers: new Headers({ Accept: 'application/json', Prefer: 'count=exact', + ...(params.meta?.headers || {}), }), }; @@ -108,7 +121,7 @@ export default ( }); }, - getOne: (resource, params) => { + getOne: (resource, params: Partial = {}) => { const { id, meta } = params; const primaryKey = getPrimaryKey(resource, primaryKeys); @@ -119,13 +132,14 @@ export default ( return httpClient(url, { headers: new Headers({ accept: 'application/vnd.pgrst.object+json', + ...(params.meta?.headers || {}), }), }).then(({ json }) => ({ data: dataWithId(json, primaryKey), })); }, - getMany: (resource, params) => { + getMany: (resource, params: Partial = {}) => { const ids = params.ids; const primaryKey = getPrimaryKey(resource, primaryKeys); @@ -137,7 +151,10 @@ export default ( })); }, - getManyReference: (resource, params) => { + getManyReference: ( + resource, + params: Partial = {} + ) => { const { page, perPage } = params.pagination; const { field, order } = params.sort; @@ -168,6 +185,7 @@ export default ( headers: new Headers({ Accept: 'application/json', Prefer: 'count=exact', + ...(params.meta?.headers || {}), }), }; @@ -191,7 +209,7 @@ export default ( }); }, - update: (resource, params) => { + update: (resource, params: Partial = {}) => { const { id, data, meta } = params; const primaryKey = getPrimaryKey(resource, primaryKeys); @@ -212,12 +230,13 @@ export default ( Accept: 'application/vnd.pgrst.object+json', Prefer: 'return=representation', 'Content-Type': 'application/json', + ...(params.meta?.headers || {}), }), body, }).then(({ json }) => ({ data: dataWithId(json, primaryKey) })); }, - updateMany: (resource, params) => { + updateMany: (resource, params: Partial = {}) => { const ids = params.ids; const primaryKey = getPrimaryKey(resource, primaryKeys); @@ -249,6 +268,7 @@ export default ( headers: new Headers({ Prefer: 'return=representation', 'Content-Type': 'application/json', + ...(params.meta?.headers || {}), }), body, }).then(({ json }) => ({ @@ -256,7 +276,7 @@ export default ( })); }, - create: (resource, params) => { + create: (resource, params: Partial = {}) => { const primaryKey = getPrimaryKey(resource, primaryKeys); const url = `${apiUrl}/${resource}`; @@ -266,6 +286,7 @@ export default ( Accept: 'application/vnd.pgrst.object+json', Prefer: 'return=representation', 'Content-Type': 'application/json', + ...(params.meta?.headers || {}), }), body: JSON.stringify(params.data), }).then(({ json }) => ({ @@ -276,7 +297,7 @@ export default ( })); }, - delete: (resource, params) => { + delete: (resource, params: Partial = {}) => { const { id, meta } = params; const primaryKey = getPrimaryKey(resource, primaryKeys); @@ -290,11 +311,12 @@ export default ( Accept: 'application/vnd.pgrst.object+json', Prefer: 'return=representation', 'Content-Type': 'application/json', + ...(params.meta?.headers || {}), }), }).then(({ json }) => ({ data: dataWithId(json, primaryKey) })); }, - deleteMany: (resource, params) => { + deleteMany: (resource, params: Partial = {}) => { const { ids, meta } = params; const primaryKey = getPrimaryKey(resource, primaryKeys); @@ -307,6 +329,7 @@ export default ( headers: new Headers({ Prefer: 'return=representation', 'Content-Type': 'application/json', + ...(params.meta?.headers || {}), }), }).then(({ json }) => ({ data: json.map(data => encodeId(data, primaryKey)), From f88d5ccb00d0fc5ec7ac7db0c371f79b1b5a47d7 Mon Sep 17 00:00:00 2001 From: Raphael Scheible Date: Sun, 9 Apr 2023 01:40:05 +0200 Subject: [PATCH 09/11] add new features --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df20bcd..3b2070a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,16 @@ Find all notable changes of this project in this file. ## unpublished (v2.0.0) +### Improvements - updated dependencies - updated `urlBuilder` and integrated URL encoding + +### New feature - [#48](https://github.com/raphiniert-com/ra-data-postgrest/issues/48) solved by pull request [#55](https://github.com/raphiniert-com/ra-data-postgrest/pull/55), the create method should return the data returned by postgrest and not the posted data - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek) +- [#39](https://github.com/raphiniert-com/ra-data-postgrest/pull/39), allow passing extra headers via meta for react-admin hooks - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek) - [#41](https://github.com/raphiniert-com/ra-data-postgrest/pull/41), allow columns filtering for getList and getManyReference - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek) - added support of [#41](https://github.com/raphiniert-com/ra-data-postgrest/pull/41) for other functions, but `create` and `updateMany` - +- [#38](https://github.com/raphiniert-com/ra-data-postgrest/pull/38), Let the sort param in getList be optional - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek) ## v1.2.1 - 2023-04-07 From 2c11904613a37aecdaf3feaed47691bcb3ab211c Mon Sep 17 00:00:00 2001 From: Raphael Scheible Date: Sun, 9 Apr 2023 02:05:56 +0200 Subject: [PATCH 10/11] adjusted to new qs lib --- tests/dataProvider/basic.test.ts | 3 ++- tests/dataProvider/getList.test.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/dataProvider/basic.test.ts b/tests/dataProvider/basic.test.ts index 57fc62d..1dde154 100644 --- a/tests/dataProvider/basic.test.ts +++ b/tests/dataProvider/basic.test.ts @@ -1,3 +1,4 @@ +import qs from 'querystring'; import { enc } from '../urlBuilder/helper'; import { makeTestFromCase, Case } from './helper'; @@ -12,7 +13,7 @@ const cases: Case[] = [ filter: {}, meta: {}, }, - expectedUrl: '/posts?order=title.desc&offset=0&limit=10', + expectedUrl: '/posts?offset=0&limit=10&order=title.desc', expectedOptions: { headers: { accept: 'application/json', diff --git a/tests/dataProvider/getList.test.ts b/tests/dataProvider/getList.test.ts index 58c0832..d67ba53 100644 --- a/tests/dataProvider/getList.test.ts +++ b/tests/dataProvider/getList.test.ts @@ -19,7 +19,7 @@ describe('getList specific', () => { }, filter: {}, }, - expectedUrl: `/posts?order=id.asc&offset=0&limit=10`, + expectedUrl: `/posts?offset=0&limit=10&order=id.asc`, expectedOptions: { headers: { accept: 'application/json', From 2877503d3169ec203b1f5ffa099756f36bf27a36 Mon Sep 17 00:00:00 2001 From: Raphael Scheible Date: Sun, 9 Apr 2023 02:06:24 +0200 Subject: [PATCH 11/11] cleanup --- tests/dataProvider/basic.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/dataProvider/basic.test.ts b/tests/dataProvider/basic.test.ts index 1dde154..40d7936 100644 --- a/tests/dataProvider/basic.test.ts +++ b/tests/dataProvider/basic.test.ts @@ -1,4 +1,3 @@ -import qs from 'querystring'; import { enc } from '../urlBuilder/helper'; import { makeTestFromCase, Case } from './helper';