@contember/engine-content-api 2.0.0-alpha.36 → 2.0.0-alpha.38
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/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +31 -6
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +31 -6
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
- package/dist/development/src/input-validation/ColumnValueResolver.cjs.map +1 -1
- package/dist/development/src/input-validation/ColumnValueResolver.js.map +1 -1
- package/dist/development/src/input-validation/preValidation/CreateInputPreValidationProcessor.cjs.map +1 -1
- package/dist/development/src/input-validation/preValidation/CreateInputPreValidationProcessor.js.map +1 -1
- package/dist/development/src/input-validation/preValidation/InputPreValidator.cjs.map +1 -1
- package/dist/development/src/input-validation/preValidation/InputPreValidator.js.map +1 -1
- package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
- package/dist/development/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
- package/dist/development/src/inputProcessing/CreateInputVisitor.cjs +6 -7
- package/dist/development/src/inputProcessing/CreateInputVisitor.cjs.map +1 -1
- package/dist/development/src/inputProcessing/CreateInputVisitor.js +6 -7
- package/dist/development/src/inputProcessing/CreateInputVisitor.js.map +1 -1
- package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs +14 -15
- package/dist/development/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
- package/dist/development/src/inputProcessing/UpdateInputVisitor.js +14 -15
- package/dist/development/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
- package/dist/development/src/mapper/ColumnValue.cjs +8 -18
- package/dist/development/src/mapper/ColumnValue.cjs.map +1 -1
- package/dist/development/src/mapper/ColumnValue.js +8 -18
- package/dist/development/src/mapper/ColumnValue.js.map +1 -1
- package/dist/development/src/mapper/EventManager.cjs +1 -1
- package/dist/development/src/mapper/EventManager.cjs.map +1 -1
- package/dist/development/src/mapper/EventManager.js +1 -1
- package/dist/development/src/mapper/EventManager.js.map +1 -1
- package/dist/development/src/mapper/Mapper.cjs +8 -28
- package/dist/development/src/mapper/Mapper.cjs.map +1 -1
- package/dist/development/src/mapper/Mapper.js +8 -28
- package/dist/development/src/mapper/Mapper.js.map +1 -1
- package/dist/development/src/mapper/Result.cjs.map +1 -1
- package/dist/development/src/mapper/Result.js.map +1 -1
- package/dist/development/src/mapper/delete/DeleteExecutor.cjs +4 -8
- package/dist/development/src/mapper/delete/DeleteExecutor.cjs.map +1 -1
- package/dist/development/src/mapper/delete/DeleteExecutor.js +5 -9
- package/dist/development/src/mapper/delete/DeleteExecutor.js.map +1 -1
- package/dist/development/src/mapper/insert/InsertBuilder.cjs +12 -8
- package/dist/development/src/mapper/insert/InsertBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/insert/InsertBuilder.js +13 -9
- package/dist/development/src/mapper/insert/InsertBuilder.js.map +1 -1
- package/dist/development/src/mapper/insert/Inserter.cjs.map +1 -1
- package/dist/development/src/mapper/insert/Inserter.js.map +1 -1
- package/dist/development/src/mapper/insert/SqlCreateInputProcessor.cjs +1 -3
- package/dist/development/src/mapper/insert/SqlCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/SqlCreateInputProcessor.js +1 -3
- package/dist/development/src/mapper/insert/SqlCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs +3 -5
- package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js +4 -6
- package/dist/development/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs +3 -5
- package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js +4 -6
- package/dist/development/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs +4 -3
- package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js +4 -3
- package/dist/development/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs +3 -5
- package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js +4 -6
- package/dist/development/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs +4 -6
- package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js +5 -7
- package/dist/development/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/UpdateBuilder.cjs +12 -5
- package/dist/development/src/mapper/update/UpdateBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/update/UpdateBuilder.js +13 -6
- package/dist/development/src/mapper/update/UpdateBuilder.js.map +1 -1
- package/dist/development/src/mapper/update/Updater.cjs.map +1 -1
- package/dist/development/src/mapper/update/Updater.js.map +1 -1
- package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +11 -16
- package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +12 -17
- package/dist/development/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs +6 -7
- package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js +7 -8
- package/dist/development/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +5 -4
- package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +5 -4
- package/dist/development/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs +11 -12
- package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js +12 -13
- package/dist/development/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs +8 -12
- package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs.map +1 -1
- package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js +9 -13
- package/dist/development/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +31 -6
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +31 -6
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
- package/dist/production/src/input-validation/ColumnValueResolver.cjs.map +1 -1
- package/dist/production/src/input-validation/ColumnValueResolver.js.map +1 -1
- package/dist/production/src/input-validation/preValidation/CreateInputPreValidationProcessor.cjs.map +1 -1
- package/dist/production/src/input-validation/preValidation/CreateInputPreValidationProcessor.js.map +1 -1
- package/dist/production/src/input-validation/preValidation/InputPreValidator.cjs.map +1 -1
- package/dist/production/src/input-validation/preValidation/InputPreValidator.js.map +1 -1
- package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.cjs.map +1 -1
- package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
- package/dist/production/src/inputProcessing/CreateInputVisitor.cjs +6 -7
- package/dist/production/src/inputProcessing/CreateInputVisitor.cjs.map +1 -1
- package/dist/production/src/inputProcessing/CreateInputVisitor.js +6 -7
- package/dist/production/src/inputProcessing/CreateInputVisitor.js.map +1 -1
- package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs +14 -15
- package/dist/production/src/inputProcessing/UpdateInputVisitor.cjs.map +1 -1
- package/dist/production/src/inputProcessing/UpdateInputVisitor.js +14 -15
- package/dist/production/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
- package/dist/production/src/mapper/ColumnValue.cjs +8 -18
- package/dist/production/src/mapper/ColumnValue.cjs.map +1 -1
- package/dist/production/src/mapper/ColumnValue.js +8 -18
- package/dist/production/src/mapper/ColumnValue.js.map +1 -1
- package/dist/production/src/mapper/EventManager.cjs +1 -1
- package/dist/production/src/mapper/EventManager.cjs.map +1 -1
- package/dist/production/src/mapper/EventManager.js +1 -1
- package/dist/production/src/mapper/EventManager.js.map +1 -1
- package/dist/production/src/mapper/Mapper.cjs +8 -28
- package/dist/production/src/mapper/Mapper.cjs.map +1 -1
- package/dist/production/src/mapper/Mapper.js +8 -28
- package/dist/production/src/mapper/Mapper.js.map +1 -1
- package/dist/production/src/mapper/Result.cjs.map +1 -1
- package/dist/production/src/mapper/Result.js.map +1 -1
- package/dist/production/src/mapper/delete/DeleteExecutor.cjs +4 -8
- package/dist/production/src/mapper/delete/DeleteExecutor.cjs.map +1 -1
- package/dist/production/src/mapper/delete/DeleteExecutor.js +5 -9
- package/dist/production/src/mapper/delete/DeleteExecutor.js.map +1 -1
- package/dist/production/src/mapper/insert/InsertBuilder.cjs +12 -8
- package/dist/production/src/mapper/insert/InsertBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/insert/InsertBuilder.js +13 -9
- package/dist/production/src/mapper/insert/InsertBuilder.js.map +1 -1
- package/dist/production/src/mapper/insert/Inserter.cjs.map +1 -1
- package/dist/production/src/mapper/insert/Inserter.js.map +1 -1
- package/dist/production/src/mapper/insert/SqlCreateInputProcessor.cjs +1 -3
- package/dist/production/src/mapper/insert/SqlCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/SqlCreateInputProcessor.js +1 -3
- package/dist/production/src/mapper/insert/SqlCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs +3 -5
- package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js +4 -6
- package/dist/production/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs +3 -5
- package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js +4 -6
- package/dist/production/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs +4 -3
- package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js +4 -3
- package/dist/production/src/mapper/insert/relations/OneHasManyCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs +3 -5
- package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js +4 -6
- package/dist/production/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs +4 -6
- package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js +5 -7
- package/dist/production/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/SqlUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/UpdateBuilder.cjs +12 -5
- package/dist/production/src/mapper/update/UpdateBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/update/UpdateBuilder.js +13 -6
- package/dist/production/src/mapper/update/UpdateBuilder.js.map +1 -1
- package/dist/production/src/mapper/update/Updater.cjs.map +1 -1
- package/dist/production/src/mapper/update/Updater.js.map +1 -1
- package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs +11 -16
- package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js +12 -17
- package/dist/production/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs +6 -7
- package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js +7 -8
- package/dist/production/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs +5 -4
- package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js +5 -4
- package/dist/production/src/mapper/update/relations/OneHasManyUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs +11 -12
- package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js +12 -13
- package/dist/production/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.js.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs +8 -12
- package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.cjs.map +1 -1
- package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js +9 -13
- package/dist/production/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/insert/jsonInsert.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/insert/jsonInsert.test.d.ts.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.d.ts.map +1 -1
- package/dist/types/input-validation/ColumnValueResolver.d.ts +1 -1
- package/dist/types/input-validation/ColumnValueResolver.d.ts.map +1 -1
- package/dist/types/input-validation/ValidationDataSelector.d.ts +1 -1
- package/dist/types/input-validation/preValidation/CreateInputPreValidationProcessor.d.ts +3 -3
- package/dist/types/input-validation/preValidation/CreateInputPreValidationProcessor.d.ts.map +1 -1
- package/dist/types/input-validation/preValidation/InputPreValidator.d.ts +3 -3
- package/dist/types/input-validation/preValidation/InputPreValidator.d.ts.map +1 -1
- package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts +4 -4
- package/dist/types/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts.map +1 -1
- package/dist/types/inputProcessing/CreateInputProcessor.d.ts +8 -6
- package/dist/types/inputProcessing/CreateInputProcessor.d.ts.map +1 -1
- package/dist/types/inputProcessing/CreateInputVisitor.d.ts +3 -2
- package/dist/types/inputProcessing/CreateInputVisitor.d.ts.map +1 -1
- package/dist/types/inputProcessing/UpdateInputProcessor.d.ts +14 -12
- package/dist/types/inputProcessing/UpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/inputProcessing/UpdateInputVisitor.d.ts +3 -2
- package/dist/types/inputProcessing/UpdateInputVisitor.d.ts.map +1 -1
- package/dist/types/mapper/ColumnValue.d.ts +4 -8
- package/dist/types/mapper/ColumnValue.d.ts.map +1 -1
- package/dist/types/mapper/EventManager.d.ts +9 -9
- package/dist/types/mapper/EventManager.d.ts.map +1 -1
- package/dist/types/mapper/Mapper.d.ts +6 -7
- package/dist/types/mapper/Mapper.d.ts.map +1 -1
- package/dist/types/mapper/Result.d.ts +5 -4
- package/dist/types/mapper/Result.d.ts.map +1 -1
- package/dist/types/mapper/delete/DeleteExecutor.d.ts.map +1 -1
- package/dist/types/mapper/insert/InsertBuilder.d.ts +3 -4
- package/dist/types/mapper/insert/InsertBuilder.d.ts.map +1 -1
- package/dist/types/mapper/insert/Inserter.d.ts +3 -2
- package/dist/types/mapper/insert/Inserter.d.ts.map +1 -1
- package/dist/types/mapper/insert/SqlCreateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/insert/relations/ManyHasManyCreateInputProcessor.d.ts +5 -3
- package/dist/types/mapper/insert/relations/ManyHasManyCreateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/insert/relations/ManyHasOneCreateInputProcessor.d.ts +5 -3
- package/dist/types/mapper/insert/relations/ManyHasOneCreateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/insert/relations/OneHasManyCreateInputProcessor.d.ts +5 -3
- package/dist/types/mapper/insert/relations/OneHasManyCreateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.d.ts +5 -3
- package/dist/types/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.d.ts +5 -3
- package/dist/types/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/types.d.ts +84 -1
- package/dist/types/mapper/types.d.ts.map +1 -1
- package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts +2 -1
- package/dist/types/mapper/update/SqlUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/UpdateBuilder.d.ts +3 -3
- package/dist/types/mapper/update/UpdateBuilder.d.ts.map +1 -1
- package/dist/types/mapper/update/Updater.d.ts +2 -1
- package/dist/types/mapper/update/Updater.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts +5 -3
- package/dist/types/mapper/update/relations/ManyHasManyUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/ManyHasOneUpdateInputProcessor.d.ts +6 -4
- package/dist/types/mapper/update/relations/ManyHasOneUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts +5 -3
- package/dist/types/mapper/update/relations/OneHasManyUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.d.ts +6 -4
- package/dist/types/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.d.ts +6 -4
- package/dist/types/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts +35 -2
- package/src/input-validation/ColumnValueResolver.ts +1 -1
- package/src/input-validation/preValidation/CreateInputPreValidationProcessor.ts +2 -2
- package/src/input-validation/preValidation/InputPreValidator.ts +7 -7
- package/src/input-validation/preValidation/UpdateInputPreValidationProcessor.ts +3 -3
- package/src/inputProcessing/CreateInputProcessor.ts +8 -6
- package/src/inputProcessing/CreateInputVisitor.ts +18 -19
- package/src/inputProcessing/UpdateInputProcessor.ts +13 -11
- package/src/inputProcessing/UpdateInputVisitor.ts +25 -24
- package/src/mapper/ColumnValue.ts +11 -25
- package/src/mapper/EventManager.ts +6 -6
- package/src/mapper/Mapper.ts +19 -37
- package/src/mapper/Result.ts +3 -2
- package/src/mapper/delete/DeleteExecutor.ts +4 -8
- package/src/mapper/insert/InsertBuilder.ts +20 -17
- package/src/mapper/insert/Inserter.ts +4 -3
- package/src/mapper/insert/SqlCreateInputProcessor.ts +1 -3
- package/src/mapper/insert/relations/ManyHasManyCreateInputProcessor.ts +8 -8
- package/src/mapper/insert/relations/ManyHasOneCreateInputProcessor.ts +8 -8
- package/src/mapper/insert/relations/OneHasManyCreateInputProcessor.ts +8 -6
- package/src/mapper/insert/relations/OneHasOneInverseCreateInputProcessor.ts +8 -9
- package/src/mapper/insert/relations/OneHasOneOwningCreateInputProcessor.ts +9 -9
- package/src/mapper/types.ts +115 -1
- package/src/mapper/update/SqlUpdateInputProcessor.ts +2 -1
- package/src/mapper/update/UpdateBuilder.ts +20 -12
- package/src/mapper/update/Updater.ts +3 -2
- package/src/mapper/update/relations/ManyHasManyUpdateInputProcessor.ts +15 -19
- package/src/mapper/update/relations/ManyHasOneUpdateInputProcessor.ts +11 -11
- package/src/mapper/update/relations/OneHasManyUpdateInputProcessor.ts +9 -7
- package/src/mapper/update/relations/OneHasOneInverseUpdateInputProcessor.ts +18 -18
- package/src/mapper/update/relations/OneHasOneOwningUpdateInputProcessor.ts +14 -17
- package/tests/cases/integration/graphQlRequests/insert/jsonInsert.test.ts +37 -0
- package/tests/cases/integration/graphQlRequests/query/misc/reducedHasMany.test.ts +69 -0
- package/tests/cases/integration/graphQlRequests/update/manyHasOne/update.test.ts +0 -5
- package/tests/cases/integration/graphQlRequests/update/manyHasOne/upsert.test.ts +0 -5
- package/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/upsert.test.ts +9 -0
- package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/update.test.ts +0 -5
- package/tests/cases/integration/graphQlRequests/update/oneHasOneOwning/upsert.test.ts +0 -5
- package/tests/cases/integration/graphQlSchema/schema-acl-allowed.gql +5 -0
- package/tests/cases/integration/graphQlSchema/schema-acl-restricted-create.gql +5 -0
- package/tests/cases/integration/graphQlSchema/schema-acl-restricted-delete.gql +5 -0
- package/tests/cases/integration/graphQlSchema/schema-acl-restricted-update.gql +5 -0
- package/tests/cases/integration/graphQlSchema/schema-basic.gql +11 -0
- package/tests/cases/integration/graphQlSchema/schema-bug-66.gql +6 -0
- package/tests/cases/integration/graphQlSchema/schema-custom-primary.gql +11 -0
- package/tests/cases/integration/graphQlSchema/schema-has-many-reduction.gql +6 -0
- package/tests/cases/integration/graphQlSchema/schema-new-builder.gql +12 -0
- package/tests/cases/unit/inputPreValidator.test.ts +1 -1
- package/tests/src/testGraphql.ts +1 -1
package/dist/production/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateInputPreValidationProcessor.js","sources":["../../../../../../packages/engine-content-api/src/input-validation/preValidation/UpdateInputPreValidationProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../inputProcessing'\nimport { Input, Model } from '@contember/schema'\nimport { appendRelationToPath, ValidationPath } from '../ValidationPath'\nimport { Mapper } from '../../mapper'\nimport { InputPreValidator } from './InputPreValidator'\n\ntype Result = any\n\nconst NoResult = () => Promise.resolve([])\n\nexport class UpdateInputPreValidationProcessor implements UpdateInputProcessor<Result> {\n\tconstructor(\n\t\tprivate readonly inputValidator: InputPreValidator,\n\t\tprivate readonly path: ValidationPath,\n\t\tprivate readonly mapper: Mapper,\n\t) {}\n\n\tasync column(context: Model.ColumnContext): Promise<Result> {\n\t\treturn []\n\t}\n\n\tmanyHasManyInverse: UpdateInputProcessor.HasManyRelationInputProcessor<Model.ManyHasManyInverseContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate({ ...ctx, input: ctx.input.data }),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\tmanyHasManyOwning: UpdateInputProcessor.HasManyRelationInputProcessor<Model.ManyHasManyOwningContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate({ ...ctx, input: ctx.input.data }),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\tmanyHasOne: UpdateInputProcessor.HasOneRelationInputProcessor<Model.ManyHasOneContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate(ctx),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\toneHasMany: UpdateInputProcessor.HasManyRelationInputProcessor<Model.OneHasManyContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate({ ...ctx, input: ctx.input.data }),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\toneHasOneInverse: UpdateInputProcessor.HasOneRelationInputProcessor<Model.OneHasOneInverseContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate(ctx),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\n\toneHasOneOwning: UpdateInputProcessor.HasOneRelationInputProcessor<Model.OneHasOneOwningContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate(ctx),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\n\tasync processCreate(context: {\n\t\ttargetEntity: Model.Entity\n\t\trelation: Model.AnyRelation\n\t\ttargetRelation: Model.AnyRelation | null\n\t\tinput:
|
|
1
|
+
{"version":3,"file":"UpdateInputPreValidationProcessor.js","sources":["../../../../../../packages/engine-content-api/src/input-validation/preValidation/UpdateInputPreValidationProcessor.ts"],"sourcesContent":["import { UpdateInputProcessor } from '../../inputProcessing'\nimport { Input, Model } from '@contember/schema'\nimport { appendRelationToPath, ValidationPath } from '../ValidationPath'\nimport { Mapper, MapperInput } from '../../mapper'\nimport { InputPreValidator } from './InputPreValidator'\n\ntype Result = any\n\nconst NoResult = () => Promise.resolve([])\n\nexport class UpdateInputPreValidationProcessor implements UpdateInputProcessor<Result> {\n\tconstructor(\n\t\tprivate readonly inputValidator: InputPreValidator,\n\t\tprivate readonly path: ValidationPath,\n\t\tprivate readonly mapper: Mapper,\n\t) {}\n\n\tasync column(context: Model.ColumnContext): Promise<Result> {\n\t\treturn []\n\t}\n\n\tmanyHasManyInverse: UpdateInputProcessor.HasManyRelationInputProcessor<Model.ManyHasManyInverseContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate({ ...ctx, input: ctx.input.data }),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\tmanyHasManyOwning: UpdateInputProcessor.HasManyRelationInputProcessor<Model.ManyHasManyOwningContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate({ ...ctx, input: ctx.input.data }),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\tmanyHasOne: UpdateInputProcessor.HasOneRelationInputProcessor<Model.ManyHasOneContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate(ctx),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\toneHasMany: UpdateInputProcessor.HasManyRelationInputProcessor<Model.OneHasManyContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate({ ...ctx, input: ctx.input.data }),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\toneHasOneInverse: UpdateInputProcessor.HasOneRelationInputProcessor<Model.OneHasOneInverseContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate(ctx),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\n\toneHasOneOwning: UpdateInputProcessor.HasOneRelationInputProcessor<Model.OneHasOneOwningContext, Result> = {\n\t\tcreate: ctx => this.processCreate(ctx),\n\t\tupdate: ctx => this.processUpdate(ctx),\n\t\tupsert: ctx => this.processUpsert(ctx),\n\t\tconnectOrCreate: ctx => this.processCreate({ ...ctx, input: ctx.input.create }),\n\t\tconnect: NoResult,\n\t\tdisconnect: NoResult,\n\t\t['delete']: NoResult,\n\t}\n\n\tasync processCreate(context: {\n\t\ttargetEntity: Model.Entity\n\t\trelation: Model.AnyRelation\n\t\ttargetRelation: Model.AnyRelation | null\n\t\tinput: MapperInput.CreateDataInput\n\t\tindex?: number\n\t\talias?: string\n\t}) {\n\t\tconst newPath = appendRelationToPath(this.path, context.relation.name, context)\n\n\t\treturn this.inputValidator.validateCreate({\n\t\t\tentity: context.targetEntity,\n\t\t\tmapper: this.mapper,\n\t\t\tdata: context.input,\n\t\t\tpath: newPath,\n\t\t\toverRelation: context.targetRelation,\n\t\t})\n\t}\n\n\tasync processUpsert(context: {\n\t\ttargetEntity: Model.Entity\n\t\ttargetRelation: Model.AnyRelation | null\n\t\trelation: Model.AnyRelation\n\t\tinput: UpdateInputProcessor.UpsertInput\n\t\tindex?: number\n\t\talias?: string\n\t}) {\n\t\tconst newPath = appendRelationToPath(this.path, context.relation.name, context)\n\t\treturn [\n\t\t\t...(await this.inputValidator.validateUpdate({\n\t\t\t\tentity: context.targetEntity,\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tdata: context.input.update,\n\t\t\t\tpath: newPath,\n\t\t\t\twhere: {}, // todo\n\t\t\t})),\n\t\t\t...(await this.inputValidator.validateCreate({\n\t\t\t\tentity: context.targetEntity,\n\t\t\t\tmapper: this.mapper,\n\t\t\t\tdata: context.input.create,\n\t\t\t\tpath: newPath,\n\t\t\t\toverRelation: context.targetRelation,\n\t\t\t})),\n\t\t]\n\t}\n\n\tasync processUpdate(context: {\n\t\ttargetEntity: Model.Entity\n\t\trelation: Model.AnyRelation\n\t\tinput: MapperInput.UpdateDataInput\n\t\ttargetRelation: Model.AnyRelation | null\n\t\tindex?: number\n\t\talias?: string\n\t}) {\n\t\tconst newPath = appendRelationToPath(this.path, context.relation.name, context)\n\t\treturn this.inputValidator.validateUpdate({\n\t\t\tentity: context.targetEntity,\n\t\t\tmapper: this.mapper,\n\t\t\tdata: context.input,\n\t\t\tpath: newPath,\n\t\t\twhere: {}, // todo,\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";;;;AAQA,MAAM,WAAW,MAAM,QAAQ,QAAQ,EAAE;AAElC,MAAM,kCAA0E;AAAA,EACtF,YACkB,gBACA,MACA,QAChB;AAHgB,SAAA,iBAAA;AACA,SAAA,OAAA;AACA,SAAA,SAAA;AAOgG,kBAAA,MAAA,sBAAA;AAAA,MACjH,QAAQ,CAAA,QAAO,KAAK,cAAc,GAAG;AAAA,MACrC,QAAQ,CAAO,QAAA,KAAK,cAAc,EAAE,GAAG,KAAK,OAAO,IAAI,MAAM,KAAA,CAAM;AAAA,MACnE,QAAQ,CAAA,QAAO,KAAK,cAAc,GAAG;AAAA,MACrC,iBAAiB,CAAO,QAAA,KAAK,cAAc,EAAE,GAAG,KAAK,OAAO,IAAI,MAAM,OAAA,CAAQ;AAAA,MAC9E,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,CAAC,QAAQ,GAAG;AAAA,IAAA,CACb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,CAAA;AAAA;AAAA,MAAC,CACR;AAAA,MACD,GAAI,MAAM,KAAK,eAAe,eAAe;AAAA,QAC5C,QAAQ,QAAQ;AAAA,QAChB,QAAQ,KAAK;AAAA,QACb,MAAM,QAAQ,MAAM;AAAA,QACpB,MAAM;AAAA,QACN,cAAc,QAAQ;AAAA,MACtB,CAAA;AAAA,IACF;AAAA,EAAA;AAAA,EAGD,MAAM,cAAc,SAOjB;AACF,UAAM,UAAU,qBAAqB,KAAK,MAAM,QAAQ,SAAS,MAAM,OAAO;AACvE,WAAA,KAAK,eAAe,eAAe;AAAA,MACzC,QAAQ,QAAQ;AAAA,MAChB,QAAQ,KAAK;AAAA,MACb,MAAM,QAAQ;AAAA,MACd,MAAM;AAAA,MACN,OAAO,CAAA;AAAA;AAAA,IAAC,CACR;AAAA,EAAA;AAEH;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const exception = require("../exception.cjs");
|
|
4
|
-
const isIt = require("../utils/isIt.cjs");
|
|
5
4
|
const object = require("../utils/object.cjs");
|
|
6
5
|
require("@contember/schema-utils");
|
|
7
6
|
const schema = require("@contember/schema");
|
|
@@ -68,13 +67,13 @@ class CreateInputVisitor {
|
|
|
68
67
|
}
|
|
69
68
|
input = object.filterObject(input, (k, v) => v !== null && v !== void 0);
|
|
70
69
|
this.verifyOperations(input);
|
|
71
|
-
if (
|
|
70
|
+
if ("connect" in input) {
|
|
72
71
|
return [await processor.connect({ ...context, input: input.connect })];
|
|
73
72
|
}
|
|
74
|
-
if (
|
|
73
|
+
if ("create" in input) {
|
|
75
74
|
return [await processor.create({ ...context, input: input.create })];
|
|
76
75
|
}
|
|
77
|
-
if (
|
|
76
|
+
if ("connectOrCreate" in input) {
|
|
78
77
|
return [await processor.connectOrCreate({ ...context, input: input.connectOrCreate })];
|
|
79
78
|
}
|
|
80
79
|
throw new exception.ImplementationException();
|
|
@@ -90,13 +89,13 @@ class CreateInputVisitor {
|
|
|
90
89
|
element = object.filterObject(element, (k, v) => v !== null && v !== void 0);
|
|
91
90
|
this.verifyOperations(element);
|
|
92
91
|
let result;
|
|
93
|
-
if (
|
|
92
|
+
if ("connect" in element) {
|
|
94
93
|
result = processor.connect({ ...context, input: element.connect, index: i++, alias });
|
|
95
94
|
}
|
|
96
|
-
if (
|
|
95
|
+
if ("create" in element) {
|
|
97
96
|
result = processor.create({ ...context, input: element.create, index: i++, alias });
|
|
98
97
|
}
|
|
99
|
-
if (
|
|
98
|
+
if ("connectOrCreate" in element) {
|
|
100
99
|
result = processor.connectOrCreate({ ...context, input: element.connectOrCreate, index: i++, alias });
|
|
101
100
|
}
|
|
102
101
|
if (result !== void 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateInputVisitor.cjs","sources":["../../../../../packages/engine-content-api/src/inputProcessing/CreateInputVisitor.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"CreateInputVisitor.cjs","sources":["../../../../../packages/engine-content-api/src/inputProcessing/CreateInputVisitor.ts"],"sourcesContent":["import { filterObject } from '../utils'\nimport { Input, Model } from '@contember/schema'\nimport { CreateInputProcessor } from './CreateInputProcessor'\nimport { ImplementationException, UserError } from '../exception'\nimport { MapperInput } from '../mapper'\n\nexport class CreateInputVisitor<Result> implements\n\tModel.ColumnVisitor<Promise<Result[]>>,\n\tModel.RelationByTypeVisitor<Promise<Result[]>> {\n\n\tconstructor(\n\t\tprivate readonly createInputProcessor: CreateInputProcessor<Result>,\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly data: MapperInput.CreateDataInput,\n\t) {}\n\n\tpublic async visitColumn(context: Model.ColumnContext): Promise<Result[]> {\n\t\treturn [await this.createInputProcessor.column({\n\t\t\t...context,\n\t\t\tinput: this.data[context.column.name] as Input.ColumnValue,\n\t\t})]\n\t}\n\n\tpublic visitManyHasManyInverse(context: Model.ManyHasManyInverseContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.createInputProcessor.manyHasManyInverse,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitManyHasManyOwning(context: Model.ManyHasManyOwningContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.createInputProcessor.manyHasManyOwning,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitManyHasOne(context: Model.ManyHasOneContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.createInputProcessor.manyHasOne,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasMany(context: Model.OneHasManyContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.createInputProcessor.oneHasMany,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasOneInverse(context: Model.OneHasOneInverseContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.createInputProcessor.oneHasOneInverse,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasOneOwning(context: Model.OneHasOneOwningContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.createInputProcessor.oneHasOneOwning,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tprivate async processRelationInput<Context>(\n\t\tprocessor: CreateInputProcessor.HasOneRelationProcessor<Context, Result>,\n\t\tcontext: Context,\n\t\tinput: MapperInput.CreateOneRelationInput | undefined,\n\t): Promise<Result[]> {\n\t\tif (input === undefined || input === null) {\n\t\t\tif (processor.nothing) {\n\t\t\t\treturn [await processor.nothing({ ...context, input: undefined })]\n\t\t\t}\n\t\t\treturn Promise.resolve([])\n\t\t}\n\t\tinput = filterObject(input, (k, v) => v !== null && v !== undefined)\n\t\tthis.verifyOperations(input)\n\t\tif ('connect' in input) {\n\t\t\treturn [await processor.connect({ ...context, input: input.connect })]\n\t\t}\n\t\tif ('create' in input) {\n\t\t\treturn [await processor.create({ ...context, input: input.create })]\n\t\t}\n\t\tif ('connectOrCreate' in input) {\n\t\t\treturn [await processor.connectOrCreate({ ...context, input: input.connectOrCreate })]\n\t\t}\n\t\tthrow new ImplementationException()\n\t}\n\n\tprivate async processManyRelationInput<Context>(\n\t\tprocessor: CreateInputProcessor.HasManyRelationProcessor<Context, Result>,\n\t\tcontext: Context,\n\t\tinput: MapperInput.CreateManyRelationInput | undefined,\n\t): Promise<Result[]> {\n\t\tif (input === undefined || input === null) {\n\t\t\treturn Promise.resolve([])\n\t\t}\n\t\tconst results: Result[] = []\n\t\tlet i = 0\n\t\tfor (let element of input) {\n\t\t\tconst alias = element.alias\n\t\t\telement = filterObject(element, (k, v) => v !== null && v !== undefined)\n\t\t\tthis.verifyOperations(element)\n\t\t\tlet result\n\t\t\tif ('connect' in element) {\n\t\t\t\tresult = processor.connect({ ...context, input: element.connect, index: i++, alias })\n\t\t\t}\n\t\t\tif ('create' in element) {\n\t\t\t\tresult = processor.create({ ...context, input: element.create, index: i++, alias })\n\t\t\t}\n\t\t\tif ('connectOrCreate' in element) {\n\t\t\t\tresult = processor.connectOrCreate({ ...context, input: element.connectOrCreate, index: i++, alias })\n\t\t\t}\n\t\t\tif (result !== undefined) {\n\t\t\t\tresults.push(await result)\n\t\t\t}\n\t\t}\n\t\treturn Promise.all(results)\n\t}\n\n\tprivate verifyOperations(input: object) {\n\t\tconst keys = Object.keys(input).filter(it => it !== 'alias')\n\t\tconst ops = Object.values(Input.CreateRelationOperation) as string[]\n\t\tif (keys.length !== 1 || !ops.includes(keys[0])) {\n\t\t\tconst found = keys.length === 0 ? 'none' : keys.join(', ')\n\t\t\tthrow new UserError(\n\t\t\t\t`Expected exactly one of: ${ops.join(', ')}. ${found} found.`,\n\t\t\t)\n\t\t}\n\t}\n}\n"],"names":["schema","filterObject","ImplementationException","Input","UserError"],"mappings":";;;;;;AAMO,MAAM,mBAEmC;AAAA,EAE/C,YACkB,sBACAA,SACA,MAChB;AAHgB,SAAA,uBAAA;AACA,SAAA,SAAAA;AACA,SAAA,OAAA;AAAA,EAAA;AAAA,EAGlB,MAAa,YAAY,SAAiD;AACzE,WAAO,CAAC,MAAM,KAAK,qBAAqB,OAAO;AAAA,MAC9C,GAAG;AAAA,MACH,OAAO,KAAK,KAAK,QAAQ,OAAO,IAAI;AAAA,IAAA,CACpC,CAAC;AAAA,EAAA;AAAA,EAGI,wBAAwB,SAA0C;AACxE,WAAO,KAAK;AAAA,MACX,KAAK,qBAAqB;AAAA,MAC1B;AAAA,MACA,KAAK,KAAK,QAAQ,SAAS,IAAI;AAAA,IAChC;AAAA,EAAA;AAAA,EAGM,uBAAuB,SAAyC;AACtE,WAAO,KAAK;AAAA,MACX,KAAK,qBAAqB;AAAA,MAC1B;AAAA,MACA,KAAK,KAAK,QAAQ,SAAS,IAAI;AAAA,IAChC;AAAA,EAAA;AAAA,EAGM,gBAAgB,SAAkC;AACxD,WAAO,KAAK;AAAA,MACX,KAAK,qBAAqB;AAAA,MAC1B;AAAA,MACA,KAAK,KAAK,QAAQ,SAAS,IAAI;AAAA,IAChC;AAAA,EAAA;AAAA,EAGM,gBAAgB,SAAkC;AACxD,WAAO,KAAK;AAAA,MACX,KAAK,qBAAqB;AAAA,MAC1B;AAAA,MACA,KAAK,KAAK,QAAQ,SAAS,IAAI;AAAA,IAChC;AAAA,EAAA;AAAA,EAGM,sBAAsB,SAAwC;AACpE,WAAO,KAAK;AAAA,MACX,KAAK,qBAAqB;AAAA,MAC1B;AAAA,MACA,KAAK,KAAK,QAAQ,SAAS,IAAI;AAAA,IAChC;AAAA,EAAA;AAAA,EAGM,qBAAqB,SAAuC;AAClE,WAAO,KAAK;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AA,UAAU,QAAQ,EAAE,GAAG,SAAS,OAAO,QAAQ,SAAS,OAAO,KAAK,MAAA,CAAO;AAAA,MAAA;AAErF,UAAI,YAAY,SAAS;AACf,iBAAA,UAAU,OAAO,EAAE,GAAG,SAAS,OAAO,QAAQ,QAAQ,OAAO,KAAK,MAAA,CAAO;AAAA,MAAA;AAEnF,UAAI,qBAAqB,SAAS;AACxB,iBAAA,UAAU,gBAAgB,EAAE,GAAG,SAAS,OAAO,QAAQ,iBAAiB,OAAO,KAAK,MAAA,CAAO;AAAA,MAAA;AAErG,UAAI,WAAW,QAAW;AACjB,gBAAA,KAAK,MAAM,MAAM;AAAA,MAAA;AAAA,IAC1B;AAEM,WAAA,QAAQ,IAAI,OAAO;AAAA,EAAA;AAAA,EAGnB,iBAAiB,OAAe;AACjC,UAAA,OAAO,OAAO,KAAK,KAAK,EAAE,OAAO,CAAA,OAAM,OAAO,OAAO;AAC3D,UAAM,MAAM,OAAO,OAAOE,OAAAA,MAAM,uBAAuB;AACnD,QAAA,KAAK,WAAW,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC,GAAG;AAChD,YAAM,QAAQ,KAAK,WAAW,IAAI,SAAS,KAAK,KAAK,IAAI;AACzD,YAAM,IAAIC,UAAA;AAAA,QACT,4BAA4B,IAAI,KAAK,IAAI,CAAC,KAAK,KAAK;AAAA,MACrD;AAAA,IAAA;AAAA,EACD;AAEF;;"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ImplementationException, UserError } from "../exception.js";
|
|
2
|
-
import { isIt } from "../utils/isIt.js";
|
|
3
2
|
import { filterObject } from "../utils/object.js";
|
|
4
3
|
import "@contember/schema-utils";
|
|
5
4
|
import { Input } from "@contember/schema";
|
|
@@ -66,13 +65,13 @@ class CreateInputVisitor {
|
|
|
66
65
|
}
|
|
67
66
|
input = filterObject(input, (k, v) => v !== null && v !== void 0);
|
|
68
67
|
this.verifyOperations(input);
|
|
69
|
-
if (
|
|
68
|
+
if ("connect" in input) {
|
|
70
69
|
return [await processor.connect({ ...context, input: input.connect })];
|
|
71
70
|
}
|
|
72
|
-
if (
|
|
71
|
+
if ("create" in input) {
|
|
73
72
|
return [await processor.create({ ...context, input: input.create })];
|
|
74
73
|
}
|
|
75
|
-
if (
|
|
74
|
+
if ("connectOrCreate" in input) {
|
|
76
75
|
return [await processor.connectOrCreate({ ...context, input: input.connectOrCreate })];
|
|
77
76
|
}
|
|
78
77
|
throw new ImplementationException();
|
|
@@ -88,13 +87,13 @@ class CreateInputVisitor {
|
|
|
88
87
|
element = filterObject(element, (k, v) => v !== null && v !== void 0);
|
|
89
88
|
this.verifyOperations(element);
|
|
90
89
|
let result;
|
|
91
|
-
if (
|
|
90
|
+
if ("connect" in element) {
|
|
92
91
|
result = processor.connect({ ...context, input: element.connect, index: i++, alias });
|
|
93
92
|
}
|
|
94
|
-
if (
|
|
93
|
+
if ("create" in element) {
|
|
95
94
|
result = processor.create({ ...context, input: element.create, index: i++, alias });
|
|
96
95
|
}
|
|
97
|
-
if (
|
|
96
|
+
if ("connectOrCreate" in element) {
|
|
98
97
|
result = processor.connectOrCreate({ ...context, input: element.connectOrCreate, index: i++, alias });
|
|
99
98
|
}
|
|
100
99
|
if (result !== void 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateInputVisitor.js","sources":["../../../../../packages/engine-content-api/src/inputProcessing/CreateInputVisitor.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"CreateInputVisitor.js","sources":["../../../../../packages/engine-content-api/src/inputProcessing/CreateInputVisitor.ts"],"sourcesContent":["import { filterObject } from '../utils'\nimport { Input, Model } from '@contember/schema'\nimport { CreateInputProcessor } from './CreateInputProcessor'\nimport { ImplementationException, UserError } from '../exception'\nimport { MapperInput } from '../mapper'\n\nexport class CreateInputVisitor<Result> implements\n\tModel.ColumnVisitor<Promise<Result[]>>,\n\tModel.RelationByTypeVisitor<Promise<Result[]>> {\n\n\tconstructor(\n\t\tprivate readonly createInputProcessor: CreateInputProcessor<Result>,\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly data: MapperInput.CreateDataInput,\n\t) {}\n\n\tpublic async visitColumn(context: Model.ColumnContext): Promise<Result[]> {\n\t\treturn [await this.createInputProcessor.column({\n\t\t\t...context,\n\t\t\tinput: this.data[context.column.name] as Input.ColumnValue,\n\t\t})]\n\t}\n\n\tpublic visitManyHasManyInverse(context: Model.ManyHasManyInverseContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.createInputProcessor.manyHasManyInverse,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitManyHasManyOwning(context: Model.ManyHasManyOwningContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.createInputProcessor.manyHasManyOwning,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitManyHasOne(context: Model.ManyHasOneContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.createInputProcessor.manyHasOne,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasMany(context: Model.OneHasManyContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.createInputProcessor.oneHasMany,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasOneInverse(context: Model.OneHasOneInverseContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.createInputProcessor.oneHasOneInverse,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasOneOwning(context: Model.OneHasOneOwningContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.createInputProcessor.oneHasOneOwning,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tprivate async processRelationInput<Context>(\n\t\tprocessor: CreateInputProcessor.HasOneRelationProcessor<Context, Result>,\n\t\tcontext: Context,\n\t\tinput: MapperInput.CreateOneRelationInput | undefined,\n\t): Promise<Result[]> {\n\t\tif (input === undefined || input === null) {\n\t\t\tif (processor.nothing) {\n\t\t\t\treturn [await processor.nothing({ ...context, input: undefined })]\n\t\t\t}\n\t\t\treturn Promise.resolve([])\n\t\t}\n\t\tinput = filterObject(input, (k, v) => v !== null && v !== undefined)\n\t\tthis.verifyOperations(input)\n\t\tif ('connect' in input) {\n\t\t\treturn [await processor.connect({ ...context, input: input.connect })]\n\t\t}\n\t\tif ('create' in input) {\n\t\t\treturn [await processor.create({ ...context, input: input.create })]\n\t\t}\n\t\tif ('connectOrCreate' in input) {\n\t\t\treturn [await processor.connectOrCreate({ ...context, input: input.connectOrCreate })]\n\t\t}\n\t\tthrow new ImplementationException()\n\t}\n\n\tprivate async processManyRelationInput<Context>(\n\t\tprocessor: CreateInputProcessor.HasManyRelationProcessor<Context, Result>,\n\t\tcontext: Context,\n\t\tinput: MapperInput.CreateManyRelationInput | undefined,\n\t): Promise<Result[]> {\n\t\tif (input === undefined || input === null) {\n\t\t\treturn Promise.resolve([])\n\t\t}\n\t\tconst results: Result[] = []\n\t\tlet i = 0\n\t\tfor (let element of input) {\n\t\t\tconst alias = element.alias\n\t\t\telement = filterObject(element, (k, v) => v !== null && v !== undefined)\n\t\t\tthis.verifyOperations(element)\n\t\t\tlet result\n\t\t\tif ('connect' in element) {\n\t\t\t\tresult = processor.connect({ ...context, input: element.connect, index: i++, alias })\n\t\t\t}\n\t\t\tif ('create' in element) {\n\t\t\t\tresult = processor.create({ ...context, input: element.create, index: i++, alias })\n\t\t\t}\n\t\t\tif ('connectOrCreate' in element) {\n\t\t\t\tresult = processor.connectOrCreate({ ...context, input: element.connectOrCreate, index: i++, alias })\n\t\t\t}\n\t\t\tif (result !== undefined) {\n\t\t\t\tresults.push(await result)\n\t\t\t}\n\t\t}\n\t\treturn Promise.all(results)\n\t}\n\n\tprivate verifyOperations(input: object) {\n\t\tconst keys = Object.keys(input).filter(it => it !== 'alias')\n\t\tconst ops = Object.values(Input.CreateRelationOperation) as string[]\n\t\tif (keys.length !== 1 || !ops.includes(keys[0])) {\n\t\t\tconst found = keys.length === 0 ? 'none' : keys.join(', ')\n\t\t\tthrow new UserError(\n\t\t\t\t`Expected exactly one of: ${ops.join(', ')}. ${found} found.`,\n\t\t\t)\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAMO,MAAM,mBAEmC;AAAA,EAE/C,YACkB,sBACA,QACA,MAChB;AAHgB,SAAA,uBAAA;AACA,SAAA,SAAA;AACA,SAAA,OAAA;AAAA,EAAA;AAAA,EAGlB,MAAa,YAAY,SAAiD;AACzE,WAAO,CAAC,MAAM,KAAK,qBAAqB,OAAO;AAAA,MAC9C,GAAG;AAAA,MACH,OAAO,KAAK,KAAK,QAAQ,OAAO,IAAI;AAAA,IAAA,CACpC,CAAC;AAAA,EAAA;AAAA,EAGI,wBAAwB,SAA0C;AACxE,WAAO,KAAK;AAAA,MACX,KAAK,qBAAqB;AAAA,MAC1B;AAAA,MACA,KAAK,KAAK,QAAQ,SAAS,IAAI;AAAA,IAChC;AAAA,EAAA;AAAA,EAGM,uBAAuB,SAAyC;AACtE,WAAO,KAAK;AAAA,MACX,KAAK,qBAAqB;AAAA,MAC1B;AAAA,MACA,KAAK,KAAK,QAAQ,SAAS,IAAI;AAAA,IAChC;AAAA,EAAA;AAAA,EAGM,gBAAgB,SAAkC;AACxD,WAAO,KAAK;AAAA,MACX,KAAK,qBAAqB;AAAA,MAC1B;AAAA,MACA,KAAK,KAAK,QAAQ,SAAS,IAAI;AAAA,IAChC;AAAA,EAAA;AAAA,EAGM,gBAAgB,SAAkC;AACxD,WAAO,KAAK;AAAA,MACX,KAAK,qBAAqB;AAAA,MAC1B;AAAA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B,UAAM,UAAoB,CAAC;AAC3B,QAAI,IAAI;AACR,aAAS,WAAW,OAAO;AAC1B,YAAM,QAAQ,QAAQ;AACZ,gBAAA,aAAa,SAAS,CAAC,GAAG,MAAM,MAAM,QAAQ,MAAM,MAAS;AACvE,WAAK,iBAAiB,OAAO;AACzB,UAAA;AACJ,UAAI,aAAa,SAAS;AAChB,iBAAA,UAAU,QAAQ,EAAE,GAAG,SAAS,OAAO,QAAQ,SAAS,OAAO,KAAK,MAAA,CAAO;AAAA,MAAA;AAErF,UAAI,YAAY,SAAS;AACf,iBAAA,UAAU,OAAO,EAAE,GAAG,SAAS,OAAO,QAAQ,QAAQ,OAAO,KAAK,MAAA,CAAO;AAAA,MAAA;AAEnF,UAAI,qBAAqB,SAAS;AACxB,iBAAA,UAAU,gBAAgB,EAAE,GAAG,SAAS,OAAO,QAAQ,iBAAiB,OAAO,KAAK,MAAA,CAAO;AAAA,MAAA;AAErG,UAAI,WAAW,QAAW;AACjB,gBAAA,KAAK,MAAM,MAAM;AAAA,MAAA;AAAA,IAC1B;AAEM,WAAA,QAAQ,IAAI,OAAO;AAAA,EAAA;AAAA,EAGnB,iBAAiB,OAAe;AACjC,UAAA,OAAO,OAAO,KAAK,KAAK,EAAE,OAAO,CAAA,OAAM,OAAO,OAAO;AAC3D,UAAM,MAAM,OAAO,OAAO,MAAM,uBAAuB;AACnD,QAAA,KAAK,WAAW,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC,GAAG;AAChD,YAAM,QAAQ,KAAK,WAAW,IAAI,SAAS,KAAK,KAAK,IAAI;AACzD,YAAM,IAAI;AAAA,QACT,4BAA4B,IAAI,KAAK,IAAI,CAAC,KAAK,KAAK;AAAA,MACrD;AAAA,IAAA;AAAA,EACD;AAEF;"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const schema = require("@contember/schema");
|
|
4
4
|
const exception = require("../exception.cjs");
|
|
5
|
-
const isIt = require("../utils/isIt.cjs");
|
|
6
5
|
const object = require("../utils/object.cjs");
|
|
7
6
|
require("@contember/schema-utils");
|
|
8
7
|
class UpdateInputVisitor {
|
|
@@ -66,25 +65,25 @@ class UpdateInputVisitor {
|
|
|
66
65
|
}
|
|
67
66
|
input = object.filterObject(input, (k, v) => v !== null && v !== void 0);
|
|
68
67
|
this.verifyOperations(input);
|
|
69
|
-
if (
|
|
68
|
+
if ("connect" in input) {
|
|
70
69
|
return [await processor.connect({ ...context, input: input.connect })];
|
|
71
70
|
}
|
|
72
|
-
if (
|
|
71
|
+
if ("create" in input) {
|
|
73
72
|
return [await processor.create({ ...context, input: input.create })];
|
|
74
73
|
}
|
|
75
|
-
if (
|
|
74
|
+
if ("connectOrCreate" in input) {
|
|
76
75
|
return [await processor.connectOrCreate({ ...context, input: input.connectOrCreate })];
|
|
77
76
|
}
|
|
78
|
-
if (
|
|
77
|
+
if ("delete" in input) {
|
|
79
78
|
return [await processor.delete({ ...context, input: void 0 })];
|
|
80
79
|
}
|
|
81
|
-
if (
|
|
80
|
+
if ("disconnect" in input) {
|
|
82
81
|
return [await processor.disconnect({ ...context, input: void 0 })];
|
|
83
82
|
}
|
|
84
|
-
if (
|
|
83
|
+
if ("update" in input) {
|
|
85
84
|
return [await processor.update({ ...context, input: input.update })];
|
|
86
85
|
}
|
|
87
|
-
if (
|
|
86
|
+
if ("upsert" in input) {
|
|
88
87
|
return [await processor.upsert({ ...context, input: input.upsert })];
|
|
89
88
|
}
|
|
90
89
|
throw new exception.ImplementationException();
|
|
@@ -100,22 +99,22 @@ class UpdateInputVisitor {
|
|
|
100
99
|
element = object.filterObject(element, (k, v) => v !== null && v !== void 0);
|
|
101
100
|
this.verifyOperations(element);
|
|
102
101
|
let result;
|
|
103
|
-
if (
|
|
102
|
+
if ("connect" in element) {
|
|
104
103
|
result = processor.connect({ ...context, input: element.connect, index: i, alias });
|
|
105
104
|
}
|
|
106
|
-
if (
|
|
105
|
+
if ("create" in element) {
|
|
107
106
|
result = processor.create({ ...context, input: element.create, index: i, alias });
|
|
108
107
|
}
|
|
109
|
-
if (
|
|
108
|
+
if ("connectOrCreate" in element) {
|
|
110
109
|
result = processor.connectOrCreate({ ...context, input: element.connectOrCreate, index: i, alias });
|
|
111
110
|
}
|
|
112
|
-
if (
|
|
111
|
+
if ("delete" in element) {
|
|
113
112
|
result = processor.delete({ ...context, input: element.delete, index: i, alias });
|
|
114
113
|
}
|
|
115
|
-
if (
|
|
114
|
+
if ("disconnect" in element) {
|
|
116
115
|
result = processor.disconnect({ ...context, input: element.disconnect, index: i, alias });
|
|
117
116
|
}
|
|
118
|
-
if (
|
|
117
|
+
if ("update" in element) {
|
|
119
118
|
result = processor.update({
|
|
120
119
|
...context,
|
|
121
120
|
input: { where: element.update.by, data: element.update.data },
|
|
@@ -123,7 +122,7 @@ class UpdateInputVisitor {
|
|
|
123
122
|
alias
|
|
124
123
|
});
|
|
125
124
|
}
|
|
126
|
-
if (
|
|
125
|
+
if ("upsert" in element) {
|
|
127
126
|
result = processor.upsert({
|
|
128
127
|
...context,
|
|
129
128
|
input: { where: element.upsert.by, update: element.upsert.update, create: element.upsert.create },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateInputVisitor.cjs","sources":["../../../../../packages/engine-content-api/src/inputProcessing/UpdateInputVisitor.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { filterObject, isIt } from '../utils'\nimport { UpdateInputProcessor } from './UpdateInputProcessor'\nimport { ImplementationException, UserError } from '../exception'\n\nexport class UpdateInputVisitor<Result> implements\n\tModel.ColumnVisitor<Promise<Result[]>>,\n\tModel.RelationByTypeVisitor<Promise<Result[]>> {\n\n\tconstructor(\n\t\tprivate readonly updateInputProcessor: UpdateInputProcessor<Result>,\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly data: Input.UpdateDataInput,\n\t) {}\n\n\tpublic async visitColumn({ entity, column }: Model.ColumnContext): Promise<Result[]> {\n\t\treturn [await this.updateInputProcessor.column({\n\t\t\tentity,\n\t\t\tcolumn,\n\t\t\tinput: this.data[column.name] as Input.ColumnValue,\n\t\t})]\n\t}\n\n\tpublic visitManyHasManyInverse(context: Model.ManyHasManyInverseContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.updateInputProcessor.manyHasManyInverse,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as Input.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitManyHasManyOwning(context: Model.ManyHasManyOwningContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.updateInputProcessor.manyHasManyOwning,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as Input.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitManyHasOne(context: Model.ManyHasOneContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.updateInputProcessor.manyHasOne,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as Input.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasMany(context: Model.OneHasManyContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.updateInputProcessor.oneHasMany,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as Input.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasOneInverse(context: Model.OneHasOneInverseContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.updateInputProcessor.oneHasOneInverse,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as Input.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasOneOwning(context: Model.OneHasOneOwningContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.updateInputProcessor.oneHasOneOwning,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as Input.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tprivate async processRelationInput<Context>(\n\t\tprocessor: UpdateInputProcessor.HasOneRelationInputProcessor<Context, Result>,\n\t\tcontext: Context,\n\t\tinput: Input.UpdateOneRelationInput | undefined,\n\t): Promise< Result[]> {\n\t\tif (input === undefined || input === null) {\n\t\t\treturn Promise.resolve([])\n\t\t}\n\t\tinput = filterObject(input, (k, v) => v !== null && v !== undefined)\n\t\tthis.verifyOperations(input)\n\t\tif (isIt<Input.ConnectRelationInput>(input, 'connect')) {\n\t\t\treturn [await processor.connect({ ...context, input: input.connect })]\n\t\t}\n\t\tif (isIt<Input.CreateRelationInput>(input, 'create')) {\n\t\t\treturn [await processor.create({ ...context, input: input.create })]\n\t\t}\n\t\tif (isIt<Input.ConnectOrCreateRelationInput>(input, 'connectOrCreate')) {\n\t\t\treturn [await processor.connectOrCreate({ ...context, input: input.connectOrCreate })]\n\t\t}\n\t\tif (isIt<Input.DeleteRelationInput>(input, 'delete')) {\n\t\t\treturn [await processor.delete({ ...context, input: undefined })]\n\t\t}\n\t\tif (isIt<Input.DisconnectRelationInput>(input, 'disconnect')) {\n\t\t\treturn [await processor.disconnect({ ...context, input: undefined })]\n\t\t}\n\t\tif (isIt<Input.UpdateRelationInput>(input, 'update')) {\n\t\t\treturn [await processor.update({ ...context, input: input.update })]\n\t\t}\n\t\tif (isIt<Input.UpsertRelationInput>(input, 'upsert')) {\n\t\t\treturn [await processor.upsert({ ...context, input: input.upsert })]\n\t\t}\n\t\tthrow new ImplementationException()\n\t}\n\n\tprivate async processManyRelationInput<Context>(\n\t\tprocessor: UpdateInputProcessor.HasManyRelationInputProcessor<Context, Result>,\n\t\tcontext: Context,\n\t\tinput: Input.UpdateManyRelationInput | undefined,\n\t): Promise<Result[]> {\n\t\tif (input === undefined || input === null) {\n\t\t\treturn Promise.resolve([])\n\t\t}\n\t\tconst results: Array<Result> = []\n\t\tlet i = 0\n\t\tfor (let element of input) {\n\t\t\tconst alias = element.alias\n\t\t\telement = filterObject(element, (k, v) => v !== null && v !== undefined)\n\t\t\tthis.verifyOperations(element)\n\t\t\tlet result\n\t\t\tif (isIt<Input.ConnectRelationInput>(element, 'connect')) {\n\t\t\t\tresult = processor.connect({ ...context, input: element.connect, index: i, alias })\n\t\t\t}\n\t\t\tif (isIt<Input.CreateRelationInput>(element, 'create')) {\n\t\t\t\tresult = processor.create({ ...context, input: element.create, index: i, alias })\n\t\t\t}\n\t\t\tif (isIt<Input.ConnectOrCreateRelationInput>(element, 'connectOrCreate')) {\n\t\t\t\tresult = processor.connectOrCreate({ ...context, input: element.connectOrCreate, index: i, alias })\n\t\t\t}\n\t\t\tif (isIt<Input.DeleteSpecifiedRelationInput>(element, 'delete')) {\n\t\t\t\tresult = processor.delete({ ...context, input: element.delete, index: i, alias })\n\t\t\t}\n\t\t\tif (isIt<Input.DisconnectSpecifiedRelationInput>(element, 'disconnect')) {\n\t\t\t\tresult = processor.disconnect({ ...context, input: element.disconnect, index: i, alias })\n\t\t\t}\n\t\t\tif (isIt<Input.UpdateSpecifiedRelationInput>(element, 'update')) {\n\t\t\t\tresult = processor.update({\n\t\t\t\t\t...context,\n\t\t\t\t\tinput: { where: element.update.by, data: element.update.data },\n\t\t\t\t\tindex: i,\n\t\t\t\t\talias,\n\t\t\t\t})\n\t\t\t}\n\t\t\tif (isIt<Input.UpsertSpecifiedRelationInput>(element, 'upsert')) {\n\t\t\t\tresult = processor.upsert({\n\t\t\t\t\t...context,\n\t\t\t\t\tinput: { where: element.upsert.by, update: element.upsert.update, create: element.upsert.create },\n\t\t\t\t\tindex: i,\n\t\t\t\t\talias,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tif (result !== undefined) {\n\t\t\t\tresults.push(await result)\n\t\t\t}\n\t\t}\n\t\treturn results\n\t}\n\n\tprivate verifyOperations(input: object) {\n\t\tconst keys = Object.keys(input).filter(it => it !== 'alias')\n\t\tconst ops = Object.values(Input.UpdateRelationOperation) as string[]\n\t\tif (keys.length !== 1 || !ops.includes(keys[0])) {\n\t\t\tconst found = keys.length === 0 ? 'none' : keys.join(', ')\n\t\t\tthrow new UserError(\n\t\t\t\t`Expected exactly one of: ${ops.join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,GAAG;AAChE,iBAAS,UAAU,OAAO;AAAA,UACzB,GAAG;AAAA,UACH,OAAO,EAAE,OAAO,QAAQ,OAAO,IAAI,MAAM,QAAQ,OAAO,KAAK;AAAA,UAC7D,OAAO;AAAA,UACP;AAAA,QAAA,CACA;AAAA,MAAA;AAEE,UAAAA,KAAA,KAAyC,SAAS,QAAQ,GAAG;AAChE,iBAAS,UAAU,OAAO;AAAA,UACzB,GAAG;AAAA,UACH,OAAO,EAAE,OAAO,QAAQ,OAAO,IAAI,QAAQ,QAAQ,OAAO,QAAQ,QAAQ,QAAQ,OAAO,OAAO;AAAA,UAChG,OAAO;AAAA,UACP;AAAA,QAAA,CACA;AAAA,MAAA;AAGF,UAAI,WAAW,QAAW;AACjB,gBAAA,KAAK,MAAM,MAAM;AAAA,MAAA;AAAA,IAC1B;AAEM,WAAA;AAAA,EAAA;AAAA,EAGA,iBAAiB,OAAe;AACjC,UAAA,OAAO,OAAO,KAAK,KAAK,EAAE,OAAO,CAAA,OAAM,OAAO,OAAO;AAC3D,UAAM,MAAM,OAAO,OAAOE,OAAAA,MAAM,uBAAuB;AACnD,QAAA,KAAK,WAAW,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC,GAAG;AAChD,YAAM,QAAQ,KAAK,WAAW,IAAI,SAAS,KAAK,KAAK,IAAI;AACzD,YAAM,IAAIC,UAAA;AAAA,QACT,4BAA4B,IAAI,KAAK,IAAI,CAAC,KAAK,KAAK;AAAA,MACrD;AAAA,IAAA;AAAA,EACD;AAEF;;"}
|
|
1
|
+
{"version":3,"file":"UpdateInputVisitor.cjs","sources":["../../../../../packages/engine-content-api/src/inputProcessing/UpdateInputVisitor.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { filterObject } from '../utils'\nimport { UpdateInputProcessor } from './UpdateInputProcessor'\nimport { ImplementationException, UserError } from '../exception'\nimport { MapperInput } from '../mapper'\n\nexport class UpdateInputVisitor<Result> implements\n\tModel.ColumnVisitor<Promise<Result[]>>,\n\tModel.RelationByTypeVisitor<Promise<Result[]>> {\n\n\tconstructor(\n\t\tprivate readonly updateInputProcessor: UpdateInputProcessor<Result>,\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly data: MapperInput.UpdateDataInput,\n\t) {}\n\n\tpublic async visitColumn({ entity, column }: Model.ColumnContext): Promise<Result[]> {\n\t\treturn [await this.updateInputProcessor.column({\n\t\t\tentity,\n\t\t\tcolumn,\n\t\t\tinput: this.data[column.name] as Input.ColumnValue,\n\t\t})]\n\t}\n\n\tpublic visitManyHasManyInverse(context: Model.ManyHasManyInverseContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.updateInputProcessor.manyHasManyInverse,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitManyHasManyOwning(context: Model.ManyHasManyOwningContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.updateInputProcessor.manyHasManyOwning,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitManyHasOne(context: Model.ManyHasOneContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.updateInputProcessor.manyHasOne,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasMany(context: Model.OneHasManyContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.updateInputProcessor.oneHasMany,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasOneInverse(context: Model.OneHasOneInverseContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.updateInputProcessor.oneHasOneInverse,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasOneOwning(context: Model.OneHasOneOwningContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.updateInputProcessor.oneHasOneOwning,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tprivate async processRelationInput<Context>(\n\t\tprocessor: UpdateInputProcessor.HasOneRelationInputProcessor<Context, Result>,\n\t\tcontext: Context,\n\t\tinput: MapperInput.UpdateOneRelationInput | undefined,\n\t): Promise< Result[]> {\n\t\tif (input === undefined || input === null) {\n\t\t\treturn Promise.resolve([])\n\t\t}\n\t\tinput = filterObject(input, (k, v) => v !== null && v !== undefined)\n\t\tthis.verifyOperations(input)\n\t\tif ('connect' in input) {\n\t\t\treturn [await processor.connect({ ...context, input: input.connect })]\n\t\t}\n\t\tif ('create' in input) {\n\t\t\treturn [await processor.create({ ...context, input: input.create })]\n\t\t}\n\t\tif ('connectOrCreate' in input) {\n\t\t\treturn [await processor.connectOrCreate({ ...context, input: input.connectOrCreate })]\n\t\t}\n\t\tif ('delete' in input) {\n\t\t\treturn [await processor.delete({ ...context, input: undefined })]\n\t\t}\n\t\tif ('disconnect' in input) {\n\t\t\treturn [await processor.disconnect({ ...context, input: undefined })]\n\t\t}\n\t\tif ('update' in input) {\n\t\t\treturn [await processor.update({ ...context, input: input.update })]\n\t\t}\n\t\tif ('upsert' in input) {\n\t\t\treturn [await processor.upsert({ ...context, input: input.upsert })]\n\t\t}\n\t\tthrow new ImplementationException()\n\t}\n\n\tprivate async processManyRelationInput<Context>(\n\t\tprocessor: UpdateInputProcessor.HasManyRelationInputProcessor<Context, Result>,\n\t\tcontext: Context,\n\t\tinput: MapperInput.UpdateManyRelationInput | undefined,\n\t): Promise<Result[]> {\n\t\tif (input === undefined || input === null) {\n\t\t\treturn Promise.resolve([])\n\t\t}\n\t\tconst results: Array<Result> = []\n\t\tlet i = 0\n\t\tfor (let element of input) {\n\t\t\tconst alias = element.alias\n\t\t\telement = filterObject(element, (k, v) => v !== null && v !== undefined)\n\t\t\tthis.verifyOperations(element)\n\t\t\tlet result\n\t\t\tif ('connect' in element) {\n\t\t\t\tresult = processor.connect({ ...context, input: element.connect, index: i, alias })\n\t\t\t}\n\t\t\tif ('create' in element) {\n\t\t\t\tresult = processor.create({ ...context, input: element.create, index: i, alias })\n\t\t\t}\n\t\t\tif ('connectOrCreate' in element) {\n\t\t\t\tresult = processor.connectOrCreate({ ...context, input: element.connectOrCreate, index: i, alias })\n\t\t\t}\n\t\t\tif ('delete' in element) {\n\t\t\t\tresult = processor.delete({ ...context, input: element.delete, index: i, alias })\n\t\t\t}\n\t\t\tif ('disconnect' in element) {\n\t\t\t\tresult = processor.disconnect({ ...context, input: element.disconnect, index: i, alias })\n\t\t\t}\n\t\t\tif ('update' in element) {\n\t\t\t\tresult = processor.update({\n\t\t\t\t\t...context,\n\t\t\t\t\tinput: { where: element.update.by, data: element.update.data },\n\t\t\t\t\tindex: i,\n\t\t\t\t\talias,\n\t\t\t\t})\n\t\t\t}\n\t\t\tif ('upsert' in element) {\n\t\t\t\tresult = processor.upsert({\n\t\t\t\t\t...context,\n\t\t\t\t\tinput: { where: element.upsert.by, update: element.upsert.update, create: element.upsert.create },\n\t\t\t\t\tindex: i,\n\t\t\t\t\talias,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tif (result !== undefined) {\n\t\t\t\tresults.push(await result)\n\t\t\t}\n\t\t}\n\t\treturn results\n\t}\n\n\tprivate verifyOperations(input: object) {\n\t\tconst keys = Object.keys(input).filter(it => it !== 'alias')\n\t\tconst ops = Object.values(Input.UpdateRelationOperation) as string[]\n\t\tif (keys.length !== 1 || !ops.includes(keys[0])) {\n\t\t\tconst found = keys.length === 0 ? 'none' : keys.join(', ')\n\t\t\tthrow new UserError(\n\t\t\t\t`Expected exactly one of: ${ops.join(', ')}. ${found} found.`,\n\t\t\t)\n\t\t}\n\t}\n}\n"],"names":["schema","filterObject","ImplementationException","Input","UserError"],"mappings":";;;;;;AAMO,MAAM,mBAEmC;A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,MAAA;AAGF,UAAI,WAAW,QAAW;AACjB,gBAAA,KAAK,MAAM,MAAM;AAAA,MAAA;AAAA,IAC1B;AAEM,WAAA;AAAA,EAAA;AAAA,EAGA,iBAAiB,OAAe;AACjC,UAAA,OAAO,OAAO,KAAK,KAAK,EAAE,OAAO,CAAA,OAAM,OAAO,OAAO;AAC3D,UAAM,MAAM,OAAO,OAAOE,OAAAA,MAAM,uBAAuB;AACnD,QAAA,KAAK,WAAW,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC,GAAG;AAChD,YAAM,QAAQ,KAAK,WAAW,IAAI,SAAS,KAAK,KAAK,IAAI;AACzD,YAAM,IAAIC,UAAA;AAAA,QACT,4BAA4B,IAAI,KAAK,IAAI,CAAC,KAAK,KAAK;AAAA,MACrD;AAAA,IAAA;AAAA,EACD;AAEF;;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Input } from "@contember/schema";
|
|
2
2
|
import { ImplementationException, UserError } from "../exception.js";
|
|
3
|
-
import { isIt } from "../utils/isIt.js";
|
|
4
3
|
import { filterObject } from "../utils/object.js";
|
|
5
4
|
import "@contember/schema-utils";
|
|
6
5
|
class UpdateInputVisitor {
|
|
@@ -64,25 +63,25 @@ class UpdateInputVisitor {
|
|
|
64
63
|
}
|
|
65
64
|
input = filterObject(input, (k, v) => v !== null && v !== void 0);
|
|
66
65
|
this.verifyOperations(input);
|
|
67
|
-
if (
|
|
66
|
+
if ("connect" in input) {
|
|
68
67
|
return [await processor.connect({ ...context, input: input.connect })];
|
|
69
68
|
}
|
|
70
|
-
if (
|
|
69
|
+
if ("create" in input) {
|
|
71
70
|
return [await processor.create({ ...context, input: input.create })];
|
|
72
71
|
}
|
|
73
|
-
if (
|
|
72
|
+
if ("connectOrCreate" in input) {
|
|
74
73
|
return [await processor.connectOrCreate({ ...context, input: input.connectOrCreate })];
|
|
75
74
|
}
|
|
76
|
-
if (
|
|
75
|
+
if ("delete" in input) {
|
|
77
76
|
return [await processor.delete({ ...context, input: void 0 })];
|
|
78
77
|
}
|
|
79
|
-
if (
|
|
78
|
+
if ("disconnect" in input) {
|
|
80
79
|
return [await processor.disconnect({ ...context, input: void 0 })];
|
|
81
80
|
}
|
|
82
|
-
if (
|
|
81
|
+
if ("update" in input) {
|
|
83
82
|
return [await processor.update({ ...context, input: input.update })];
|
|
84
83
|
}
|
|
85
|
-
if (
|
|
84
|
+
if ("upsert" in input) {
|
|
86
85
|
return [await processor.upsert({ ...context, input: input.upsert })];
|
|
87
86
|
}
|
|
88
87
|
throw new ImplementationException();
|
|
@@ -98,22 +97,22 @@ class UpdateInputVisitor {
|
|
|
98
97
|
element = filterObject(element, (k, v) => v !== null && v !== void 0);
|
|
99
98
|
this.verifyOperations(element);
|
|
100
99
|
let result;
|
|
101
|
-
if (
|
|
100
|
+
if ("connect" in element) {
|
|
102
101
|
result = processor.connect({ ...context, input: element.connect, index: i, alias });
|
|
103
102
|
}
|
|
104
|
-
if (
|
|
103
|
+
if ("create" in element) {
|
|
105
104
|
result = processor.create({ ...context, input: element.create, index: i, alias });
|
|
106
105
|
}
|
|
107
|
-
if (
|
|
106
|
+
if ("connectOrCreate" in element) {
|
|
108
107
|
result = processor.connectOrCreate({ ...context, input: element.connectOrCreate, index: i, alias });
|
|
109
108
|
}
|
|
110
|
-
if (
|
|
109
|
+
if ("delete" in element) {
|
|
111
110
|
result = processor.delete({ ...context, input: element.delete, index: i, alias });
|
|
112
111
|
}
|
|
113
|
-
if (
|
|
112
|
+
if ("disconnect" in element) {
|
|
114
113
|
result = processor.disconnect({ ...context, input: element.disconnect, index: i, alias });
|
|
115
114
|
}
|
|
116
|
-
if (
|
|
115
|
+
if ("update" in element) {
|
|
117
116
|
result = processor.update({
|
|
118
117
|
...context,
|
|
119
118
|
input: { where: element.update.by, data: element.update.data },
|
|
@@ -121,7 +120,7 @@ class UpdateInputVisitor {
|
|
|
121
120
|
alias
|
|
122
121
|
});
|
|
123
122
|
}
|
|
124
|
-
if (
|
|
123
|
+
if ("upsert" in element) {
|
|
125
124
|
result = processor.upsert({
|
|
126
125
|
...context,
|
|
127
126
|
input: { where: element.upsert.by, update: element.upsert.update, create: element.upsert.create },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateInputVisitor.js","sources":["../../../../../packages/engine-content-api/src/inputProcessing/UpdateInputVisitor.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { filterObject, isIt } from '../utils'\nimport { UpdateInputProcessor } from './UpdateInputProcessor'\nimport { ImplementationException, UserError } from '../exception'\n\nexport class UpdateInputVisitor<Result> implements\n\tModel.ColumnVisitor<Promise<Result[]>>,\n\tModel.RelationByTypeVisitor<Promise<Result[]>> {\n\n\tconstructor(\n\t\tprivate readonly updateInputProcessor: UpdateInputProcessor<Result>,\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly data: Input.UpdateDataInput,\n\t) {}\n\n\tpublic async visitColumn({ entity, column }: Model.ColumnContext): Promise<Result[]> {\n\t\treturn [await this.updateInputProcessor.column({\n\t\t\tentity,\n\t\t\tcolumn,\n\t\t\tinput: this.data[column.name] as Input.ColumnValue,\n\t\t})]\n\t}\n\n\tpublic visitManyHasManyInverse(context: Model.ManyHasManyInverseContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.updateInputProcessor.manyHasManyInverse,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as Input.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitManyHasManyOwning(context: Model.ManyHasManyOwningContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.updateInputProcessor.manyHasManyOwning,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as Input.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitManyHasOne(context: Model.ManyHasOneContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.updateInputProcessor.manyHasOne,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as Input.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasMany(context: Model.OneHasManyContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.updateInputProcessor.oneHasMany,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as Input.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasOneInverse(context: Model.OneHasOneInverseContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.updateInputProcessor.oneHasOneInverse,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as Input.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasOneOwning(context: Model.OneHasOneOwningContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.updateInputProcessor.oneHasOneOwning,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as Input.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tprivate async processRelationInput<Context>(\n\t\tprocessor: UpdateInputProcessor.HasOneRelationInputProcessor<Context, Result>,\n\t\tcontext: Context,\n\t\tinput: Input.UpdateOneRelationInput | undefined,\n\t): Promise< Result[]> {\n\t\tif (input === undefined || input === null) {\n\t\t\treturn Promise.resolve([])\n\t\t}\n\t\tinput = filterObject(input, (k, v) => v !== null && v !== undefined)\n\t\tthis.verifyOperations(input)\n\t\tif (isIt<Input.ConnectRelationInput>(input, 'connect')) {\n\t\t\treturn [await processor.connect({ ...context, input: input.connect })]\n\t\t}\n\t\tif (isIt<Input.CreateRelationInput>(input, 'create')) {\n\t\t\treturn [await processor.create({ ...context, input: input.create })]\n\t\t}\n\t\tif (isIt<Input.ConnectOrCreateRelationInput>(input, 'connectOrCreate')) {\n\t\t\treturn [await processor.connectOrCreate({ ...context, input: input.connectOrCreate })]\n\t\t}\n\t\tif (isIt<Input.DeleteRelationInput>(input, 'delete')) {\n\t\t\treturn [await processor.delete({ ...context, input: undefined })]\n\t\t}\n\t\tif (isIt<Input.DisconnectRelationInput>(input, 'disconnect')) {\n\t\t\treturn [await processor.disconnect({ ...context, input: undefined })]\n\t\t}\n\t\tif (isIt<Input.UpdateRelationInput>(input, 'update')) {\n\t\t\treturn [await processor.update({ ...context, input: input.update })]\n\t\t}\n\t\tif (isIt<Input.UpsertRelationInput>(input, 'upsert')) {\n\t\t\treturn [await processor.upsert({ ...context, input: input.upsert })]\n\t\t}\n\t\tthrow new ImplementationException()\n\t}\n\n\tprivate async processManyRelationInput<Context>(\n\t\tprocessor: UpdateInputProcessor.HasManyRelationInputProcessor<Context, Result>,\n\t\tcontext: Context,\n\t\tinput: Input.UpdateManyRelationInput | undefined,\n\t): Promise<Result[]> {\n\t\tif (input === undefined || input === null) {\n\t\t\treturn Promise.resolve([])\n\t\t}\n\t\tconst results: Array<Result> = []\n\t\tlet i = 0\n\t\tfor (let element of input) {\n\t\t\tconst alias = element.alias\n\t\t\telement = filterObject(element, (k, v) => v !== null && v !== undefined)\n\t\t\tthis.verifyOperations(element)\n\t\t\tlet result\n\t\t\tif (isIt<Input.ConnectRelationInput>(element, 'connect')) {\n\t\t\t\tresult = processor.connect({ ...context, input: element.connect, index: i, alias })\n\t\t\t}\n\t\t\tif (isIt<Input.CreateRelationInput>(element, 'create')) {\n\t\t\t\tresult = processor.create({ ...context, input: element.create, index: i, alias })\n\t\t\t}\n\t\t\tif (isIt<Input.ConnectOrCreateRelationInput>(element, 'connectOrCreate')) {\n\t\t\t\tresult = processor.connectOrCreate({ ...context, input: element.connectOrCreate, index: i, alias })\n\t\t\t}\n\t\t\tif (isIt<Input.DeleteSpecifiedRelationInput>(element, 'delete')) {\n\t\t\t\tresult = processor.delete({ ...context, input: element.delete, index: i, alias })\n\t\t\t}\n\t\t\tif (isIt<Input.DisconnectSpecifiedRelationInput>(element, 'disconnect')) {\n\t\t\t\tresult = processor.disconnect({ ...context, input: element.disconnect, index: i, alias })\n\t\t\t}\n\t\t\tif (isIt<Input.UpdateSpecifiedRelationInput>(element, 'update')) {\n\t\t\t\tresult = processor.update({\n\t\t\t\t\t...context,\n\t\t\t\t\tinput: { where: element.update.by, data: element.update.data },\n\t\t\t\t\tindex: i,\n\t\t\t\t\talias,\n\t\t\t\t})\n\t\t\t}\n\t\t\tif (isIt<Input.UpsertSpecifiedRelationInput>(element, 'upsert')) {\n\t\t\t\tresult = processor.upsert({\n\t\t\t\t\t...context,\n\t\t\t\t\tinput: { where: element.upsert.by, update: element.upsert.update, create: element.upsert.create },\n\t\t\t\t\tindex: i,\n\t\t\t\t\talias,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tif (result !== undefined) {\n\t\t\t\tresults.push(await result)\n\t\t\t}\n\t\t}\n\t\treturn results\n\t}\n\n\tprivate verifyOperations(input: object) {\n\t\tconst keys = Object.keys(input).filter(it => it !== 'alias')\n\t\tconst ops = Object.values(Input.UpdateRelationOperation) as string[]\n\t\tif (keys.length !== 1 || !ops.includes(keys[0])) {\n\t\t\tconst found = keys.length === 0 ? 'none' : keys.join(', ')\n\t\t\tthrow new UserError(\n\t\t\t\t`Expected exactly one of: ${ops.join(', ')}. ${found} found.`,\n\t\t\t)\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;AAKO,MAAM,mBAEmC;AAAA,EAE/C,YACkB,sBACA,QACA,MAChB;AAHgB,SAAA,uBAAA;AACA,SAAA,SAAA;AACA,SAAA,OAAA;AAAA,EAAA;AAAA,EAGlB,MAAa,YAAY,EAAE,QAAQ,UAAkD;AACpF,WAAO,CAAC,MAAM,KAAK,qBAAqB,OAAO;AAAA,MAC9C;AAAA,MACA;AAAA,MACA,OAAO,KAAK,KAAK,OAAO,IAAI;AAAA,IAAA,CAC5B,CAAC;AAAA,EAAA;AAAA,EAGI,wBAAwB,SAA0C;AACxE,WAAO,KAAK;AAAA,MACX,KAAK,qBAAqB;AAAA,MAC1B;AAAA,MACA,KAAK,KAAK,QAAQ,SAAS,IAAI;AAAA,IAChC;AAAA,EAAA;AAAA,EAGM,uBAAuB,SAAyC;AACtE,WAAO,KAAK;AAAA,MACX,KAAK,qBAAqB;AAAA,MAC1B;AAAA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AAI,SAAS,KAAK,KAAK,IAAI;AACzD,YAAM,IAAI;AAAA,QACT,4BAA4B,IAAI,KAAK,IAAI,CAAC,KAAK,KAAK;AAAA,MACrD;AAAA,IAAA;AAAA,EACD;AAEF;"}
|
|
1
|
+
{"version":3,"file":"UpdateInputVisitor.js","sources":["../../../../../packages/engine-content-api/src/inputProcessing/UpdateInputVisitor.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { filterObject } from '../utils'\nimport { UpdateInputProcessor } from './UpdateInputProcessor'\nimport { ImplementationException, UserError } from '../exception'\nimport { MapperInput } from '../mapper'\n\nexport class UpdateInputVisitor<Result> implements\n\tModel.ColumnVisitor<Promise<Result[]>>,\n\tModel.RelationByTypeVisitor<Promise<Result[]>> {\n\n\tconstructor(\n\t\tprivate readonly updateInputProcessor: UpdateInputProcessor<Result>,\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly data: MapperInput.UpdateDataInput,\n\t) {}\n\n\tpublic async visitColumn({ entity, column }: Model.ColumnContext): Promise<Result[]> {\n\t\treturn [await this.updateInputProcessor.column({\n\t\t\tentity,\n\t\t\tcolumn,\n\t\t\tinput: this.data[column.name] as Input.ColumnValue,\n\t\t})]\n\t}\n\n\tpublic visitManyHasManyInverse(context: Model.ManyHasManyInverseContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.updateInputProcessor.manyHasManyInverse,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitManyHasManyOwning(context: Model.ManyHasManyOwningContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.updateInputProcessor.manyHasManyOwning,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitManyHasOne(context: Model.ManyHasOneContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.updateInputProcessor.manyHasOne,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasMany(context: Model.OneHasManyContext) {\n\t\treturn this.processManyRelationInput(\n\t\t\tthis.updateInputProcessor.oneHasMany,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateManyRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasOneInverse(context: Model.OneHasOneInverseContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.updateInputProcessor.oneHasOneInverse,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tpublic visitOneHasOneOwning(context: Model.OneHasOneOwningContext) {\n\t\treturn this.processRelationInput(\n\t\t\tthis.updateInputProcessor.oneHasOneOwning,\n\t\t\tcontext,\n\t\t\tthis.data[context.relation.name] as MapperInput.CreateOneRelationInput,\n\t\t)\n\t}\n\n\tprivate async processRelationInput<Context>(\n\t\tprocessor: UpdateInputProcessor.HasOneRelationInputProcessor<Context, Result>,\n\t\tcontext: Context,\n\t\tinput: MapperInput.UpdateOneRelationInput | undefined,\n\t): Promise< Result[]> {\n\t\tif (input === undefined || input === null) {\n\t\t\treturn Promise.resolve([])\n\t\t}\n\t\tinput = filterObject(input, (k, v) => v !== null && v !== undefined)\n\t\tthis.verifyOperations(input)\n\t\tif ('connect' in input) {\n\t\t\treturn [await processor.connect({ ...context, input: input.connect })]\n\t\t}\n\t\tif ('create' in input) {\n\t\t\treturn [await processor.create({ ...context, input: input.create })]\n\t\t}\n\t\tif ('connectOrCreate' in input) {\n\t\t\treturn [await processor.connectOrCreate({ ...context, input: input.connectOrCreate })]\n\t\t}\n\t\tif ('delete' in input) {\n\t\t\treturn [await processor.delete({ ...context, input: undefined })]\n\t\t}\n\t\tif ('disconnect' in input) {\n\t\t\treturn [await processor.disconnect({ ...context, input: undefined })]\n\t\t}\n\t\tif ('update' in input) {\n\t\t\treturn [await processor.update({ ...context, input: input.update })]\n\t\t}\n\t\tif ('upsert' in input) {\n\t\t\treturn [await processor.upsert({ ...context, input: input.upsert })]\n\t\t}\n\t\tthrow new ImplementationException()\n\t}\n\n\tprivate async processManyRelationInput<Context>(\n\t\tprocessor: UpdateInputProcessor.HasManyRelationInputProcessor<Context, Result>,\n\t\tcontext: Context,\n\t\tinput: MapperInput.UpdateManyRelationInput | undefined,\n\t): Promise<Result[]> {\n\t\tif (input === undefined || input === null) {\n\t\t\treturn Promise.resolve([])\n\t\t}\n\t\tconst results: Array<Result> = []\n\t\tlet i = 0\n\t\tfor (let element of input) {\n\t\t\tconst alias = element.alias\n\t\t\telement = filterObject(element, (k, v) => v !== null && v !== undefined)\n\t\t\tthis.verifyOperations(element)\n\t\t\tlet result\n\t\t\tif ('connect' in element) {\n\t\t\t\tresult = processor.connect({ ...context, input: element.connect, index: i, alias })\n\t\t\t}\n\t\t\tif ('create' in element) {\n\t\t\t\tresult = processor.create({ ...context, input: element.create, index: i, alias })\n\t\t\t}\n\t\t\tif ('connectOrCreate' in element) {\n\t\t\t\tresult = processor.connectOrCreate({ ...context, input: element.connectOrCreate, index: i, alias })\n\t\t\t}\n\t\t\tif ('delete' in element) {\n\t\t\t\tresult = processor.delete({ ...context, input: element.delete, index: i, alias })\n\t\t\t}\n\t\t\tif ('disconnect' in element) {\n\t\t\t\tresult = processor.disconnect({ ...context, input: element.disconnect, index: i, alias })\n\t\t\t}\n\t\t\tif ('update' in element) {\n\t\t\t\tresult = processor.update({\n\t\t\t\t\t...context,\n\t\t\t\t\tinput: { where: element.update.by, data: element.update.data },\n\t\t\t\t\tindex: i,\n\t\t\t\t\talias,\n\t\t\t\t})\n\t\t\t}\n\t\t\tif ('upsert' in element) {\n\t\t\t\tresult = processor.upsert({\n\t\t\t\t\t...context,\n\t\t\t\t\tinput: { where: element.upsert.by, update: element.upsert.update, create: element.upsert.create },\n\t\t\t\t\tindex: i,\n\t\t\t\t\talias,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tif (result !== undefined) {\n\t\t\t\tresults.push(await result)\n\t\t\t}\n\t\t}\n\t\treturn results\n\t}\n\n\tprivate verifyOperations(input: object) {\n\t\tconst keys = Object.keys(input).filter(it => it !== 'alias')\n\t\tconst ops = Object.values(Input.UpdateRelationOperation) as string[]\n\t\tif (keys.length !== 1 || !ops.includes(keys[0])) {\n\t\t\tconst found = keys.length === 0 ? 'none' : keys.join(', ')\n\t\t\tthrow new UserError(\n\t\t\t\t`Expected exactly one of: ${ops.join(', ')}. ${found} found.`,\n\t\t\t)\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAMO,MAAM,mBAEmC;AAAA,EAE/C,YACkB,sBACA,QACA,MAChB;AAHgB,SAAA,uBAAA;AACA,SAAA,SAAA;AACA,SAAA,OAAA;AAAA,EAAA;AAAA,EAGlB,MAAa,YAAY,EAAE,QAAQ,UAAkD;AACpF,WAAO,CAAC,MAAM,KAAK,qBAAqB,OAAO;AAAA,MAC9C;AAAA,MACA;AAAA,MACA,OAAO,KAAK,KAAK,OAAO,IAAI;AAAA,IAAA,CAC5B,CAAC;AAAA,EAAA;AAAA,EAGI,wBAAwB,SAA0C;AACxE,WAAO,KAAK;AAAA,MACX,KAAK,qBAAqB;AAAA,MAC1B;AAAA,MACA,KAAK,KAAK,QAAQ,SAAS,IAAI;AAAA,IAChC;AAAA,EAAA;AAAA,EAGM,uBAAuB,SAAyC;AACtE,WAAO,KAAK;AAAA,MACX,KAAK,qBAAqB;AAAA,MAC1B;AAAA,MACA,KAAK,KAAK,QAAQ,SAAS,IAAI;AAAA,IAChC;AAAA,EAAA;AAAA,EAGM,gBAAgB,SAAkC;AACxD,WAAO,KAAK;AAAA,MACX,KAAK,qBAAqB;AAAA,MAC1B;AAAA,MACA,KAAK,KAAK,QAAQ,SAAS,IAAI;AAAA,IAChC;AAAA,EAAA;AAAA,EAGM,gBAAgB,SAAkC;AACxD,WAAO,KAAK;AAAA,MACX,KAAK,qBAAqB;AAAA,MAC1B;AAAA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AAAA,UACzB,GAAG;AAAA,UACH,OAAO,EAAE,OAAO,QAAQ,OAAO,IAAI,MAAM,QAAQ,OAAO,KAAK;AAAA,UAC7D,OAAO;AAAA,UACP;AAAA,QAAA,CACA;AAAA,MAAA;AAEF,UAAI,YAAY,SAAS;AACxB,iBAAS,UAAU,OAAO;AAAA,UACzB,GAAG;AAAA,UACH,OAAO,EAAE,OAAO,QAAQ,OAAO,IAAI,QAAQ,QAAQ,OAAO,QAAQ,QAAQ,QAAQ,OAAO,OAAO;AAAA,UAChG,OAAO;AAAA,UACP;AAAA,QAAA,CACA;AAAA,MAAA;AAGF,UAAI,WAAW,QAAW;AACjB,gBAAA,KAAK,MAAM,MAAM;AAAA,MAAA;AAAA,IAC1B;AAEM,WAAA;AAAA,EAAA;AAAA,EAGA,iBAAiB,OAAe;AACjC,UAAA,OAAO,OAAO,KAAK,KAAK,EAAE,OAAO,CAAA,OAAM,OAAO,OAAO;AAC3D,UAAM,MAAM,OAAO,OAAO,MAAM,uBAAuB;AACnD,QAAA,KAAK,WAAW,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC,GAAG;AAChD,YAAM,QAAQ,KAAK,WAAW,IAAI,SAAS,KAAK,KAAK,IAAI;AACzD,YAAM,IAAI;AAAA,QACT,4BAA4B,IAAI,KAAK,IAAI,CAAC,KAAK,KAAK;AAAA,MACrD;AAAA,IAAA;AAAA,EACD;AAEF;"}
|
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
value = value();
|
|
3
|
+
const rowDataToFieldValues = (values) => Object.fromEntries(values.map((it) => [it.fieldName, it.value]));
|
|
4
|
+
const normalizeDbValue = (value, type) => {
|
|
5
|
+
if (value === null) {
|
|
6
|
+
return null;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const resolveRowData = async (values) => {
|
|
12
|
-
const valuePromises = values.map(async (it) => ({ ...it, resolvedValue: await it.value }));
|
|
13
|
-
const settledValues = await Promise.allSettled(valuePromises);
|
|
14
|
-
const failed = promises.getRejections(settledValues);
|
|
15
|
-
if (failed.length > 0) {
|
|
16
|
-
throw failed[0];
|
|
8
|
+
if ((type === "jsonb" || type === "json") && typeof value === "object") {
|
|
9
|
+
return JSON.stringify(value);
|
|
17
10
|
}
|
|
18
|
-
|
|
19
|
-
return fulfilled.filter((it) => it.resolvedValue !== void 0);
|
|
11
|
+
return value;
|
|
20
12
|
};
|
|
21
|
-
|
|
22
|
-
exports.resolveGenericValue = resolveGenericValue;
|
|
23
|
-
exports.resolveRowData = resolveRowData;
|
|
13
|
+
exports.normalizeDbValue = normalizeDbValue;
|
|
24
14
|
exports.rowDataToFieldValues = rowDataToFieldValues;
|
|
25
15
|
//# sourceMappingURL=ColumnValue.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnValue.cjs","sources":["../../../../../packages/engine-content-api/src/mapper/ColumnValue.ts"],"sourcesContent":["import { Value } from '@contember/schema'\
|
|
1
|
+
{"version":3,"file":"ColumnValue.cjs","sources":["../../../../../packages/engine-content-api/src/mapper/ColumnValue.ts"],"sourcesContent":["import { Value } from '@contember/schema'\n\nexport type ColumnValue = {\n\tvalue: Value.FieldValue\n\tfieldName: string\n\tcolumnName: string\n\tcolumnType: string\n}\n\n\nexport const rowDataToFieldValues = (values: ColumnValue[]): Record<string, Value.FieldValue> =>\n\tObject.fromEntries(values.map(it => [it.fieldName, it.value]))\n\nexport const normalizeDbValue = (value: Value.FieldValue, type: string): Value.FieldValue => {\n\tif (value === null) {\n\t\treturn null\n\t}\n\tif ((type === 'jsonb' || type === 'json') && typeof value === 'object') {\n\t\treturn JSON.stringify(value)\n\t}\n\treturn value\n}\n"],"names":[],"mappings":";;AAUO,MAAM,uBAAuB,CAAC,WACpC,OAAO,YAAY,OAAO,IAAI,CAAM,OAAA,CAAC,GAAG,WAAW,GAAG,KAAK,CAAC,CAAC;AAEjD,MAAA,mBAAmB,CAAC,OAAyB,SAAmC;AAC5F,MAAI,UAAU,MAAM;AACZ,WAAA;AAAA,EAAA;AAER,OAAK,SAAS,WAAW,SAAS,WAAW,OAAO,UAAU,UAAU;AAChE,WAAA,KAAK,UAAU,KAAK;AAAA,EAAA;AAErB,SAAA;AACR;;;"}
|
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value = value();
|
|
1
|
+
const rowDataToFieldValues = (values) => Object.fromEntries(values.map((it) => [it.fieldName, it.value]));
|
|
2
|
+
const normalizeDbValue = (value, type) => {
|
|
3
|
+
if (value === null) {
|
|
4
|
+
return null;
|
|
6
5
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const resolveRowData = async (values) => {
|
|
10
|
-
const valuePromises = values.map(async (it) => ({ ...it, resolvedValue: await it.value }));
|
|
11
|
-
const settledValues = await Promise.allSettled(valuePromises);
|
|
12
|
-
const failed = getRejections(settledValues);
|
|
13
|
-
if (failed.length > 0) {
|
|
14
|
-
throw failed[0];
|
|
6
|
+
if ((type === "jsonb" || type === "json") && typeof value === "object") {
|
|
7
|
+
return JSON.stringify(value);
|
|
15
8
|
}
|
|
16
|
-
|
|
17
|
-
return fulfilled.filter((it) => it.resolvedValue !== void 0);
|
|
9
|
+
return value;
|
|
18
10
|
};
|
|
19
|
-
const rowDataToFieldValues = (values) => values.reduce((acc, { fieldName, value }) => ({ ...acc, [fieldName]: value }), {});
|
|
20
11
|
export {
|
|
21
|
-
|
|
22
|
-
resolveRowData,
|
|
12
|
+
normalizeDbValue,
|
|
23
13
|
rowDataToFieldValues
|
|
24
14
|
};
|
|
25
15
|
//# sourceMappingURL=ColumnValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnValue.js","sources":["../../../../../packages/engine-content-api/src/mapper/ColumnValue.ts"],"sourcesContent":["import { Value } from '@contember/schema'\
|
|
1
|
+
{"version":3,"file":"ColumnValue.js","sources":["../../../../../packages/engine-content-api/src/mapper/ColumnValue.ts"],"sourcesContent":["import { Value } from '@contember/schema'\n\nexport type ColumnValue = {\n\tvalue: Value.FieldValue\n\tfieldName: string\n\tcolumnName: string\n\tcolumnType: string\n}\n\n\nexport const rowDataToFieldValues = (values: ColumnValue[]): Record<string, Value.FieldValue> =>\n\tObject.fromEntries(values.map(it => [it.fieldName, it.value]))\n\nexport const normalizeDbValue = (value: Value.FieldValue, type: string): Value.FieldValue => {\n\tif (value === null) {\n\t\treturn null\n\t}\n\tif ((type === 'jsonb' || type === 'json') && typeof value === 'object') {\n\t\treturn JSON.stringify(value)\n\t}\n\treturn value\n}\n"],"names":[],"mappings":"AAUO,MAAM,uBAAuB,CAAC,WACpC,OAAO,YAAY,OAAO,IAAI,CAAM,OAAA,CAAC,GAAG,WAAW,GAAG,KAAK,CAAC,CAAC;AAEjD,MAAA,mBAAmB,CAAC,OAAyB,SAAmC;AAC5F,MAAI,UAAU,MAAM;AACZ,WAAA;AAAA,EAAA;AAER,OAAK,SAAS,WAAW,SAAS,WAAW,OAAO,UAAU,UAAU;AAChE,WAAA,KAAK,UAAU,KAAK;AAAA,EAAA;AAErB,SAAA;AACR;"}
|
|
@@ -37,7 +37,7 @@ class AfterUpdateEvent {
|
|
|
37
37
|
__publicField(this, "_hasChanges");
|
|
38
38
|
}
|
|
39
39
|
get hasChanges() {
|
|
40
|
-
return this._hasChanges = this.data.some((it) => it.
|
|
40
|
+
return this._hasChanges = this.data.some((it) => it.value !== it.old);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
class BeforeDeleteEvent {
|