@cuboapp/api-backend 1.0.34 → 1.0.35

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.34",
3
+ "version": "1.0.35",
4
4
  "description": "Backend Api for CuboApp",
5
5
  "main": "src/index.ts",
6
6
  "repository": "git@github.com:cuboapp/api-backend.git",
@@ -10,7 +10,7 @@
10
10
  "dependencies": {
11
11
  "@cuboapp/constants": "2.0.8",
12
12
  "@cuboapp/crdt": "1.0.11",
13
- "@cuboapp/database": "1.0.4",
13
+ "@cuboapp/database": "1.0.5",
14
14
  "@cuboapp/types": "2.0.13",
15
15
  "@cuboapp/utils": "1.0.10",
16
16
  "@cuboapp/ws": "1.0.6",
@@ -2,11 +2,7 @@ import { CUBO_ENTITY_FIELD_TYPE } from '@cuboapp/constants'
2
2
  import { CuboApiEntitiesMap, CuboEntityField } from '@cuboapp/types'
3
3
  import { keyBy } from '@cuboapp/utils'
4
4
 
5
- import { ApiHelpers } from '.'
6
-
7
5
  export class ApiHelpersData<T extends CuboApiEntitiesMap<T>> {
8
- constructor(private helpers: ApiHelpers<T>) {}
9
-
10
6
  public prepare(type: 'create' | 'update' | 'delete', fields: CuboEntityField[], dto?: any, performer_id?: number) {
11
7
  const fieldsByAlias = keyBy(fields, (i) => i.alias)
12
8
 
@@ -15,11 +11,11 @@ export class ApiHelpersData<T extends CuboApiEntitiesMap<T>> {
15
11
 
16
12
  switch (type) {
17
13
  case 'create':
18
- prepared.created_at = dto.created_at !== undefined ? dto.created_at : new Date().toISOString()
14
+ prepared.created_at = dto.created_at !== undefined ? dto.created_at : new Date()
19
15
  prepared.created_by = dto.created_by !== undefined ? dto.created_by : performer_id
20
16
  break
21
17
  case 'update':
22
- prepared.modified_at = dto.modified_at !== undefined ? dto.modified_at : new Date().toISOString()
18
+ prepared.modified_at = dto.modified_at !== undefined ? dto.modified_at : new Date()
23
19
  prepared.modified_by = dto.modified_by !== undefined ? dto.modified_by : performer_id
24
20
 
25
21
  if (dto?.deleted_at !== undefined) {
@@ -24,7 +24,7 @@ export class ApiHelpers<T extends CuboApiEntitiesMap<T>, A> {
24
24
 
25
25
  public withes = new ApiHelpersWithes<T>(this)
26
26
  public convert = new ApiHelpersConvert<T>(this)
27
- public data = new ApiHelpersData<T>(this)
27
+ public data = new ApiHelpersData<T>()
28
28
 
29
29
  private cache: Record<string, any> = {}
30
30
  private fetching: Record<string, Promise<any> | null> = {}
package/src/index.ts CHANGED
@@ -261,6 +261,7 @@ export class CuboBackendApi<T extends CuboApiEntitiesMap<T>, A extends unknown>
261
261
  throw { status: 400, text: 'No keys to update' }
262
262
  }
263
263
 
264
+ // console.log('dto', dto)
264
265
  // const prepared = dbPrepareInsertQueryString(dto)
265
266
  const db = await this.helpers.getConnection('write')
266
267
  const [created_id] = await db.create(entity.alias, dto, { transaction: opts?.transaction, log: opts?.log })