@contember/engine-content-api 2.1.0-alpha.26 → 2.1.0-alpha.27

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.
Files changed (24) hide show
  1. package/dist/development/src/mapper/select/ConditionBuilder.cjs +6 -2
  2. package/dist/development/src/mapper/select/ConditionBuilder.cjs.map +1 -1
  3. package/dist/development/src/mapper/select/ConditionBuilder.js +7 -3
  4. package/dist/development/src/mapper/select/ConditionBuilder.js.map +1 -1
  5. package/dist/development/src/schema/ConditionTypeProvider.cjs +2 -0
  6. package/dist/development/src/schema/ConditionTypeProvider.cjs.map +1 -1
  7. package/dist/development/src/schema/ConditionTypeProvider.js +2 -0
  8. package/dist/development/src/schema/ConditionTypeProvider.js.map +1 -1
  9. package/dist/production/src/mapper/select/ConditionBuilder.cjs +6 -2
  10. package/dist/production/src/mapper/select/ConditionBuilder.cjs.map +1 -1
  11. package/dist/production/src/mapper/select/ConditionBuilder.js +7 -3
  12. package/dist/production/src/mapper/select/ConditionBuilder.js.map +1 -1
  13. package/dist/production/src/schema/ConditionTypeProvider.cjs +2 -0
  14. package/dist/production/src/schema/ConditionTypeProvider.cjs.map +1 -1
  15. package/dist/production/src/schema/ConditionTypeProvider.js +2 -0
  16. package/dist/production/src/schema/ConditionTypeProvider.js.map +1 -1
  17. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  18. package/dist/types/mapper/select/ConditionBuilder.d.ts.map +1 -1
  19. package/dist/types/schema/ConditionTypeProvider.d.ts.map +1 -1
  20. package/dist/types/tsconfig.tsbuildinfo +1 -1
  21. package/package.json +1 -1
  22. package/src/mapper/select/ConditionBuilder.ts +10 -4
  23. package/src/schema/ConditionTypeProvider.ts +3 -0
  24. package/tests/cases/integration/graphQlSchema/schema-column-types.gql +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contember/engine-content-api",
3
- "version": "2.1.0-alpha.26",
3
+ "version": "2.1.0-alpha.27",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/production/index.js",
6
6
  "typings": "./dist/types/index.d.ts",
@@ -50,11 +50,17 @@ export class ConditionBuilder {
50
50
  gte: (builder, value) => builder.compare(columnIdentifier, Operator.gte, value),
51
51
 
52
52
  includes: (builder, value) => {
53
- const cast = columnType.type === Model.ColumnType.Enum
54
- ? `${Compiler.SCHEMA_PLACEHOLDER}."${columnType.columnType}"`
55
- : columnType.columnType
53
+ if (columnType.type === Model.ColumnType.Json) {
54
+ // For JSON columns, use @> operator to check if JSON contains the value
55
+ return builder.raw(`${formatColumnIdentifier(columnIdentifier)} @> ?::jsonb`, JSON.stringify(value))
56
+ } else {
57
+ // For array columns, use @> operator with array casting
58
+ const cast = columnType.type === Model.ColumnType.Enum
59
+ ? `${Compiler.SCHEMA_PLACEHOLDER}."${columnType.columnType}"`
60
+ : columnType.columnType
56
61
 
57
- return builder.raw(`${formatColumnIdentifier(columnIdentifier)} @> ARRAY[?]::${cast}[]`, value)
62
+ return builder.raw(`${formatColumnIdentifier(columnIdentifier)} @> ARRAY[?]::${cast}[]`, value)
63
+ }
58
64
  },
59
65
  maxLength: (builder, value) => builder.raw(`array_length(${formatColumnIdentifier(columnIdentifier)}, 1) <= ?`, value),
60
66
  minLength: (builder, value) => builder.raw(`array_length(${formatColumnIdentifier(columnIdentifier)}, 1) >= ?`, value),
@@ -60,6 +60,9 @@ export class ConditionTypeProvider {
60
60
  conditions.lte = { type: type }
61
61
  conditions.gt = { type: type }
62
62
  conditions.gte = { type: type }
63
+ } else {
64
+ // For JSON columns, add the includes operator
65
+ conditions.includes = { type: type }
63
66
  }
64
67
  if (column.type === Model.ColumnType.String) {
65
68
  conditions.contains = { type: GraphQLString }
@@ -204,6 +204,7 @@ input JsonCondition {
204
204
  not: JsonCondition
205
205
  null: Boolean
206
206
  isNull: Boolean
207
+ includes: Json
207
208
  }
208
209
 
209
210
  input TimeCondition {