@opra/sqb 0.10.0 → 0.12.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/cjs/sqb-adapter.js +17 -15
- package/esm/sqb-adapter.js +2 -1
- package/package.json +7 -9
package/cjs/sqb-adapter.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SQBAdapter = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const lodash_isnil_1 = tslib_1.__importDefault(require("lodash.isnil"));
|
|
6
|
+
const lodash_omitby_1 = tslib_1.__importDefault(require("lodash.omitby"));
|
|
5
7
|
const convert_filter_js_1 = require("./convert-filter.js");
|
|
6
8
|
var SQBAdapter;
|
|
7
9
|
(function (SQBAdapter) {
|
|
8
10
|
function prepare(query) {
|
|
9
11
|
switch (query.method) {
|
|
10
12
|
case 'create': {
|
|
11
|
-
const options = (0,
|
|
13
|
+
const options = (0, lodash_omitby_1.default)({
|
|
12
14
|
pick: query.pick?.length ? query.pick : undefined,
|
|
13
15
|
omit: query.omit?.length ? query.omit : undefined,
|
|
14
16
|
include: query.include?.length ? query.include : undefined,
|
|
15
|
-
},
|
|
17
|
+
}, lodash_isnil_1.default);
|
|
16
18
|
const { data } = query;
|
|
17
19
|
return {
|
|
18
20
|
method: 'create',
|
|
@@ -22,9 +24,9 @@ var SQBAdapter;
|
|
|
22
24
|
};
|
|
23
25
|
}
|
|
24
26
|
case 'count': {
|
|
25
|
-
const options = (0,
|
|
27
|
+
const options = (0, lodash_omitby_1.default)({
|
|
26
28
|
filter: (0, convert_filter_js_1.convertFilter)(query.filter)
|
|
27
|
-
},
|
|
29
|
+
}, lodash_isnil_1.default);
|
|
28
30
|
return {
|
|
29
31
|
method: 'count',
|
|
30
32
|
options,
|
|
@@ -33,11 +35,11 @@ var SQBAdapter;
|
|
|
33
35
|
}
|
|
34
36
|
case 'get': {
|
|
35
37
|
if (query.kind === 'CollectionGetQuery') {
|
|
36
|
-
const options = (0,
|
|
38
|
+
const options = (0, lodash_omitby_1.default)({
|
|
37
39
|
pick: query.pick?.length ? query.pick : undefined,
|
|
38
40
|
omit: query.omit?.length ? query.omit : undefined,
|
|
39
41
|
include: query.include?.length ? query.include : undefined,
|
|
40
|
-
},
|
|
42
|
+
}, lodash_isnil_1.default);
|
|
41
43
|
const keyValue = query.keyValue;
|
|
42
44
|
return {
|
|
43
45
|
method: 'findByPk',
|
|
@@ -49,7 +51,7 @@ var SQBAdapter;
|
|
|
49
51
|
break;
|
|
50
52
|
}
|
|
51
53
|
case 'search': {
|
|
52
|
-
const options = (0,
|
|
54
|
+
const options = (0, lodash_omitby_1.default)({
|
|
53
55
|
pick: query.pick?.length ? query.pick : undefined,
|
|
54
56
|
omit: query.omit?.length ? query.omit : undefined,
|
|
55
57
|
include: query.include?.length ? query.include : undefined,
|
|
@@ -59,7 +61,7 @@ var SQBAdapter;
|
|
|
59
61
|
distinct: query.distinct,
|
|
60
62
|
total: query.count,
|
|
61
63
|
filter: (0, convert_filter_js_1.convertFilter)(query.filter)
|
|
62
|
-
},
|
|
64
|
+
}, lodash_isnil_1.default);
|
|
63
65
|
return {
|
|
64
66
|
method: 'findAll',
|
|
65
67
|
options,
|
|
@@ -67,11 +69,11 @@ var SQBAdapter;
|
|
|
67
69
|
};
|
|
68
70
|
}
|
|
69
71
|
case 'update': {
|
|
70
|
-
const options = (0,
|
|
72
|
+
const options = (0, lodash_omitby_1.default)({
|
|
71
73
|
pick: query.pick?.length ? query.pick : undefined,
|
|
72
74
|
omit: query.omit?.length ? query.omit : undefined,
|
|
73
75
|
include: query.include?.length ? query.include : undefined,
|
|
74
|
-
},
|
|
76
|
+
}, lodash_isnil_1.default);
|
|
75
77
|
const { data } = query;
|
|
76
78
|
const keyValue = query.keyValue;
|
|
77
79
|
return {
|
|
@@ -83,9 +85,9 @@ var SQBAdapter;
|
|
|
83
85
|
};
|
|
84
86
|
}
|
|
85
87
|
case 'updateMany': {
|
|
86
|
-
const options = (0,
|
|
88
|
+
const options = (0, lodash_omitby_1.default)({
|
|
87
89
|
filter: (0, convert_filter_js_1.convertFilter)(query.filter)
|
|
88
|
-
},
|
|
90
|
+
}, lodash_isnil_1.default);
|
|
89
91
|
const { data } = query;
|
|
90
92
|
return {
|
|
91
93
|
method: 'updateAll',
|
|
@@ -105,9 +107,9 @@ var SQBAdapter;
|
|
|
105
107
|
};
|
|
106
108
|
}
|
|
107
109
|
case 'deleteMany': {
|
|
108
|
-
const options = (0,
|
|
110
|
+
const options = (0, lodash_omitby_1.default)({
|
|
109
111
|
filter: (0, convert_filter_js_1.convertFilter)(query.filter)
|
|
110
|
-
},
|
|
112
|
+
}, lodash_isnil_1.default);
|
|
111
113
|
return {
|
|
112
114
|
method: 'destroyAll',
|
|
113
115
|
options,
|
package/esm/sqb-adapter.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/sqb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Opra SQB adapter package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,15 +17,16 @@
|
|
|
17
17
|
"build:esm": "tsc -b tsconfig-build-esm.json",
|
|
18
18
|
"postbuild": "cp README.md package.json ../../LICENSE ../../build/sqb && cp ../../package.cjs.json ../../build/sqb/cjs/package.json",
|
|
19
19
|
"lint": "eslint .",
|
|
20
|
-
"test": "jest",
|
|
21
|
-
"cover": "jest --collect-coverage",
|
|
20
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules npx jest",
|
|
21
|
+
"cover": "NODE_OPTIONS=--experimental-vm-modules npx jest --collect-coverage",
|
|
22
22
|
"clean": "npm run clean:src && npm run clean:dist && npm run clean:cover",
|
|
23
|
-
"clean:src": "ts-cleanup -s src --all",
|
|
23
|
+
"clean:src": "ts-cleanup -s src --all && ts-cleanup -s test --all",
|
|
24
24
|
"clean:dist": "rimraf ../../build/sqb",
|
|
25
25
|
"clean:cover": "rimraf ../../coverage/sqb"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"lodash": "^4.
|
|
28
|
+
"lodash.isnil": "^4.0.0",
|
|
29
|
+
"lodash.omitby": "^4.6.0",
|
|
29
30
|
"ts-gems": "^2.3.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
@@ -33,13 +34,10 @@
|
|
|
33
34
|
"@sqb/builder": "^4.5.5",
|
|
34
35
|
"@sqb/connect": "^4.5.5",
|
|
35
36
|
"@sqb/postgres": "^4.5.5",
|
|
36
|
-
"async-mutex": "^0.4.0",
|
|
37
37
|
"postgresql-client": "^2.5.2"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@opra/core": "^0.
|
|
41
|
-
"@opra/exception": "^0.5.0",
|
|
42
|
-
"@opra/url": "^0.5.0",
|
|
40
|
+
"@opra/core": "^0.12.0",
|
|
43
41
|
"@sqb/connect": ">= 4.5.4"
|
|
44
42
|
},
|
|
45
43
|
"type": "module",
|