@contember/engine-content-api 1.2.0-alpha.15 → 1.2.0-alpha.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contember/engine-content-api",
3
- "version": "1.2.0-alpha.15",
3
+ "version": "1.2.0-alpha.17",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/src/index.js",
6
6
  "typings": "dist/src/index.d.ts",
@@ -10,19 +10,20 @@
10
10
  "test": "vitest --no-threads"
11
11
  },
12
12
  "dependencies": {
13
- "@contember/database": "^1.2.0-alpha.15",
14
- "@contember/dic": "^1.2.0-alpha.15",
15
- "@contember/engine-common": "^1.2.0-alpha.15",
16
- "@contember/graphql-utils": "^1.2.0-alpha.15",
17
- "@contember/schema": "^1.2.0-alpha.15",
18
- "@contember/schema-utils": "^1.2.0-alpha.15",
13
+ "@contember/database": "^1.2.0-alpha.17",
14
+ "@contember/dic": "^1.2.0-alpha.17",
15
+ "@contember/engine-common": "^1.2.0-alpha.17",
16
+ "@contember/logger": "^1.2.0-alpha.17",
17
+ "@contember/graphql-utils": "^1.2.0-alpha.17",
18
+ "@contember/schema": "^1.2.0-alpha.17",
19
+ "@contember/schema-utils": "^1.2.0-alpha.17",
19
20
  "@graphql-tools/schema": "^8.3.5",
20
21
  "graphql-tag": "^2.12.5"
21
22
  },
22
23
  "devDependencies": {
23
- "@contember/database-tester": "^1.2.0-alpha.15",
24
- "@contember/engine-api-tester": "^1.2.0-alpha.15",
25
- "@contember/schema-definition": "^1.2.0-alpha.15",
24
+ "@contember/database-tester": "^1.2.0-alpha.17",
25
+ "@contember/engine-api-tester": "^1.2.0-alpha.17",
26
+ "@contember/schema-definition": "^1.2.0-alpha.17",
26
27
  "@graphql-codegen/cli": "^2.6.2",
27
28
  "@graphql-codegen/typescript": "^2.5.1",
28
29
  "@graphql-codegen/typescript-operations": "^2.4.2",
@@ -12,6 +12,7 @@ import * as Database from '@contember/database'
12
12
  import { UniqueWhereError } from '../inputProcessing'
13
13
  import { Model } from '@contember/schema'
14
14
  import { isOwningRelation, isRelation, NamingHelper } from '@contember/schema-utils'
15
+ import { logger } from '@contember/logger'
15
16
  import RelationType = Model.RelationType
16
17
 
17
18
 
@@ -108,8 +109,7 @@ export const convertError = (schema: Model.Schema, e: any): MutationResult => {
108
109
  return new MutationSqlError([], e.originalMessage, [MutationResultHint.subSequentSqlError])
109
110
  }
110
111
  if (e instanceof Database.QueryError) {
111
- // eslint-disable-next-line no-console
112
- console.error(e)
112
+ logger.error(e, { loc: 'convertError' })
113
113
  return new MutationSqlError([], e.originalMessage, [MutationResultHint.sqlError])
114
114
  }
115
115
  throw e
@@ -3,9 +3,9 @@ import {
3
3
  ConditionBuilder,
4
4
  FieldsVisitorFactory,
5
5
  JoinBuilder,
6
- RelationFetcher,
7
6
  MetaHandler,
8
7
  OrderByBuilder,
8
+ RelationFetcher,
9
9
  WhereBuilder,
10
10
  } from './select'
11
11
  import { UniqueWhereExpander } from '../inputProcessing'
@@ -2,6 +2,7 @@ import { Input, Model, Value } from '@contember/schema'
2
2
  import { convertError } from './ErrorUtils'
3
3
  import { getFulfilledValues, getRejections } from '../utils'
4
4
  import { SerializationFailureError } from '@contember/database'
5
+ import { logger } from '@contember/logger'
5
6
 
6
7
  export enum MutationResultType {
7
8
  ok = 'ok',
@@ -225,10 +226,7 @@ export const collectResults = async (
225
226
  const failures = getRejections(results)
226
227
  if (failures.length > 0) {
227
228
  if (failures.length > 1 && !failures.every(it => it instanceof SerializationFailureError)) {
228
- // eslint-disable-next-line no-console
229
- console.error('Multiple error has occurred, printing them & rethrowing the first one')
230
- // eslint-disable-next-line no-console
231
- failures.slice(1).map(e => console.error(e))
229
+ failures.slice(1).map(e => logger.error(e))
232
230
  }
233
231
  throw failures[0]
234
232
  }
@@ -1,6 +1,7 @@
1
1
  import { Path } from './Path'
2
2
  import { Value } from '@contember/schema'
3
3
  import { getFulfilledValues, getRejections } from '../../utils'
4
+ import { logger } from '@contember/logger'
4
5
 
5
6
  type DataPromises = {
6
7
  path: Path
@@ -109,10 +110,7 @@ export class SelectHydrator {
109
110
  const failures = getRejections(results)
110
111
  if (failures.length > 0) {
111
112
  if (failures.length > 1) {
112
- // eslint-disable-next-line no-console
113
- console.error('Multiple error has occurred, printing them & rethrowing the first one')
114
- // eslint-disable-next-line no-console
115
- failures.slice(1).map(e => console.error(e))
113
+ failures.slice(1).map(e => logger.error(e, { loc: 'SelectHydrator' }))
116
114
  }
117
115
  throw failures[0]
118
116
  }
@@ -2,7 +2,6 @@ import { Input, Model, Value } from '@contember/schema'
2
2
  import { Mapper } from '../Mapper'
3
3
  import { UpdateBuilder } from './UpdateBuilder'
4
4
  import { UpdateInputProcessor } from '../../inputProcessing'
5
- import * as Context from '../../inputProcessing'
6
5
  import {
7
6
  ConstraintType,
8
7
  getInsertPrimary,
@@ -17,6 +16,7 @@ import { hasManyProcessor, hasOneProcessor } from '../MutationProcessorHelper'
17
16
  import { AbortUpdate } from './Updater'
18
17
  import { ImplementationException } from '../../exception'
19
18
  import { CheckedPrimary } from '../CheckedPrimary'
19
+ import { logger } from '@contember/logger'
20
20
 
21
21
  export class SqlUpdateInputProcessor implements UpdateInputProcessor<MutationResultList> {
22
22
  constructor(
@@ -228,10 +228,7 @@ export class SqlUpdateInputProcessor implements UpdateInputProcessor<MutationRes
228
228
  return [new MutationConstraintViolationError([], ConstraintType.notNull)]
229
229
  }
230
230
  if (relation.joiningColumn.onDelete === Model.OnDelete.restrict) {
231
- // eslint-disable-next-line no-console
232
- console.error(
233
- '[DEPRECATED] You are deleting an entity over the relation where onDelete behaviour is set to restrict. This will fail in next version.',
234
- )
231
+ logger.warn('You are deleting an entity over the relation where onDelete behaviour is set to restrict. This will fail in next version.', { loc: 'SqlUpdateInputProcessor' })
235
232
  this.updateBuilder.addFieldValue(relation.name, null)
236
233
  }
237
234
  const inversePrimary = await this.mapper.selectField(
@@ -490,10 +487,7 @@ export class SqlUpdateInputProcessor implements UpdateInputProcessor<MutationRes
490
487
  return [new MutationConstraintViolationError([], ConstraintType.notNull)]
491
488
  }
492
489
  if (relation.joiningColumn.onDelete === Model.OnDelete.restrict) {
493
- // eslint-disable-next-line no-console
494
- console.error(
495
- '[DEPRECATED] You are deleting an entity over the relation where onDelete behaviour is set to restrict. This will fail in next version.',
496
- )
490
+ logger.warn('You are deleting an entity over the relation where onDelete behaviour is set to restrict. This will fail in next version.', { loc: 'SqlUpdateInputProcessor' })
497
491
  this.updateBuilder.addFieldValue(relation.name, null)
498
492
  }
499
493
  const targetPrimary = await this.mapper.selectField(
@@ -2,13 +2,13 @@ import { Input, Model, Result, Value } from '@contember/schema'
2
2
  import {
3
3
  ConstraintType,
4
4
  getInsertPrimary,
5
- getUpdatePrimary,
6
5
  InputErrorKind,
7
6
  Mapper,
8
7
  MapperFactory,
9
8
  MutationResultHint,
10
9
  MutationResultList,
11
- MutationResultType, tryMutation,
10
+ MutationResultType,
11
+ tryMutation,
12
12
  } from '../mapper'
13
13
  import { ValidationResolver } from './ValidationResolver'
14
14
  import { GraphQLResolveInfo } from 'graphql'
@@ -20,6 +20,7 @@ import { assertNever } from '../utils'
20
20
  import { InputPreValidator } from '../input-validation'
21
21
  import { ObjectNode } from '../inputProcessing'
22
22
  import { executeReadOperations } from './ReadHelpers'
23
+ import { logger } from '@contember/logger'
23
24
 
24
25
  type WithoutNode<T extends { node: any }> = Pick<T, Exclude<keyof T, 'node'>>
25
26
 
@@ -479,6 +480,7 @@ export class MutationResolver {
479
480
  return result
480
481
  })
481
482
  },
483
+ message => logger.warn(message),
482
484
  {
483
485
  maxAttempts: 15,
484
486
  minTimeout: 10,
package/src/tsconfig.json CHANGED
@@ -8,23 +8,26 @@
8
8
  {
9
9
  "path": "../../database/src"
10
10
  },
11
+ {
12
+ "path": "../../dic/src"
13
+ },
11
14
  {
12
15
  "path": "../../engine-common/src"
13
16
  },
14
17
  {
15
- "path": "../../schema/src"
18
+ "path": "../../graphql-utils/src"
16
19
  },
17
20
  {
18
- "path": "../../schema-definition/src"
21
+ "path": "../../logger/src"
19
22
  },
20
23
  {
21
- "path": "../../schema-utils/src"
24
+ "path": "../../schema/src"
22
25
  },
23
26
  {
24
- "path": "../../dic/src"
27
+ "path": "../../schema-definition/src"
25
28
  },
26
29
  {
27
- "path": "../../graphql-utils/src"
30
+ "path": "../../schema-utils/src"
28
31
  }
29
32
  ]
30
33
  }
package/tests/src/test.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Acl, Model, Schema, Validation } from '@contember/schema'
2
- import { ExecutionContainerFactory, GraphQlSchemaBuilderFactory, Authorizator } from '../../src'
2
+ import { Authorizator, ExecutionContainerFactory, GraphQlSchemaBuilderFactory } from '../../src'
3
3
  import { AllowAllPermissionFactory, emptySchema } from '@contember/schema-utils'
4
4
  import { executeGraphQlTest } from './testGraphql'
5
5
  import { Client } from '@contember/database'