@raphiniert/ra-data-postgrest 2.0.0-alpha.4 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,213 +1,232 @@
1
- # Change Log
2
-
3
- Find all notable changes of this project in this file.
4
-
5
- ## v2.0.0-alpha.4 - 2023-10-23
6
- ### Improvements
7
- - updated dependencies
8
-
9
- ### New feature
10
- - [#100](https://github.com/raphiniert-com/ra-data-postgrest/pull/100) support "meta.columns" on all code paths (useful when the user does not have permissions on all the columns in which case doing select=* gives permissions errors) - @[ruslantalpa](https://github.com/ruslantalpa)
11
-
12
- ### Fixes
13
- - [#50](https://github.com/raphiniert-com/ra-data-postgrest/issues/50) and [#88](https://github.com/raphiniert-com/ra-data-postgrest/issues/88) solved by [#100](https://github.com/raphiniert-com/ra-data-postgrest/pull/100) including other fixes - @[ruslantalpa](https://github.com/ruslantalpa)
14
-
15
-
16
- ## v2.0.0-alpha.3 - 2023-06-16
17
- ### Improvements
18
- - updated dependencies
19
-
20
- ### New feature
21
- - [#82](https://github.com/raphiniert-com/ra-data-postgrest/pull/82), add logical operator filter parsing - @[jordiyapz](https://github.com/jordiyapz)
22
-
23
- ### Fixes
24
- - [#81](https://github.com/raphiniert-com/ra-data-postgrest/pull/81), use {} with cs and cd operators url - @[YannBeauxis](https://github.com/YannBeauxis)
25
-
26
- ### Breaking changes
27
- - Changed from from regular parameters to instantiate the dataProvider to a configuration interface/class. Thus, in future initalize the dataProvider by creating a structure which implements the interface:
28
-
29
- ```jsx
30
- import { fetchUtils } from 'react-admin';
31
- import postgrestRestProvider,
32
- { IDataProviderConfig,
33
- defaultPrimaryKeys,
34
- defaultSchema } from '@raphiniert/ra-data-postgrest';
35
-
36
- const config: IDataProviderConfig = {
37
- apiUrl: 'http://path.to.my.api/',
38
- httpClient: fetchUtils.fetchJson,
39
- defaultListOp: 'eq',
40
- primaryKeys: defaultPrimaryKeys,
41
- schema: defaultSchema
42
- }
43
-
44
- dp = postgrestRestProvider(config);
45
- ```
46
-
47
- ## v2.0.0-alpha.2 - 2023-04-24
48
- ### Improvements
49
- - updated dependencies
50
-
51
- ### New feature
52
- - [#49](https://github.com/raphiniert-com/ra-data-postgrest/issues/49), custom schema name can be used
53
-
54
- ## v2.0.0-alpha.1 - 2023-04-09
55
- ### Improvements
56
- - updated dependencies
57
- - updated `urlBuilder` and integrated URL encoding
58
-
59
- ### New feature
60
- - [#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)
61
- - [#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)
62
- - [#41](https://github.com/raphiniert-com/ra-data-postgrest/pull/41), allow columns filtering for getList and getManyReference - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
63
- - added support of [#41](https://github.com/raphiniert-com/ra-data-postgrest/pull/41) for other functions, but `create` and `updateMany`
64
- - [#38](https://github.com/raphiniert-com/ra-data-postgrest/pull/38), Let the sort param in getList be optional - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
65
-
66
-
67
- ## v1.2.1 - 2023-04-07
68
- - small fix in condition
69
- - fixed package name
70
-
71
- ## v2.0.0-alpha.0 - 2022-11-23
72
-
73
- - [#42](https://github.com/raphiniert-com/ra-data-postgrest/issues/42), started adding some unit tests - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
74
- - dropped authProvider
75
- - code cleanup & restructuring
76
- - minor bugfixes - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
77
- - added some notes to README.md
78
-
79
- ### Breaking changes
80
-
81
- - dropped authProvider as this should rather be an own package in case of a generic piece of software or application specific.
82
-
83
- ## v1.2.0 - 2022-08-23
84
-
85
- - [#33](https://github.com/raphiniert-com/ra-data-postgrest/pull/33), adding dependabot - @[promitheus7](https://github.com/promitheus7)
86
- - [#30](https://github.com/raphiniert-com/ra-data-postgrest/pull/30) and [#33](https://github.com/raphiniert-com/ra-data-postgrest/pull/33), updated dependency to compatible starting from `ra-core` 4.1.x - @[corrideat](https://github.com/corrideat), @[promitheus7](https://github.com/promitheus7)
87
-
88
- ## v1.1.9 - 2022-08-23
89
-
90
- - [#30](https://github.com/raphiniert-com/ra-data-postgrest/pull/30), updated ts and modified code, such that some package dependencies became unrequired - @[corrideat](https://github.com/corrideat)
91
-
92
- ## v1.1.8 - 2022-01-07
93
-
94
- - required re-release as I missed to transpile all and upload the features of 1.1.7 to npm.
95
-
96
- ## v1.1.7 - 2022-01-07
97
-
98
- ### Fixes
99
-
100
- - fixed bad behaivor with compound keys while using field named `id` [issue #27](https://github.com/raphiniert-com/ra-data-postgrest/issues/27) and [issue #19](https://github.com/raphiniert-com/ra-data-postgrest/pull/19) - @[kenfehling](https://github.com/kenfehling)
101
-
102
- ### New feature
103
-
104
- - [#26](https://github.com/raphiniert-com/ra-data-postgrest/pull/26), added rpc filter support, which is explained [here](https://github.com/raphiniert-com/ra-data-postgrest#special-filter-feature-rpc-functions) - @[TheRealAstroboy](https://github.com/TheRealAstroboy)
105
-
106
- ## v1.1.6 - 2021-01-16
107
-
108
- ### Fixes
109
-
110
- - [#24](https://github.com/raphiniert-com/ra-data-postgrest/pull/24), fixed eq. prefix for non-compound keys [issue #23](https://github.com/raphiniert-com/ra-data-postgrest/issues/23) - @[andymed-jlp](https://github.com/andymed-jlp)
111
-
112
- ## v1.1.5 - 2021-01-16
113
-
114
- ### Fixes
115
-
116
- - fixed query string generation of rpc endpoints [issue #22](https://github.com/raphiniert-com/ra-data-postgrest/issues/22)
117
-
118
- ### Breaking changes
119
-
120
- - Support was dropped for generating the query string given many ids in case of an rpc endpoint. If your application has some psql functions which parse the standard input, I recommend to rework your db design. If this change causes strong damage to your application, please contact me in order to find a proper generic solution. Query strings of single rpc calls now drop the operator (`eq.`) and are generated properly.
121
-
122
- ## v1.1.4 - 2021-01-16
123
-
124
- - deployment error
125
-
126
- ## v1.1.3 - 2020-11-30
127
-
128
- ### Fixes
129
-
130
- - [#20](https://github.com/raphiniert-com/ra-data-postgrest/pull/20), fixed small bug in update - @[mkkane](https://github.com/mkkane)
131
- - removed console log
132
-
133
- ## v1.1.2 - 2020-10-05
134
-
135
- ### Fixes
136
-
137
- - fixed the last fix of getMany and getManyReferecnce for compound keys :)
138
-
139
- ## v1.1.1 - 2020-09-28
140
-
141
- ### Fixes
142
-
143
- - fixed getMany and getManyReferecnce for compound keys
144
-
145
- ## v1.1.0 - 2020-09-16
146
-
147
- ### Fixes
148
-
149
- - removed requirement to define order key in react admin, when using compound keys: default was `id`, now it's the compound key
150
-
151
- ### Breaking changes
152
-
153
- - refactored compound primary keys:
154
- For single custom keys wrap an array as follows:
155
- ```jsx
156
- const dataProvider = postgrestRestProvider(
157
- API_URL,
158
- fetchUtils.fetchJson,
159
- 'eq',
160
- new Map([
161
- ['some_table', ['custom_id']], // <- instead of ['some_table','custom_id']
162
- ['another_table', ['first_column', 'second_column']],
163
- ])
164
- );
165
- ```
166
-
167
- ## v1.0.7 - 2020-08-23
168
-
169
- ### New feature
170
-
171
- - [#14](https://github.com/raphiniert-com/ra-data-postgrest/pull/14), added compound primary keys (see [README.md](https://github.com/raphiniert-com/ra-data-postgrest/blob/master/README.md#compound-primary-keys)) - @[programmarchy](https://github.com/programmarchy)
172
-
173
- ### Maintenance
174
-
175
- - `import React from 'react';` -> `import * as React from 'react';`
176
- - Some minor code cleanup
177
-
178
- ## v1.0.6 - 2020-06-15
179
-
180
- ### Fixes
181
-
182
- - Fixed wrong support statement concerning [postgrest starter kit](https://github.com/subzerocloud/postgrest-starter-kit) in readme
183
-
184
- ## v1.0.5 - 2020-06-15
185
-
186
- ### Fixes
187
-
188
- - [#13](https://github.com/raphiniert-com/ra-data-postgrest/pull/13), Remove console.log - @[jpagex](https://github.com/jpagex)
189
- - [#12](https://github.com/raphiniert-com/ra-data-postgrest/pull/12), Fixed limit parameter - @[jpagex](https://github.com/jpagex)
190
-
191
- ## v1.0.4 - 2020-06-08
192
-
193
- ### Fixes
194
-
195
- - Fixed missing js files in npm package [#8](https://github.com/raphiniert-com/ra-data-postgrest/issues/8)
196
- - [#9](https://github.com/raphiniert-com/ra-data-postgrest/pull/9), Fixed typo in readme - @[seclace](https://github.com/seclace)
197
-
198
- ## v1.0.3 - 2020-05-17
199
-
200
- ### Fixes
201
-
202
- - Fixed bug when multidelete - @[colonist4096](https://github.com/colonist4096)
203
- - [#5](https://github.com/raphiniert-com/ra-data-postgrest/pull/6), Fixed bug while using multiple filters on the same attribute - @[olivierdalang](https://github.com/olivierdalang)
204
-
205
- ## v1.0.2 - 2020-03-10
206
-
207
- ### Fixes
208
-
209
- - [#4](https://github.com/raphiniert-com/ra-data-postgrest/pull/4), Fixed bug while using ReferenceField with UUID - @[xero88](https://github.com/xero88)
210
-
211
- ## v1.0.1 - 2020-02-01
212
-
213
- - initial release
1
+ # Change Log
2
+
3
+ Find all notable changes of this project in this file.
4
+
5
+ ## v2.1.0 - 2024-02-27
6
+ ### Improvements
7
+ - updated dependencies
8
+
9
+ ### Fixes
10
+ - [#123](https://github.com/raphiniert-com/ra-data-postgrest/pull/123) Modifying update call to only update changed fields @[kav](https://github.com/kav)
11
+
12
+
13
+ ## v2.0.0 - 2023-12-29
14
+ ### Improvements
15
+ - updated dependencies
16
+
17
+ ### Fixes
18
+ - [#113](https://github.com/raphiniert-com/ra-data-postgrest/pull/113) remove {} value wrapping for cs/cd @[ruslantalpa](https://github.com/ruslantalpa)
19
+
20
+ ### Breaking changes
21
+ - the fix in this version might break old versions, as the {} are removed. Thus, one needs to manually add the {} for cs/cd.
22
+
23
+
24
+ ## v2.0.0-alpha.4 - 2023-10-23
25
+ ### Improvements
26
+ - updated dependencies
27
+
28
+ ### New feature
29
+ - [#100](https://github.com/raphiniert-com/ra-data-postgrest/pull/100) support "meta.columns" on all code paths (useful when the user does not have permissions on all the columns in which case doing select=* gives permissions errors) - @[ruslantalpa](https://github.com/ruslantalpa)
30
+
31
+ ### Fixes
32
+ - [#50](https://github.com/raphiniert-com/ra-data-postgrest/issues/50) and [#88](https://github.com/raphiniert-com/ra-data-postgrest/issues/88) solved by [#100](https://github.com/raphiniert-com/ra-data-postgrest/pull/100) including other fixes - @[ruslantalpa](https://github.com/ruslantalpa)
33
+
34
+
35
+ ## v2.0.0-alpha.3 - 2023-06-16
36
+ ### Improvements
37
+ - updated dependencies
38
+
39
+ ### New feature
40
+ - [#82](https://github.com/raphiniert-com/ra-data-postgrest/pull/82), add logical operator filter parsing - @[jordiyapz](https://github.com/jordiyapz)
41
+
42
+ ### Fixes
43
+ - [#81](https://github.com/raphiniert-com/ra-data-postgrest/pull/81), use {} with cs and cd operators url - @[YannBeauxis](https://github.com/YannBeauxis)
44
+
45
+ ### Breaking changes
46
+ - Changed from from regular parameters to instantiate the dataProvider to a configuration interface/class. Thus, in future initalize the dataProvider by creating a structure which implements the interface:
47
+
48
+ ```jsx
49
+ import { fetchUtils } from 'react-admin';
50
+ import postgrestRestProvider,
51
+ { IDataProviderConfig,
52
+ defaultPrimaryKeys,
53
+ defaultSchema } from '@raphiniert/ra-data-postgrest';
54
+
55
+ const config: IDataProviderConfig = {
56
+ apiUrl: 'http://path.to.my.api/',
57
+ httpClient: fetchUtils.fetchJson,
58
+ defaultListOp: 'eq',
59
+ primaryKeys: defaultPrimaryKeys,
60
+ schema: defaultSchema
61
+ }
62
+
63
+ dp = postgrestRestProvider(config);
64
+ ```
65
+
66
+ ## v2.0.0-alpha.2 - 2023-04-24
67
+ ### Improvements
68
+ - updated dependencies
69
+
70
+ ### New feature
71
+ - [#49](https://github.com/raphiniert-com/ra-data-postgrest/issues/49), custom schema name can be used
72
+
73
+ ## v2.0.0-alpha.1 - 2023-04-09
74
+ ### Improvements
75
+ - updated dependencies
76
+ - updated `urlBuilder` and integrated URL encoding
77
+
78
+ ### New feature
79
+ - [#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)
80
+ - [#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)
81
+ - [#41](https://github.com/raphiniert-com/ra-data-postgrest/pull/41), allow columns filtering for getList and getManyReference - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
82
+ - added support of [#41](https://github.com/raphiniert-com/ra-data-postgrest/pull/41) for other functions, but `create` and `updateMany`
83
+ - [#38](https://github.com/raphiniert-com/ra-data-postgrest/pull/38), Let the sort param in getList be optional - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
84
+
85
+
86
+ ## v1.2.1 - 2023-04-07
87
+ - small fix in condition
88
+ - fixed package name
89
+
90
+ ## v2.0.0-alpha.0 - 2022-11-23
91
+
92
+ - [#42](https://github.com/raphiniert-com/ra-data-postgrest/issues/42), started adding some unit tests - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
93
+ - dropped authProvider
94
+ - code cleanup & restructuring
95
+ - minor bugfixes - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
96
+ - added some notes to README.md
97
+
98
+ ### Breaking changes
99
+
100
+ - dropped authProvider as this should rather be an own package in case of a generic piece of software or application specific.
101
+
102
+ ## v1.2.0 - 2022-08-23
103
+
104
+ - [#33](https://github.com/raphiniert-com/ra-data-postgrest/pull/33), adding dependabot - @[promitheus7](https://github.com/promitheus7)
105
+ - [#30](https://github.com/raphiniert-com/ra-data-postgrest/pull/30) and [#33](https://github.com/raphiniert-com/ra-data-postgrest/pull/33), updated dependency to compatible starting from `ra-core` 4.1.x - @[corrideat](https://github.com/corrideat), @[promitheus7](https://github.com/promitheus7)
106
+
107
+ ## v1.1.9 - 2022-08-23
108
+
109
+ - [#30](https://github.com/raphiniert-com/ra-data-postgrest/pull/30), updated ts and modified code, such that some package dependencies became unrequired - @[corrideat](https://github.com/corrideat)
110
+
111
+ ## v1.1.8 - 2022-01-07
112
+
113
+ - required re-release as I missed to transpile all and upload the features of 1.1.7 to npm.
114
+
115
+ ## v1.1.7 - 2022-01-07
116
+
117
+ ### Fixes
118
+
119
+ - fixed bad behaivor with compound keys while using field named `id` [issue #27](https://github.com/raphiniert-com/ra-data-postgrest/issues/27) and [issue #19](https://github.com/raphiniert-com/ra-data-postgrest/pull/19) - @[kenfehling](https://github.com/kenfehling)
120
+
121
+ ### New feature
122
+
123
+ - [#26](https://github.com/raphiniert-com/ra-data-postgrest/pull/26), added rpc filter support, which is explained [here](https://github.com/raphiniert-com/ra-data-postgrest#special-filter-feature-rpc-functions) - @[TheRealAstroboy](https://github.com/TheRealAstroboy)
124
+
125
+ ## v1.1.6 - 2021-01-16
126
+
127
+ ### Fixes
128
+
129
+ - [#24](https://github.com/raphiniert-com/ra-data-postgrest/pull/24), fixed eq. prefix for non-compound keys [issue #23](https://github.com/raphiniert-com/ra-data-postgrest/issues/23) - @[andymed-jlp](https://github.com/andymed-jlp)
130
+
131
+ ## v1.1.5 - 2021-01-16
132
+
133
+ ### Fixes
134
+
135
+ - fixed query string generation of rpc endpoints [issue #22](https://github.com/raphiniert-com/ra-data-postgrest/issues/22)
136
+
137
+ ### Breaking changes
138
+
139
+ - Support was dropped for generating the query string given many ids in case of an rpc endpoint. If your application has some psql functions which parse the standard input, I recommend to rework your db design. If this change causes strong damage to your application, please contact me in order to find a proper generic solution. Query strings of single rpc calls now drop the operator (`eq.`) and are generated properly.
140
+
141
+ ## v1.1.4 - 2021-01-16
142
+
143
+ - deployment error
144
+
145
+ ## v1.1.3 - 2020-11-30
146
+
147
+ ### Fixes
148
+
149
+ - [#20](https://github.com/raphiniert-com/ra-data-postgrest/pull/20), fixed small bug in update - @[mkkane](https://github.com/mkkane)
150
+ - removed console log
151
+
152
+ ## v1.1.2 - 2020-10-05
153
+
154
+ ### Fixes
155
+
156
+ - fixed the last fix of getMany and getManyReferecnce for compound keys :)
157
+
158
+ ## v1.1.1 - 2020-09-28
159
+
160
+ ### Fixes
161
+
162
+ - fixed getMany and getManyReferecnce for compound keys
163
+
164
+ ## v1.1.0 - 2020-09-16
165
+
166
+ ### Fixes
167
+
168
+ - removed requirement to define order key in react admin, when using compound keys: default was `id`, now it's the compound key
169
+
170
+ ### Breaking changes
171
+
172
+ - refactored compound primary keys:
173
+ For single custom keys wrap an array as follows:
174
+ ```jsx
175
+ const dataProvider = postgrestRestProvider(
176
+ API_URL,
177
+ fetchUtils.fetchJson,
178
+ 'eq',
179
+ new Map([
180
+ ['some_table', ['custom_id']], // <- instead of ['some_table','custom_id']
181
+ ['another_table', ['first_column', 'second_column']],
182
+ ])
183
+ );
184
+ ```
185
+
186
+ ## v1.0.7 - 2020-08-23
187
+
188
+ ### New feature
189
+
190
+ - [#14](https://github.com/raphiniert-com/ra-data-postgrest/pull/14), added compound primary keys (see [README.md](https://github.com/raphiniert-com/ra-data-postgrest/blob/master/README.md#compound-primary-keys)) - @[programmarchy](https://github.com/programmarchy)
191
+
192
+ ### Maintenance
193
+
194
+ - `import React from 'react';` -> `import * as React from 'react';`
195
+ - Some minor code cleanup
196
+
197
+ ## v1.0.6 - 2020-06-15
198
+
199
+ ### Fixes
200
+
201
+ - Fixed wrong support statement concerning [postgrest starter kit](https://github.com/subzerocloud/postgrest-starter-kit) in readme
202
+
203
+ ## v1.0.5 - 2020-06-15
204
+
205
+ ### Fixes
206
+
207
+ - [#13](https://github.com/raphiniert-com/ra-data-postgrest/pull/13), Remove console.log - @[jpagex](https://github.com/jpagex)
208
+ - [#12](https://github.com/raphiniert-com/ra-data-postgrest/pull/12), Fixed limit parameter - @[jpagex](https://github.com/jpagex)
209
+
210
+ ## v1.0.4 - 2020-06-08
211
+
212
+ ### Fixes
213
+
214
+ - Fixed missing js files in npm package [#8](https://github.com/raphiniert-com/ra-data-postgrest/issues/8)
215
+ - [#9](https://github.com/raphiniert-com/ra-data-postgrest/pull/9), Fixed typo in readme - @[seclace](https://github.com/seclace)
216
+
217
+ ## v1.0.3 - 2020-05-17
218
+
219
+ ### Fixes
220
+
221
+ - Fixed bug when multidelete - @[colonist4096](https://github.com/colonist4096)
222
+ - [#5](https://github.com/raphiniert-com/ra-data-postgrest/pull/6), Fixed bug while using multiple filters on the same attribute - @[olivierdalang](https://github.com/olivierdalang)
223
+
224
+ ## v1.0.2 - 2020-03-10
225
+
226
+ ### Fixes
227
+
228
+ - [#4](https://github.com/raphiniert-com/ra-data-postgrest/pull/4), Fixed bug while using ReferenceField with UUID - @[xero88](https://github.com/xero88)
229
+
230
+ ## v1.0.1 - 2020-02-01
231
+
232
+ - initial release
package/README.md CHANGED
@@ -172,7 +172,7 @@ PostgREST allows to [select and switch the database schema](https://postgrest.or
172
172
  ```jsx
173
173
  const config: IDataProviderConfig = {
174
174
  ...
175
- schema: localStorage.getItem("schema") || "api",
175
+ schema: () => localStorage.getItem("schema") || "api",
176
176
  ...
177
177
  }
178
178
 
package/esm/index.js CHANGED
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { getPrimaryKey, parseFilters, getOrderBy, dataWithVirtualId, dataWithoutVirtualId, removePrimaryKey, getQuery, encodeId, } from './urlBuilder';
13
13
  import qs from 'qs';
14
+ import isEqual from 'lodash/isEqual';
14
15
  export var defaultPrimaryKeys = new Map();
15
16
  export var defaultSchema = function () { return ''; };
16
17
  var useCustomSchema = function (schema, metaSchema, method) {
@@ -58,7 +59,7 @@ export default (function (config) { return ({
58
59
  return config.httpClient(url, options).then(function (_a) {
59
60
  var headers = _a.headers, json = _a.json;
60
61
  if (!headers.has('content-range')) {
61
- throw new Error("The Content-Range header is missing in the HTTP Response. The postgREST data provider expects \n responses for lists of resources to contain this header with the total number of results to build \n the pagination. If you are using CORS, did you declare Content-Range in the Access-Control-Expose-Headers header?");
62
+ throw new Error("The Content-Range header is missing in the HTTP Response. The postgREST data provider expects\n responses for lists of resources to contain this header with the total number of results to build\n the pagination. If you are using CORS, did you declare Content-Range in the Access-Control-Expose-Headers header?");
62
63
  }
63
64
  return {
64
65
  data: json.map(function (obj) { return dataWithVirtualId(obj, primaryKey); }),
@@ -126,7 +127,7 @@ export default (function (config) { return ({
126
127
  return config.httpClient(url, options).then(function (_a) {
127
128
  var headers = _a.headers, json = _a.json;
128
129
  if (!headers.has('content-range')) {
129
- throw new Error("The Content-Range header is missing in the HTTP Response. The postgREST data provider expects \n responses for lists of resources to contain this header with the total number of results to build \n the pagination. If you are using CORS, did you declare Content-Range in the Access-Control-Expose-Headers header?");
130
+ throw new Error("The Content-Range header is missing in the HTTP Response. The postgREST data provider expects\n responses for lists of resources to contain this header with the total number of results to build\n the pagination. If you are using CORS, did you declare Content-Range in the Access-Control-Expose-Headers header?");
130
131
  }
131
132
  return {
132
133
  data: json.map(function (data) { return dataWithVirtualId(data, primaryKey); }),
@@ -137,12 +138,13 @@ export default (function (config) { return ({
137
138
  update: function (resource, params) {
138
139
  var _a, _b;
139
140
  if (params === void 0) { params = {}; }
140
- var id = params.id, data = params.data, meta = params.meta;
141
+ var id = params.id, data = params.data, meta = params.meta, previousData = params.previousData;
141
142
  var primaryKey = getPrimaryKey(resource, config.primaryKeys);
142
143
  var query = getQuery(primaryKey, id, resource, meta);
143
144
  var url = "".concat(config.apiUrl, "/").concat(resource, "?").concat(qs.stringify(query));
145
+ var changedData = getChanges(data, previousData);
144
146
  var metaSchema = (_a = params.meta) === null || _a === void 0 ? void 0 : _a.schema;
145
- var body = JSON.stringify(__assign({}, dataWithoutVirtualId(removePrimaryKey(data, primaryKey), primaryKey)));
147
+ var body = JSON.stringify(__assign({}, dataWithoutVirtualId(removePrimaryKey(changedData, primaryKey), primaryKey)));
146
148
  return config
147
149
  .httpClient(url, {
148
150
  method: 'PATCH',
@@ -241,3 +243,12 @@ export default (function (config) { return ({
241
243
  });
242
244
  },
243
245
  }); });
246
+ var getChanges = function (data, previousData) {
247
+ var changes = Object.keys(data).reduce(function (changes, key) {
248
+ if (!isEqual(data[key], previousData[key])) {
249
+ changes[key] = data[key];
250
+ }
251
+ return changes;
252
+ }, {});
253
+ return changes;
254
+ };
package/esm/urlBuilder.js CHANGED
@@ -121,8 +121,6 @@ export var parseFilters = function (params, defaultListOp) {
121
121
  return "".concat(operation, ".*").concat(value, "*");
122
122
  if (['and', 'or'].includes(operation))
123
123
  return "".concat(value);
124
- if (['cs', 'cd'].includes(operation))
125
- return "".concat(operation, ".{").concat(value, "}");
126
124
  return "".concat(operation, ".").concat(value);
127
125
  })();
128
126
  // If resulting filter doesn't contain the fieldname, then add it.
package/lib/index.js CHANGED
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.defaultSchema = exports.defaultPrimaryKeys = void 0;
18
18
  var urlBuilder_1 = require("./urlBuilder");
19
19
  var qs_1 = __importDefault(require("qs"));
20
+ var isEqual_1 = __importDefault(require("lodash/isEqual"));
20
21
  exports.defaultPrimaryKeys = new Map();
21
22
  var defaultSchema = function () { return ''; };
22
23
  exports.defaultSchema = defaultSchema;
@@ -65,7 +66,7 @@ exports.default = (function (config) { return ({
65
66
  return config.httpClient(url, options).then(function (_a) {
66
67
  var headers = _a.headers, json = _a.json;
67
68
  if (!headers.has('content-range')) {
68
- throw new Error("The Content-Range header is missing in the HTTP Response. The postgREST data provider expects \n responses for lists of resources to contain this header with the total number of results to build \n the pagination. If you are using CORS, did you declare Content-Range in the Access-Control-Expose-Headers header?");
69
+ throw new Error("The Content-Range header is missing in the HTTP Response. The postgREST data provider expects\n responses for lists of resources to contain this header with the total number of results to build\n the pagination. If you are using CORS, did you declare Content-Range in the Access-Control-Expose-Headers header?");
69
70
  }
70
71
  return {
71
72
  data: json.map(function (obj) { return (0, urlBuilder_1.dataWithVirtualId)(obj, primaryKey); }),
@@ -133,7 +134,7 @@ exports.default = (function (config) { return ({
133
134
  return config.httpClient(url, options).then(function (_a) {
134
135
  var headers = _a.headers, json = _a.json;
135
136
  if (!headers.has('content-range')) {
136
- throw new Error("The Content-Range header is missing in the HTTP Response. The postgREST data provider expects \n responses for lists of resources to contain this header with the total number of results to build \n the pagination. If you are using CORS, did you declare Content-Range in the Access-Control-Expose-Headers header?");
137
+ throw new Error("The Content-Range header is missing in the HTTP Response. The postgREST data provider expects\n responses for lists of resources to contain this header with the total number of results to build\n the pagination. If you are using CORS, did you declare Content-Range in the Access-Control-Expose-Headers header?");
137
138
  }
138
139
  return {
139
140
  data: json.map(function (data) { return (0, urlBuilder_1.dataWithVirtualId)(data, primaryKey); }),
@@ -144,12 +145,13 @@ exports.default = (function (config) { return ({
144
145
  update: function (resource, params) {
145
146
  var _a, _b;
146
147
  if (params === void 0) { params = {}; }
147
- var id = params.id, data = params.data, meta = params.meta;
148
+ var id = params.id, data = params.data, meta = params.meta, previousData = params.previousData;
148
149
  var primaryKey = (0, urlBuilder_1.getPrimaryKey)(resource, config.primaryKeys);
149
150
  var query = (0, urlBuilder_1.getQuery)(primaryKey, id, resource, meta);
150
151
  var url = "".concat(config.apiUrl, "/").concat(resource, "?").concat(qs_1.default.stringify(query));
152
+ var changedData = getChanges(data, previousData);
151
153
  var metaSchema = (_a = params.meta) === null || _a === void 0 ? void 0 : _a.schema;
152
- var body = JSON.stringify(__assign({}, (0, urlBuilder_1.dataWithoutVirtualId)((0, urlBuilder_1.removePrimaryKey)(data, primaryKey), primaryKey)));
154
+ var body = JSON.stringify(__assign({}, (0, urlBuilder_1.dataWithoutVirtualId)((0, urlBuilder_1.removePrimaryKey)(changedData, primaryKey), primaryKey)));
153
155
  return config
154
156
  .httpClient(url, {
155
157
  method: 'PATCH',
@@ -248,3 +250,12 @@ exports.default = (function (config) { return ({
248
250
  });
249
251
  },
250
252
  }); });
253
+ var getChanges = function (data, previousData) {
254
+ var changes = Object.keys(data).reduce(function (changes, key) {
255
+ if (!(0, isEqual_1.default)(data[key], previousData[key])) {
256
+ changes[key] = data[key];
257
+ }
258
+ return changes;
259
+ }, {});
260
+ return changes;
261
+ };
package/lib/urlBuilder.js CHANGED
@@ -124,8 +124,6 @@ var parseFilters = function (params, defaultListOp) {
124
124
  return "".concat(operation, ".*").concat(value, "*");
125
125
  if (['and', 'or'].includes(operation))
126
126
  return "".concat(value);
127
- if (['cs', 'cd'].includes(operation))
128
- return "".concat(operation, ".{").concat(value, "}");
129
127
  return "".concat(operation, ".").concat(value);
130
128
  })();
131
129
  // If resulting filter doesn't contain the fieldname, then add it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raphiniert/ra-data-postgrest",
3
- "version": "2.0.0-alpha.4",
3
+ "version": "2.1.0",
4
4
  "description": "postgREST data provider for react-admin",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -29,22 +29,23 @@
29
29
  "prettier": "prettier --config ./.prettierrc.js --write --list-different \"src/**/*.{js,json,ts,tsx,css,md}\""
30
30
  },
31
31
  "devDependencies": {
32
- "@types/jest": "^29.5.6",
33
- "@types/qs": "^6.9.7",
32
+ "@types/jest": "^29.5.11",
33
+ "@types/qs": "^6.9.11",
34
34
  "cross-env": "^7.0.3",
35
- "eslint-config-prettier": "^9.0.0",
35
+ "eslint-config-prettier": "^9.1.0",
36
36
  "eslint-plugin-prettier": "^5.0.1",
37
37
  "install-peers-cli": "^2.2.0",
38
38
  "jest": "^29.7.0",
39
- "prettier": "^3.0.3",
39
+ "prettier": "^3.1.1",
40
40
  "rimraf": "^5.0.0",
41
41
  "ts-jest": "^29.1.1",
42
- "typescript": "^5.0.4"
42
+ "typescript": "^5.3.3"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "ra-core": "^4.1.0"
46
46
  },
47
47
  "dependencies": {
48
+ "lodash.isequal": "^4.5.0",
48
49
  "qs": "^6.11.1"
49
50
  }
50
51
  }
package/src/index.ts CHANGED
@@ -23,6 +23,7 @@ import {
23
23
  encodeId,
24
24
  } from './urlBuilder';
25
25
  import qs from 'qs';
26
+ import isEqual from 'lodash/isEqual';
26
27
 
27
28
  /**
28
29
  * Maps react-admin queries to a postgrest REST API
@@ -146,8 +147,8 @@ export default (config: IDataProviderConfig): DataProvider => ({
146
147
  return config.httpClient(url, options).then(({ headers, json }) => {
147
148
  if (!headers.has('content-range')) {
148
149
  throw new Error(
149
- `The Content-Range header is missing in the HTTP Response. The postgREST data provider expects
150
- responses for lists of resources to contain this header with the total number of results to build
150
+ `The Content-Range header is missing in the HTTP Response. The postgREST data provider expects
151
+ responses for lists of resources to contain this header with the total number of results to build
151
152
  the pagination. If you are using CORS, did you declare Content-Range in the Access-Control-Expose-Headers header?`
152
153
  );
153
154
  }
@@ -249,8 +250,8 @@ export default (config: IDataProviderConfig): DataProvider => ({
249
250
  return config.httpClient(url, options).then(({ headers, json }) => {
250
251
  if (!headers.has('content-range')) {
251
252
  throw new Error(
252
- `The Content-Range header is missing in the HTTP Response. The postgREST data provider expects
253
- responses for lists of resources to contain this header with the total number of results to build
253
+ `The Content-Range header is missing in the HTTP Response. The postgREST data provider expects
254
+ responses for lists of resources to contain this header with the total number of results to build
254
255
  the pagination. If you are using CORS, did you declare Content-Range in the Access-Control-Expose-Headers header?`
255
256
  );
256
257
  }
@@ -265,15 +266,16 @@ export default (config: IDataProviderConfig): DataProvider => ({
265
266
  },
266
267
 
267
268
  update: (resource, params: Partial<UpdateParams> = {}) => {
268
- const { id, data, meta } = params;
269
+ const { id, data, meta, previousData } = params;
269
270
  const primaryKey = getPrimaryKey(resource, config.primaryKeys);
270
271
  const query = getQuery(primaryKey, id, resource, meta);
271
272
  const url = `${config.apiUrl}/${resource}?${qs.stringify(query)}`;
273
+ const changedData = getChanges(data, previousData);
272
274
  const metaSchema = params.meta?.schema;
273
275
 
274
276
  const body = JSON.stringify({
275
277
  ...dataWithoutVirtualId(
276
- removePrimaryKey(data, primaryKey),
278
+ removePrimaryKey(changedData, primaryKey),
277
279
  primaryKey
278
280
  ),
279
281
  });
@@ -406,3 +408,13 @@ export default (config: IDataProviderConfig): DataProvider => ({
406
408
  }));
407
409
  },
408
410
  });
411
+
412
+ const getChanges = (data: any, previousData: any) => {
413
+ const changes = Object.keys(data).reduce((changes, key) => {
414
+ if (!isEqual(data[key], previousData[key])) {
415
+ changes[key] = data[key];
416
+ }
417
+ return changes;
418
+ }, {});
419
+ return changes;
420
+ };
package/src/urlBuilder.ts CHANGED
@@ -135,8 +135,6 @@ export const parseFilters = (
135
135
  if (operation.includes('like'))
136
136
  return `${operation}.*${value}*`;
137
137
  if (['and', 'or'].includes(operation)) return `${value}`;
138
- if (['cs', 'cd'].includes(operation))
139
- return `${operation}.{${value}}`;
140
138
  return `${operation}.${value}`;
141
139
  })();
142
140