@raphiniert/ra-data-postgrest 1.2.1 → 2.0.0-alpha.1

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/lib/index.js CHANGED
@@ -1,10 +1,247 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.authProvider = void 0;
7
- var dataProvider_1 = __importDefault(require("./dataProvider"));
8
- var authProvider_1 = __importDefault(require("./authProvider"));
9
- exports.authProvider = authProvider_1.default;
10
- exports.default = dataProvider_1.default;
17
+ var ra_core_1 = require("ra-core");
18
+ var urlBuilder_1 = require("./urlBuilder");
19
+ var qs_1 = __importDefault(require("qs"));
20
+ /**
21
+ * Maps react-admin queries to a postgrest REST API
22
+ *
23
+ * This REST dialect uses postgrest syntax
24
+ *
25
+ * @see https://postgrest.org/en/stable/api.html#embedded-filters
26
+ *
27
+ * @example
28
+ *
29
+ * getList => GET http://my.api.url/posts?order=title.asc&offset=0&limit=24&filterField=eq.value
30
+ * getOne => GET http://my.api.url/posts?id=eq.123
31
+ * getMany => GET http://my.api.url/posts?id=in.(123,456,789)
32
+ * getManyReference => GET http://my.api.url/posts?author_id=eq.345
33
+ * create => POST http://my.api.url/posts
34
+ * update => PATCH http://my.api.url/posts?id=eq.123
35
+ * updateMany => PATCH http://my.api.url/posts?id=in.(123,456,789)
36
+ * delete => DELETE http://my.api.url/posts?id=eq.123
37
+ * deleteMany => DELETE http://my.api.url/posts?id=in.(123,456,789)
38
+ *
39
+ * @example
40
+ *
41
+ * import * as React from 'react';
42
+ * import { Admin, Resource } from 'react-admin';
43
+ * import postgrestRestProvider from '@raphiniert/ra-data-postgrest';
44
+ *
45
+ * import { PostList } from './posts';
46
+ *
47
+ * const App = () => (
48
+ * <Admin dataProvider={postgrestRestProvider('http://path.to.my.api/')}>
49
+ * <Resource name="posts" list={PostList} />
50
+ * </Admin>
51
+ * );
52
+ *
53
+ * export default App;
54
+ */
55
+ var defaultPrimaryKeys = new Map();
56
+ exports.default = (function (apiUrl, httpClient, defaultListOp, primaryKeys) {
57
+ if (httpClient === void 0) { httpClient = ra_core_1.fetchUtils.fetchJson; }
58
+ if (defaultListOp === void 0) { defaultListOp = 'eq'; }
59
+ if (primaryKeys === void 0) { primaryKeys = defaultPrimaryKeys; }
60
+ return ({
61
+ getList: function (resource, params) {
62
+ var _a;
63
+ if (params === void 0) { params = {}; }
64
+ var primaryKey = (0, urlBuilder_1.getPrimaryKey)(resource, primaryKeys);
65
+ var _b = params.pagination, page = _b.page, perPage = _b.perPage;
66
+ var _c = params.sort || {}, field = _c.field, order = _c.order;
67
+ var _d = (0, urlBuilder_1.parseFilters)(params, defaultListOp), filter = _d.filter, select = _d.select;
68
+ var query = __assign({ offset: String((page - 1) * perPage), limit: String(perPage) }, filter);
69
+ if (field) {
70
+ query.order = (0, urlBuilder_1.getOrderBy)(field, order, primaryKey);
71
+ }
72
+ if (select) {
73
+ query.select = select;
74
+ }
75
+ // add header that Content-Range is in returned header
76
+ var options = {
77
+ headers: new Headers(__assign({ Accept: 'application/json', Prefer: 'count=exact' }, (((_a = params.meta) === null || _a === void 0 ? void 0 : _a.headers) || {}))),
78
+ };
79
+ var url = "".concat(apiUrl, "/").concat(resource, "?").concat(qs_1.default.stringify(query));
80
+ return httpClient(url, options).then(function (_a) {
81
+ var headers = _a.headers, json = _a.json;
82
+ if (!headers.has('content-range')) {
83
+ 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?");
84
+ }
85
+ return {
86
+ data: json.map(function (obj) { return (0, urlBuilder_1.dataWithId)(obj, primaryKey); }),
87
+ total: parseInt(headers.get('content-range').split('/').pop(), 10),
88
+ };
89
+ });
90
+ },
91
+ getOne: function (resource, params) {
92
+ var _a;
93
+ if (params === void 0) { params = {}; }
94
+ var id = params.id, meta = params.meta;
95
+ var primaryKey = (0, urlBuilder_1.getPrimaryKey)(resource, primaryKeys);
96
+ var query = (0, urlBuilder_1.getQuery)(primaryKey, id, resource, meta);
97
+ var url = "".concat(apiUrl, "/").concat(resource, "?").concat(qs_1.default.stringify(query));
98
+ return httpClient(url, {
99
+ headers: new Headers(__assign({ accept: 'application/vnd.pgrst.object+json' }, (((_a = params.meta) === null || _a === void 0 ? void 0 : _a.headers) || {}))),
100
+ }).then(function (_a) {
101
+ var json = _a.json;
102
+ return ({
103
+ data: (0, urlBuilder_1.dataWithId)(json, primaryKey),
104
+ });
105
+ });
106
+ },
107
+ getMany: function (resource, params) {
108
+ if (params === void 0) { params = {}; }
109
+ var ids = params.ids;
110
+ var primaryKey = (0, urlBuilder_1.getPrimaryKey)(resource, primaryKeys);
111
+ var query = (0, urlBuilder_1.getQuery)(primaryKey, ids, resource, params.meta);
112
+ var url = "".concat(apiUrl, "/").concat(resource, "?").concat(qs_1.default.stringify(query));
113
+ return httpClient(url).then(function (_a) {
114
+ var json = _a.json;
115
+ return ({
116
+ data: json.map(function (data) { return (0, urlBuilder_1.dataWithId)(data, primaryKey); }),
117
+ });
118
+ });
119
+ },
120
+ getManyReference: function (resource, params) {
121
+ var _a;
122
+ var _b;
123
+ if (params === void 0) { params = {}; }
124
+ var _c = params.pagination, page = _c.page, perPage = _c.perPage;
125
+ var _d = params.sort, field = _d.field, order = _d.order;
126
+ var _e = (0, urlBuilder_1.parseFilters)(params, defaultListOp), filter = _e.filter, select = _e.select;
127
+ var primaryKey = (0, urlBuilder_1.getPrimaryKey)(resource, primaryKeys);
128
+ var query = params.target
129
+ ? __assign((_a = {}, _a[params.target] = "eq.".concat(params.id), _a.order = (0, urlBuilder_1.getOrderBy)(field, order, primaryKey), _a.offset = String((page - 1) * perPage), _a.limit = String(perPage), _a), filter) : __assign({ order: (0, urlBuilder_1.getOrderBy)(field, order, primaryKey), offset: String((page - 1) * perPage), limit: String(perPage) }, filter);
130
+ if (select) {
131
+ query.select = select;
132
+ }
133
+ // add header that Content-Range is in returned header
134
+ var options = {
135
+ headers: new Headers(__assign({ Accept: 'application/json', Prefer: 'count=exact' }, (((_b = params.meta) === null || _b === void 0 ? void 0 : _b.headers) || {}))),
136
+ };
137
+ var url = "".concat(apiUrl, "/").concat(resource, "?").concat(qs_1.default.stringify(query));
138
+ return httpClient(url, options).then(function (_a) {
139
+ var headers = _a.headers, json = _a.json;
140
+ if (!headers.has('content-range')) {
141
+ 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?");
142
+ }
143
+ return {
144
+ data: json.map(function (data) { return (0, urlBuilder_1.dataWithId)(data, primaryKey); }),
145
+ total: parseInt(headers.get('content-range').split('/').pop(), 10),
146
+ };
147
+ });
148
+ },
149
+ update: function (resource, params) {
150
+ var _a;
151
+ if (params === void 0) { params = {}; }
152
+ var id = params.id, data = params.data, meta = params.meta;
153
+ var primaryKey = (0, urlBuilder_1.getPrimaryKey)(resource, primaryKeys);
154
+ var query = (0, urlBuilder_1.getQuery)(primaryKey, id, resource, meta);
155
+ var primaryKeyData = (0, urlBuilder_1.getKeyData)(primaryKey, data);
156
+ var url = "".concat(apiUrl, "/").concat(resource, "?").concat(qs_1.default.stringify(query));
157
+ var body = JSON.stringify(__assign(__assign({}, data), primaryKeyData));
158
+ return httpClient(url, {
159
+ method: 'PATCH',
160
+ headers: new Headers(__assign({ Accept: 'application/vnd.pgrst.object+json', Prefer: 'return=representation', 'Content-Type': 'application/json' }, (((_a = params.meta) === null || _a === void 0 ? void 0 : _a.headers) || {}))),
161
+ body: body,
162
+ }).then(function (_a) {
163
+ var json = _a.json;
164
+ return ({ data: (0, urlBuilder_1.dataWithId)(json, primaryKey) });
165
+ });
166
+ },
167
+ updateMany: function (resource, params) {
168
+ var _a;
169
+ if (params === void 0) { params = {}; }
170
+ var ids = params.ids;
171
+ var primaryKey = (0, urlBuilder_1.getPrimaryKey)(resource, primaryKeys);
172
+ var body = JSON.stringify(params.ids.map(function (id) {
173
+ var data = params.data;
174
+ var primaryKeyParams = (0, urlBuilder_1.decodeId)(id, primaryKey);
175
+ var primaryKeyData = {};
176
+ if ((0, urlBuilder_1.isCompoundKey)(primaryKey)) {
177
+ primaryKey.forEach(function (key, index) {
178
+ primaryKeyData[key] = primaryKeyParams[index];
179
+ });
180
+ }
181
+ else {
182
+ primaryKeyData[primaryKey[0]] = primaryKeyParams[0];
183
+ }
184
+ return __assign(__assign({}, data), primaryKeyData);
185
+ }));
186
+ var url = "".concat(apiUrl, "/").concat(resource);
187
+ return httpClient(url, {
188
+ method: 'PATCH',
189
+ headers: new Headers(__assign({ Prefer: 'return=representation', 'Content-Type': 'application/json' }, (((_a = params.meta) === null || _a === void 0 ? void 0 : _a.headers) || {}))),
190
+ body: body,
191
+ }).then(function (_a) {
192
+ var json = _a.json;
193
+ return ({
194
+ data: json.map(function (data) { return (0, urlBuilder_1.encodeId)(data, primaryKey); }),
195
+ });
196
+ });
197
+ },
198
+ create: function (resource, params) {
199
+ var _a;
200
+ if (params === void 0) { params = {}; }
201
+ var primaryKey = (0, urlBuilder_1.getPrimaryKey)(resource, primaryKeys);
202
+ var url = "".concat(apiUrl, "/").concat(resource);
203
+ return httpClient(url, {
204
+ method: 'POST',
205
+ headers: new Headers(__assign({ Accept: 'application/vnd.pgrst.object+json', Prefer: 'return=representation', 'Content-Type': 'application/json' }, (((_a = params.meta) === null || _a === void 0 ? void 0 : _a.headers) || {}))),
206
+ body: JSON.stringify(params.data),
207
+ }).then(function (_a) {
208
+ var json = _a.json;
209
+ return ({
210
+ data: __assign(__assign({}, json), { id: (0, urlBuilder_1.encodeId)(json, primaryKey) }),
211
+ });
212
+ });
213
+ },
214
+ delete: function (resource, params) {
215
+ var _a;
216
+ if (params === void 0) { params = {}; }
217
+ var id = params.id, meta = params.meta;
218
+ var primaryKey = (0, urlBuilder_1.getPrimaryKey)(resource, primaryKeys);
219
+ var query = (0, urlBuilder_1.getQuery)(primaryKey, id, resource, meta);
220
+ var url = "".concat(apiUrl, "/").concat(resource, "?").concat(qs_1.default.stringify(query));
221
+ return httpClient(url, {
222
+ method: 'DELETE',
223
+ headers: new Headers(__assign({ Accept: 'application/vnd.pgrst.object+json', Prefer: 'return=representation', 'Content-Type': 'application/json' }, (((_a = params.meta) === null || _a === void 0 ? void 0 : _a.headers) || {}))),
224
+ }).then(function (_a) {
225
+ var json = _a.json;
226
+ return ({ data: (0, urlBuilder_1.dataWithId)(json, primaryKey) });
227
+ });
228
+ },
229
+ deleteMany: function (resource, params) {
230
+ var _a;
231
+ if (params === void 0) { params = {}; }
232
+ var ids = params.ids, meta = params.meta;
233
+ var primaryKey = (0, urlBuilder_1.getPrimaryKey)(resource, primaryKeys);
234
+ var query = (0, urlBuilder_1.getQuery)(primaryKey, ids, resource, meta);
235
+ var url = "".concat(apiUrl, "/").concat(resource, "?").concat(qs_1.default.stringify(query));
236
+ return httpClient(url, {
237
+ method: 'DELETE',
238
+ headers: new Headers(__assign({ Prefer: 'return=representation', 'Content-Type': 'application/json' }, (((_a = params.meta) === null || _a === void 0 ? void 0 : _a.headers) || {}))),
239
+ }).then(function (_a) {
240
+ var json = _a.json;
241
+ return ({
242
+ data: json.map(function (data) { return (0, urlBuilder_1.encodeId)(data, primaryKey); }),
243
+ });
244
+ });
245
+ },
246
+ });
247
+ });
@@ -0,0 +1,22 @@
1
+ import { Identifier } from 'ra-core';
2
+ /**
3
+ * List of all possible operators in PostgRest
4
+ * (https://postgrest.org/en/stable/api.html#operators)
5
+ */
6
+ declare const postgrestOperators: readonly ["eq", "gt", "gte", "lt", "lte", "neq", "like", "ilike", "match", "imatch", "in", "is", "fts", "plfts", "phfts", "wfts", "cs", "cd", "ov", "sl", "sr", "nxr", "nxl", "adj", "not", "or", "and"];
7
+ type ParsedFiltersResult = {
8
+ filter: any;
9
+ select: any;
10
+ };
11
+ export type PostgRestOperator = (typeof postgrestOperators)[number];
12
+ export declare const parseFilters: (params: any, defaultListOp: PostgRestOperator) => Partial<ParsedFiltersResult>;
13
+ export type PrimaryKey = Array<string>;
14
+ export declare const getPrimaryKey: (resource: string, primaryKeys: Map<string, PrimaryKey>) => PrimaryKey;
15
+ export declare const decodeId: (id: Identifier, primaryKey: PrimaryKey) => string[] | number[];
16
+ export declare const encodeId: (data: any, primaryKey: PrimaryKey) => Identifier;
17
+ export declare const dataWithId: (data: any, primaryKey: PrimaryKey) => any;
18
+ export declare const isCompoundKey: (primaryKey: PrimaryKey) => Boolean;
19
+ export declare const getQuery: (primaryKey: PrimaryKey, ids: Identifier | Array<Identifier>, resource: string, meta?: any) => any;
20
+ export declare const getKeyData: (primaryKey: PrimaryKey, data: object) => object;
21
+ export declare const getOrderBy: (field: string, order: string, primaryKey: PrimaryKey) => string;
22
+ export {};
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.getOrderBy = exports.getKeyData = exports.getQuery = exports.isCompoundKey = exports.dataWithId = exports.encodeId = exports.decodeId = exports.getPrimaryKey = exports.parseFilters = void 0;
15
+ /**
16
+ * List of all possible operators in PostgRest
17
+ * (https://postgrest.org/en/stable/api.html#operators)
18
+ */
19
+ var postgrestOperators = [
20
+ 'eq',
21
+ 'gt',
22
+ 'gte',
23
+ 'lt',
24
+ 'lte',
25
+ 'neq',
26
+ 'like',
27
+ 'ilike',
28
+ 'match',
29
+ 'imatch',
30
+ 'in',
31
+ 'is',
32
+ 'fts',
33
+ 'plfts',
34
+ 'phfts',
35
+ 'wfts',
36
+ 'cs',
37
+ 'cd',
38
+ 'ov',
39
+ 'sl',
40
+ 'sr',
41
+ 'nxr',
42
+ 'nxl',
43
+ 'adj',
44
+ 'not',
45
+ 'or',
46
+ 'and',
47
+ ];
48
+ var parseFilters = function (params, defaultListOp) {
49
+ var filter = params.filter, _a = params.meta, meta = _a === void 0 ? {} : _a;
50
+ var result = {};
51
+ result.filter = {};
52
+ Object.keys(filter).forEach(function (key) {
53
+ // key: the name of the object key
54
+ var splitKey = key.split('@');
55
+ var operation = splitKey.length == 2
56
+ ? splitKey[1]
57
+ : defaultListOp;
58
+ var values;
59
+ if (['like', 'ilike'].includes(operation)) {
60
+ // we split the search term in words
61
+ values = filter[key].trim().split(/\s+/);
62
+ }
63
+ else {
64
+ values = [filter[key]];
65
+ }
66
+ values.forEach(function (value) {
67
+ // if operator is intentionally blank, rpc syntax
68
+ var op = operation.includes('like')
69
+ ? "".concat(operation, ".*").concat(value, "*")
70
+ : operation.length == 0
71
+ ? "".concat(value)
72
+ : "".concat(operation, ".").concat(value);
73
+ if (result.filter[splitKey[0]] === undefined) {
74
+ // first operator for the key, we add it to the dict
75
+ result.filter[splitKey[0]] = op;
76
+ }
77
+ else {
78
+ if (!Array.isArray(result[splitKey[0]])) {
79
+ // second operator, we transform to an array
80
+ result.filter[splitKey[0]] = [
81
+ result.filter[splitKey[0]],
82
+ op,
83
+ ];
84
+ }
85
+ else {
86
+ // third and subsequent, we add to array
87
+ result.filter[splitKey[0]].push(op);
88
+ }
89
+ }
90
+ });
91
+ });
92
+ if (meta === null || meta === void 0 ? void 0 : meta.columns) {
93
+ result.select = Array.isArray(meta.columns)
94
+ ? meta.columns.join(',')
95
+ : meta.columns;
96
+ }
97
+ return result;
98
+ };
99
+ exports.parseFilters = parseFilters;
100
+ var getPrimaryKey = function (resource, primaryKeys) {
101
+ return primaryKeys.get(resource) || ['id'];
102
+ };
103
+ exports.getPrimaryKey = getPrimaryKey;
104
+ var decodeId = function (id, primaryKey) {
105
+ if ((0, exports.isCompoundKey)(primaryKey)) {
106
+ return JSON.parse(id.toString());
107
+ }
108
+ else {
109
+ return [id.toString()];
110
+ }
111
+ };
112
+ exports.decodeId = decodeId;
113
+ var encodeId = function (data, primaryKey) {
114
+ if ((0, exports.isCompoundKey)(primaryKey)) {
115
+ return JSON.stringify(primaryKey.map(function (key) { return data[key]; }));
116
+ }
117
+ else {
118
+ return data[primaryKey[0]];
119
+ }
120
+ };
121
+ exports.encodeId = encodeId;
122
+ var dataWithId = function (data, primaryKey) {
123
+ if (JSON.stringify(primaryKey) === JSON.stringify(['id'])) {
124
+ return data;
125
+ }
126
+ return Object.assign(data, {
127
+ id: (0, exports.encodeId)(data, primaryKey),
128
+ });
129
+ };
130
+ exports.dataWithId = dataWithId;
131
+ var isCompoundKey = function (primaryKey) {
132
+ return primaryKey.length > 1;
133
+ };
134
+ exports.isCompoundKey = isCompoundKey;
135
+ var getQuery = function (primaryKey, ids, resource, meta) {
136
+ var _a, _b;
137
+ if (meta === void 0) { meta = null; }
138
+ var result = {};
139
+ if (Array.isArray(ids) && ids.length > 1) {
140
+ // no standardized query with multiple ids possible for rpc endpoints which are api-exposed database functions
141
+ if (resource.startsWith('rpc/')) {
142
+ console.error("PostgREST's rpc endpoints are not intended to be handled as views. Therefore, no query generation for multiple key values implemented!");
143
+ return;
144
+ }
145
+ if ((0, exports.isCompoundKey)(primaryKey)) {
146
+ result = {
147
+ or: "(".concat(ids.map(function (id) {
148
+ var primaryKeyParams = (0, exports.decodeId)(id, primaryKey);
149
+ return "and(".concat(primaryKey
150
+ .map(function (key, i) { return "".concat(key, ".eq.").concat(primaryKeyParams[i]); })
151
+ .join(','), ")");
152
+ }), ")"),
153
+ };
154
+ }
155
+ else {
156
+ result = (_a = {},
157
+ _a[primaryKey[0]] = "in.(".concat(ids.join(','), ")"),
158
+ _a);
159
+ }
160
+ }
161
+ else {
162
+ // if ids is one Identifier
163
+ var id = ids.toString();
164
+ var primaryKeyParams_1 = (0, exports.decodeId)(id, primaryKey);
165
+ if ((0, exports.isCompoundKey)(primaryKey)) {
166
+ if (resource.startsWith('rpc/')) {
167
+ result = {};
168
+ primaryKey.map(function (key, i) {
169
+ return (result[key] = "".concat(primaryKeyParams_1[i]));
170
+ });
171
+ }
172
+ else {
173
+ result = {
174
+ and: "(".concat(primaryKey.map(function (key, i) {
175
+ return "".concat(key, ".eq.").concat(primaryKeyParams_1[i]);
176
+ }), ")"),
177
+ };
178
+ }
179
+ }
180
+ else {
181
+ result = (_b = {},
182
+ _b[primaryKey[0]] = "eq.".concat(id),
183
+ _b);
184
+ }
185
+ }
186
+ if (meta && meta.columns) {
187
+ result.select = Array.isArray(meta.columns)
188
+ ? meta.columns.join(',')
189
+ : meta.columns;
190
+ }
191
+ return result;
192
+ };
193
+ exports.getQuery = getQuery;
194
+ var getKeyData = function (primaryKey, data) {
195
+ var _a;
196
+ if ((0, exports.isCompoundKey)(primaryKey)) {
197
+ return primaryKey.reduce(function (keyData, key) {
198
+ var _a;
199
+ return (__assign(__assign({}, keyData), (_a = {}, _a[key] = data[key], _a)));
200
+ }, {});
201
+ }
202
+ else {
203
+ return _a = {}, _a[primaryKey[0]] = data[primaryKey[0]], _a;
204
+ }
205
+ };
206
+ exports.getKeyData = getKeyData;
207
+ var getOrderBy = function (field, order, primaryKey) {
208
+ if (field == 'id') {
209
+ return primaryKey.map(function (key) { return "".concat(key, ".").concat(order.toLowerCase()); }).join(',');
210
+ }
211
+ else {
212
+ return "".concat(field, ".").concat(order.toLowerCase());
213
+ }
214
+ };
215
+ exports.getOrderBy = getOrderBy;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raphiniert/ra-data-postgrest",
3
- "version": "1.2.1",
3
+ "version": "2.0.0-alpha.1",
4
4
  "description": "postgREST data provider for react-admin",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -20,19 +20,31 @@
20
20
  "bugs": "https://github.com/raphiniert-com/ra-data-postgrest/issues",
21
21
  "license": "MIT",
22
22
  "scripts": {
23
- "build": "yarn run build-cjs && yarn run build-esm",
23
+ "coverage": "jest --coverage",
24
+ "test": "jest --watchAll",
25
+ "build": "npm run build-cjs && npm run build-esm",
24
26
  "build-cjs": "rimraf ./lib && tsc",
25
27
  "build-esm": "rimraf ./esm && tsc --outDir esm --module es2015",
26
28
  "watch": "tsc --outDir esm --module es2015 --watch",
27
- "prepare": "install-peers"
29
+ "prepare": "install-peers",
30
+ "prettier": "prettier --config ./.prettierrc.js --write --list-different \"src/**/*.{js,json,ts,tsx,css,md}\""
28
31
  },
29
32
  "devDependencies": {
33
+ "@types/jest": "^28.1.4",
30
34
  "cross-env": "^7.0.3",
35
+ "eslint-config-prettier": "^8.8.0",
36
+ "eslint-plugin-prettier": "^4.2.1",
31
37
  "install-peers-cli": "^2.2.0",
32
- "rimraf": "^3.0.2",
33
- "typescript": "^4.6.4"
38
+ "jest": "^28.1.2",
39
+ "prettier": "~2.8.7",
40
+ "rimraf": "^4.4.1",
41
+ "ts-jest": "^28.0.5",
42
+ "typescript": "^4.9.5"
34
43
  },
35
44
  "peerDependencies": {
36
45
  "ra-core": "^4.1.0"
46
+ },
47
+ "dependencies": {
48
+ "qs": "^6.11.1"
37
49
  }
38
50
  }