@cuboapp/api-backend 1.0.15 → 1.0.16

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuboapp/api-backend",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "description": "Backend Api for CuboApp",
5
5
  "main": "src/index.ts",
6
6
  "repository": "git@github.com:cuboapp/api-backend.git",
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=: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
  }