@cuboapp/api-backend 1.0.15 → 1.0.17
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 +1 -1
- package/src/crdt/index.ts +5 -6
- package/src/index.ts +2 -2
package/package.json
CHANGED
package/src/crdt/index.ts
CHANGED
|
@@ -37,7 +37,7 @@ export class CuboCrdt<T extends CuboApiEntitiesMap<T>> {
|
|
|
37
37
|
|
|
38
38
|
const { entityAlias, id } = this.parseDocumentName(documentName)
|
|
39
39
|
|
|
40
|
-
console.log('fetch', entityAlias, id)
|
|
40
|
+
// console.log('fetch', entityAlias, id)
|
|
41
41
|
if (id <= 0) {
|
|
42
42
|
return null
|
|
43
43
|
}
|
|
@@ -60,7 +60,7 @@ export class CuboCrdt<T extends CuboApiEntitiesMap<T>> {
|
|
|
60
60
|
|
|
61
61
|
const db = await this.api.helpers.getConnection('write')
|
|
62
62
|
|
|
63
|
-
const [data] = await db.connection.query(`SELECT ${fieldKey} from ${entityAlias} where id
|
|
63
|
+
const [data] = await db.connection.query(`SELECT ${fieldKey} from ${entityAlias} where id = :id`, {
|
|
64
64
|
type: QueryTypes.SELECT,
|
|
65
65
|
replacements: {
|
|
66
66
|
id
|
|
@@ -72,7 +72,6 @@ export class CuboCrdt<T extends CuboApiEntitiesMap<T>> {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
const raw = (data as any)[fieldKey]
|
|
75
|
-
// console.log('raw', raw)
|
|
76
75
|
|
|
77
76
|
if (!raw) {
|
|
78
77
|
return null
|
|
@@ -144,7 +143,7 @@ export class CuboCrdt<T extends CuboApiEntitiesMap<T>> {
|
|
|
144
143
|
],
|
|
145
144
|
onAuthenticate: async (data) => {
|
|
146
145
|
try {
|
|
147
|
-
return onAuthenticate?.(this.api, data)
|
|
146
|
+
return await onAuthenticate?.(this.api, data)
|
|
148
147
|
} catch (err) {
|
|
149
148
|
throw new Error('Ошибка авторизации: ' + err)
|
|
150
149
|
}
|
|
@@ -272,13 +271,13 @@ export class CuboCrdt<T extends CuboApiEntitiesMap<T>> {
|
|
|
272
271
|
}
|
|
273
272
|
|
|
274
273
|
public isCrdtSupported(entity: CuboEntity) {
|
|
275
|
-
const hasCrdtField = entity.fields.some((f) => f.alias === this.api.options.crdt?.fieldAlias || this.defaultCrdtFieldAlias)
|
|
274
|
+
const hasCrdtField = entity.fields.some((f) => f.alias === (this.api.options.crdt?.fieldAlias || this.defaultCrdtFieldAlias))
|
|
276
275
|
|
|
277
276
|
return hasCrdtField
|
|
278
277
|
}
|
|
279
278
|
|
|
280
279
|
public getCrdtField(entity: CuboEntity) {
|
|
281
|
-
const crdtField = entity.fields.find((f) => f.alias === this.api.options.crdt?.fieldAlias || this.defaultCrdtFieldAlias)
|
|
280
|
+
const crdtField = entity.fields.find((f) => f.alias === (this.api.options.crdt?.fieldAlias || this.defaultCrdtFieldAlias))
|
|
282
281
|
|
|
283
282
|
return crdtField
|
|
284
283
|
}
|
package/src/index.ts
CHANGED
|
@@ -27,12 +27,12 @@ export class CuboBackendApi<T extends CuboApiEntitiesMap<T>> {
|
|
|
27
27
|
throw { code: 403, text: 'Авторизация Cubo-Backend не пройдена' }
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
if (this.auth.variables
|
|
30
|
+
if (this.auth.variables?.db !== undefined) {
|
|
31
31
|
this.options.db = this.options.db || {}
|
|
32
32
|
|
|
33
33
|
this.options.db.options = {
|
|
34
34
|
...(this.options.db.options || {}),
|
|
35
|
-
...(this.auth.variables
|
|
35
|
+
...(this.auth.variables?.db || {})
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
} catch (e) {
|