@cuboapp/api-backend 1.0.4 → 1.0.6
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/package.json +3 -3
- package/pnpm-lock.yaml +11 -18
- package/src/helpers/index.ts +9 -1
- package/src/index.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuboapp/api-backend",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Backend Api for CuboApp",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"repository": "git@github.com:cuboapp/api-backend.git",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@cuboapp/config": "^0.0.
|
|
15
|
-
"@cuboapp/types": "^1.0.
|
|
14
|
+
"@cuboapp/config": "^0.0.9",
|
|
15
|
+
"@cuboapp/types": "^1.0.21",
|
|
16
16
|
"lodash-es": "^4.17.21",
|
|
17
17
|
"pg": "^8.13.3",
|
|
18
18
|
"sequelize": "^6.37.6"
|
package/pnpm-lock.yaml
CHANGED
|
@@ -9,11 +9,11 @@ importers:
|
|
|
9
9
|
.:
|
|
10
10
|
dependencies:
|
|
11
11
|
'@cuboapp/config':
|
|
12
|
-
specifier: ^0.0.
|
|
13
|
-
version: 0.0.
|
|
12
|
+
specifier: ^0.0.9
|
|
13
|
+
version: 0.0.9
|
|
14
14
|
'@cuboapp/types':
|
|
15
|
-
specifier: ^1.0.
|
|
16
|
-
version: 1.0.
|
|
15
|
+
specifier: ^1.0.21
|
|
16
|
+
version: 1.0.21
|
|
17
17
|
lodash-es:
|
|
18
18
|
specifier: ^4.17.21
|
|
19
19
|
version: 4.17.21
|
|
@@ -36,14 +36,11 @@ importers:
|
|
|
36
36
|
|
|
37
37
|
packages:
|
|
38
38
|
|
|
39
|
-
'@cuboapp/config@0.0.
|
|
40
|
-
resolution: {integrity: sha512-
|
|
39
|
+
'@cuboapp/config@0.0.9':
|
|
40
|
+
resolution: {integrity: sha512-xkCZFOGTO6E8FhowmebthZ50deslWyak6HxhSPGUqktRazMa/6DVyZnTFQBs4Xt271GBXoRekXy8xNGVJnzCrg==}
|
|
41
41
|
|
|
42
|
-
'@cuboapp/types@1.0.
|
|
43
|
-
resolution: {integrity: sha512-
|
|
44
|
-
|
|
45
|
-
'@cuboapp/types@1.0.20':
|
|
46
|
-
resolution: {integrity: sha512-PDeJ4GOsVA6OhC1ryd8XwBrnZ7k6mB48GEnMLDdgw3ACRxV2KaWc/5bDrZUdfRjggOAXmwEhX+8rvqfNvp93hg==}
|
|
42
|
+
'@cuboapp/types@1.0.21':
|
|
43
|
+
resolution: {integrity: sha512-DIxfZRAEVX+PupP86Lii6lQXZ+CC6MWDxNUOO1FSWfJVqphXtvW52DFguhd9tu+TN50sHYS/BcjMLD1nJXw4KQ==}
|
|
47
44
|
|
|
48
45
|
'@types/debug@4.1.12':
|
|
49
46
|
resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==}
|
|
@@ -232,17 +229,13 @@ packages:
|
|
|
232
229
|
|
|
233
230
|
snapshots:
|
|
234
231
|
|
|
235
|
-
'@cuboapp/config@0.0.
|
|
232
|
+
'@cuboapp/config@0.0.9':
|
|
236
233
|
dependencies:
|
|
237
|
-
'@cuboapp/types': 1.0.
|
|
234
|
+
'@cuboapp/types': 1.0.21
|
|
238
235
|
dotenv: 16.4.7
|
|
239
236
|
dotenv-expand: 12.0.1
|
|
240
237
|
|
|
241
|
-
'@cuboapp/types@1.0.
|
|
242
|
-
dependencies:
|
|
243
|
-
'@types/events': 3.0.3
|
|
244
|
-
|
|
245
|
-
'@cuboapp/types@1.0.20':
|
|
238
|
+
'@cuboapp/types@1.0.21':
|
|
246
239
|
dependencies:
|
|
247
240
|
'@types/events': 3.0.3
|
|
248
241
|
|
package/src/helpers/index.ts
CHANGED
|
@@ -99,6 +99,8 @@ export class ApiHelpers<T extends CuboApiEntitiesMap<T>> {
|
|
|
99
99
|
case 'string':
|
|
100
100
|
if (value === 'null') {
|
|
101
101
|
value = null
|
|
102
|
+
} else if ([CUBO_CRUD_QUERY_CONDITION.IN, CUBO_CRUD_QUERY_CONDITION.NIN].includes(condition)) {
|
|
103
|
+
value = value.split(',')
|
|
102
104
|
}
|
|
103
105
|
break
|
|
104
106
|
case 'number':
|
|
@@ -132,7 +134,7 @@ export class ApiHelpers<T extends CuboApiEntitiesMap<T>> {
|
|
|
132
134
|
value = null
|
|
133
135
|
} else {
|
|
134
136
|
if ([CUBO_CRUD_QUERY_CONDITION.IN, CUBO_CRUD_QUERY_CONDITION.NIN].includes(condition)) {
|
|
135
|
-
value = value.split(',')
|
|
137
|
+
value = value.split(',').map(Number)
|
|
136
138
|
} else {
|
|
137
139
|
const potentialValue = precision === 0 ? parseInt(value) : parseFloat(value)
|
|
138
140
|
|
|
@@ -289,6 +291,7 @@ export class ApiHelpers<T extends CuboApiEntitiesMap<T>> {
|
|
|
289
291
|
let password: string = ''
|
|
290
292
|
let schema: string = ''
|
|
291
293
|
let dialect: string = ''
|
|
294
|
+
let dialectModule: any = undefined
|
|
292
295
|
|
|
293
296
|
if (!this.api.config.db) {
|
|
294
297
|
throw 'DB connection is not configured'
|
|
@@ -305,6 +308,7 @@ export class ApiHelpers<T extends CuboApiEntitiesMap<T>> {
|
|
|
305
308
|
}
|
|
306
309
|
|
|
307
310
|
database = cfg.database as string
|
|
311
|
+
dialectModule = cfg.dialectModule as string
|
|
308
312
|
host = cfg.host as string
|
|
309
313
|
port = cfg.port as number
|
|
310
314
|
username = cfg.username as string
|
|
@@ -328,6 +332,10 @@ export class ApiHelpers<T extends CuboApiEntitiesMap<T>> {
|
|
|
328
332
|
schema
|
|
329
333
|
}
|
|
330
334
|
|
|
335
|
+
if (dialectModule) {
|
|
336
|
+
config.dialectModule = dialectModule
|
|
337
|
+
}
|
|
338
|
+
|
|
331
339
|
// cert for yandex cloud
|
|
332
340
|
if (/yandexcloud/.test(config.host!)) {
|
|
333
341
|
config.dialectOptions = {
|
package/src/index.ts
CHANGED
|
@@ -333,6 +333,9 @@ export class CuboBackendApi<T extends CuboApiEntitiesMap<T>> {
|
|
|
333
333
|
}
|
|
334
334
|
|
|
335
335
|
const item: any = await this.getOne(entityAlias, req, opts)
|
|
336
|
+
if (!item) {
|
|
337
|
+
throw { status: 404, text: 'Entity not found' }
|
|
338
|
+
}
|
|
336
339
|
|
|
337
340
|
const dto = await this.helpers.data.prepare('delete', entity!.fields, req.body || {}, opts?.performer_id)
|
|
338
341
|
if (!Object.keys(dto)) {
|