@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
|
@@ -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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, { 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(', ')}. ${found} found.`,\n\t\t\t)\n\t\t}\n\t}\n}\n"],"names":["schema","filterObject","isIt","ImplementationException","Input","UserError"],"mappings":";;;;;;;AAKO,MAAM,mBAEmC;AAAA,EAE/C,YACkB,sBACAA,SACA,MAChB;AAHgB,SAAA,uBAAA;AACA,SAAA,SAAAA;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,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;AA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,GAAG,MAAA,CAAO;AAAA,MAAA;AAErF,UAAAA,KAAA,KAAyC,SAAS,QAAQ,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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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,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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,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
|
+
{"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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,CAAO;AAAA,MAAA;AAEzF,UAAI,YAAY,SAAS;AACxB,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;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 {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventManager.cjs","sources":["../../../../../packages/engine-content-api/src/mapper/EventManager.ts"],"sourcesContent":["import { Input, Model, Value } from '@contember/schema'\nimport {
|
|
1
|
+
{"version":3,"file":"EventManager.cjs","sources":["../../../../../packages/engine-content-api/src/mapper/EventManager.ts"],"sourcesContent":["import { Input, Model, Value } from '@contember/schema'\nimport { Mapper } from './Mapper'\nimport { ColumnValue } from './ColumnValue'\n\nexport class BeforeInsertEvent {\n\tpublic type = 'BeforeInsertEvent' as const\n\n\tpublic afterEvent: AfterInsertEvent | undefined = undefined\n\n\tconstructor(\n\t\tpublic readonly entity: Model.Entity,\n\t\tpublic readonly data: ColumnValue[],\n\t) {\n\t}\n}\n\nexport class AfterInsertEvent {\n\tpublic type = 'AfterInsertEvent' as const\n\n\tconstructor(\n\t\tpublic readonly entity: Model.Entity,\n\t\tpublic readonly data: ColumnValue[],\n\t\tpublic readonly id: Input.PrimaryValue,\n\t) {\n\t}\n}\n\n\nexport class BeforeUpdateEvent {\n\tpublic type = 'BeforeUpdateEvent' as const\n\n\tpublic afterEvent: AfterUpdateEvent | undefined = undefined\n\n\tconstructor(\n\t\tpublic readonly entity: Model.Entity,\n\t\tpublic readonly data: ColumnValue[],\n\t\tpublic readonly id: Input.PrimaryValue,\n\t) {\n\t}\n}\n\nexport class AfterUpdateEvent {\n\tpublic type = 'AfterUpdateEvent' as const\n\n\tprivate _hasChanges: boolean | undefined\n\n\tconstructor(\n\t\tpublic readonly entity: Model.Entity,\n\t\tpublic readonly data: (ColumnValue & { old: Value.FieldValue })[],\n\t\tpublic readonly id: Input.PrimaryValue,\n\t) {\n\t}\n\tget hasChanges() {\n\t\t// todo: deep equals\n\t\treturn this._hasChanges = this.data.some(it => it.value !== it.old)\n\t}\n}\n\nexport class BeforeDeleteEvent {\n\tpublic type = 'BeforeDeleteEvent' as const\n\n\tconstructor(\n\t\tpublic readonly entity: Model.Entity,\n\t\tpublic readonly id: Input.PrimaryValue,\n\t) {\n\t}\n}\n\nexport class BeforeJunctionUpdateEvent {\n\tpublic type = 'BeforeJunctionUpdateEvent' as const\n\n\tpublic afterEvent: AfterJunctionUpdateEvent | undefined = undefined\n\n\tconstructor(\n\t\tpublic readonly owningEntity: Model.Entity,\n\t\tpublic readonly owningRelation: Model.ManyHasManyOwningRelation,\n\t\tpublic readonly owningId: Input.PrimaryValue,\n\t\tpublic readonly inverseId: Input.PrimaryValue,\n\t\tpublic readonly operation: 'connect' | 'disconnect',\n\t) {\n\t}\n}\n\n\nexport class AfterJunctionUpdateEvent {\n\tpublic type = 'AfterJunctionUpdateEvent' as const\n\n\tconstructor(\n\t\tpublic readonly owningEntity: Model.Entity,\n\t\tpublic readonly owningRelation: Model.ManyHasManyOwningRelation,\n\t\tpublic readonly owningId: Input.PrimaryValue,\n\t\tpublic readonly inverseId: Input.PrimaryValue,\n\t\tpublic readonly operation: 'connect' | 'disconnect',\n\t\tpublic readonly hasChanges: boolean,\n\t) {\n\t}\n}\n\nexport class BeforeCommitEvent {\n\tpublic type = 'BeforeCommitEvent' as const\n}\n\nexport class AfterCommitEvent {\n\tpublic type = 'AfterCommitEvent' as const\n}\n\nexport type DataModificationEvent =\n\t| BeforeInsertEvent\n\t| AfterInsertEvent\n\t| BeforeUpdateEvent\n\t| AfterUpdateEvent\n\t| BeforeJunctionUpdateEvent\n\t| AfterJunctionUpdateEvent\n\t| BeforeDeleteEvent\n\nexport type AnyEvent =\n\t| DataModificationEvent\n\t| BeforeCommitEvent\n\t| AfterCommitEvent\n\nexport type EventMap<E extends AnyEvent = AnyEvent> = {\n\t[K in E['type']]: E extends { type: K } ? E : never\n}\n\nexport type EventListener<K extends keyof EventMap> = (event: EventMap[K], mapper: Mapper) => Promise<void>\n\nexport class EventManager {\n\tprivate listeners: { [K in keyof EventMap]: EventListener<K>[] } = {\n\t\tBeforeInsertEvent: [],\n\t\tAfterInsertEvent: [],\n\t\tBeforeUpdateEvent: [],\n\t\tAfterUpdateEvent: [],\n\t\tBeforeDeleteEvent: [],\n\t\tBeforeCommitEvent: [],\n\t\tAfterCommitEvent: [],\n\t\tBeforeJunctionUpdateEvent: [],\n\t\tAfterJunctionUpdateEvent: [],\n\t}\n\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t}\n\n\tpublic listen<K extends keyof EventMap>(type: K, cb: EventListener<K>) {\n\t\tthis.listeners[type].push(cb)\n\t}\n\n\tpublic async fire<K extends keyof EventMap>(event: EventMap[K]) {\n\t\tfor (const listener of this.listeners[event.type]) {\n\t\t\tawait listener(event, this.mapper)\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;AAIO,MAAM,kBAAkB;AAAA,EAK9B,YACiB,QACA,MACf;AAFe,SAAA,SAAA;AACA,SAAA,OAAA;AANjB,kBAAA,MAAO,QAAO,mBAAA;AAEP,kBAAA,MAAA,YAAA;AAAA,EAAA;AAOR;AAEO,MAAM,iBAAiB;AAAA,EAG7B,YACiB,QACA,MACA,IACf;AAHe,SAAA,SAAA;AACA,SAAA,OAAA;AACA,SAAA,KAAA;AALjB,kBAAA,MAAO,QAAO,kBAAA;AAAA,EAAA;AAQf;AAGO,MAAM,kBAAkB;AAAA,EAK9B,YACiB,QACA,MACA,IACf;AAHe,SAAA,SAAA;AACA,SAAA,OAAA;AACA,SAAA,KAAA;AAPjB,kBAAA,MAAO,QAAO,mBAAA;AAEP,kBAAA,MAAA,YAAA;AAAA,EAAA;AAQR;AAEO,MAAM,iBAAiB;AAAA,EAK7B,YACiB,QACA,MACA,IACf;AAHe,SAAA,SAAA;AACA,SAAA,OAAA;AACA,SAAA,KAAA;AAPjB,kBAAA,MAAO,QAAO,kBAAA;AAEN,kBAAA,MAAA,aAAA;AAAA,EAAA;AAAA,EAQR,IAAI,aAAa;AAET,WAAA,KAAK,cAAc,KAAK,KAAK,KAAK,CAAM,OAAA,GAAG,UAAU,GAAG,GAAG;AAAA,EAAA;AAEpE;AAEO,MAAM,kBAAkB;AAAA,EAG9B,YACiB,QACA,IACf;AAFe,SAAA,SAAA;AACA,SAAA,KAAA;AAJjB,kBAAA,MAAO,QAAO,m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,EAClC;AAEF;;;;;;;;;;;"}
|
|
@@ -35,7 +35,7 @@ class AfterUpdateEvent {
|
|
|
35
35
|
__publicField(this, "_hasChanges");
|
|
36
36
|
}
|
|
37
37
|
get hasChanges() {
|
|
38
|
-
return this._hasChanges = this.data.some((it) => it.
|
|
38
|
+
return this._hasChanges = this.data.some((it) => it.value !== it.old);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
class BeforeDeleteEvent {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventManager.js","sources":["../../../../../packages/engine-content-api/src/mapper/EventManager.ts"],"sourcesContent":["import { Input, Model, Value } from '@contember/schema'\nimport {
|
|
1
|
+
{"version":3,"file":"EventManager.js","sources":["../../../../../packages/engine-content-api/src/mapper/EventManager.ts"],"sourcesContent":["import { Input, Model, Value } from '@contember/schema'\nimport { Mapper } from './Mapper'\nimport { ColumnValue } from './ColumnValue'\n\nexport class BeforeInsertEvent {\n\tpublic type = 'BeforeInsertEvent' as const\n\n\tpublic afterEvent: AfterInsertEvent | undefined = undefined\n\n\tconstructor(\n\t\tpublic readonly entity: Model.Entity,\n\t\tpublic readonly data: ColumnValue[],\n\t) {\n\t}\n}\n\nexport class AfterInsertEvent {\n\tpublic type = 'AfterInsertEvent' as const\n\n\tconstructor(\n\t\tpublic readonly entity: Model.Entity,\n\t\tpublic readonly data: ColumnValue[],\n\t\tpublic readonly id: Input.PrimaryValue,\n\t) {\n\t}\n}\n\n\nexport class BeforeUpdateEvent {\n\tpublic type = 'BeforeUpdateEvent' as const\n\n\tpublic afterEvent: AfterUpdateEvent | undefined = undefined\n\n\tconstructor(\n\t\tpublic readonly entity: Model.Entity,\n\t\tpublic readonly data: ColumnValue[],\n\t\tpublic readonly id: Input.PrimaryValue,\n\t) {\n\t}\n}\n\nexport class AfterUpdateEvent {\n\tpublic type = 'AfterUpdateEvent' as const\n\n\tprivate _hasChanges: boolean | undefined\n\n\tconstructor(\n\t\tpublic readonly entity: Model.Entity,\n\t\tpublic readonly data: (ColumnValue & { old: Value.FieldValue })[],\n\t\tpublic readonly id: Input.PrimaryValue,\n\t) {\n\t}\n\tget hasChanges() {\n\t\t// todo: deep equals\n\t\treturn this._hasChanges = this.data.some(it => it.value !== it.old)\n\t}\n}\n\nexport class BeforeDeleteEvent {\n\tpublic type = 'BeforeDeleteEvent' as const\n\n\tconstructor(\n\t\tpublic readonly entity: Model.Entity,\n\t\tpublic readonly id: Input.PrimaryValue,\n\t) {\n\t}\n}\n\nexport class BeforeJunctionUpdateEvent {\n\tpublic type = 'BeforeJunctionUpdateEvent' as const\n\n\tpublic afterEvent: AfterJunctionUpdateEvent | undefined = undefined\n\n\tconstructor(\n\t\tpublic readonly owningEntity: Model.Entity,\n\t\tpublic readonly owningRelation: Model.ManyHasManyOwningRelation,\n\t\tpublic readonly owningId: Input.PrimaryValue,\n\t\tpublic readonly inverseId: Input.PrimaryValue,\n\t\tpublic readonly operation: 'connect' | 'disconnect',\n\t) {\n\t}\n}\n\n\nexport class AfterJunctionUpdateEvent {\n\tpublic type = 'AfterJunctionUpdateEvent' as const\n\n\tconstructor(\n\t\tpublic readonly owningEntity: Model.Entity,\n\t\tpublic readonly owningRelation: Model.ManyHasManyOwningRelation,\n\t\tpublic readonly owningId: Input.PrimaryValue,\n\t\tpublic readonly inverseId: Input.PrimaryValue,\n\t\tpublic readonly operation: 'connect' | 'disconnect',\n\t\tpublic readonly hasChanges: boolean,\n\t) {\n\t}\n}\n\nexport class BeforeCommitEvent {\n\tpublic type = 'BeforeCommitEvent' as const\n}\n\nexport class AfterCommitEvent {\n\tpublic type = 'AfterCommitEvent' as const\n}\n\nexport type DataModificationEvent =\n\t| BeforeInsertEvent\n\t| AfterInsertEvent\n\t| BeforeUpdateEvent\n\t| AfterUpdateEvent\n\t| BeforeJunctionUpdateEvent\n\t| AfterJunctionUpdateEvent\n\t| BeforeDeleteEvent\n\nexport type AnyEvent =\n\t| DataModificationEvent\n\t| BeforeCommitEvent\n\t| AfterCommitEvent\n\nexport type EventMap<E extends AnyEvent = AnyEvent> = {\n\t[K in E['type']]: E extends { type: K } ? E : never\n}\n\nexport type EventListener<K extends keyof EventMap> = (event: EventMap[K], mapper: Mapper) => Promise<void>\n\nexport class EventManager {\n\tprivate listeners: { [K in keyof EventMap]: EventListener<K>[] } = {\n\t\tBeforeInsertEvent: [],\n\t\tAfterInsertEvent: [],\n\t\tBeforeUpdateEvent: [],\n\t\tAfterUpdateEvent: [],\n\t\tBeforeDeleteEvent: [],\n\t\tBeforeCommitEvent: [],\n\t\tAfterCommitEvent: [],\n\t\tBeforeJunctionUpdateEvent: [],\n\t\tAfterJunctionUpdateEvent: [],\n\t}\n\n\tconstructor(\n\t\tprivate readonly mapper: Mapper,\n\t) {\n\t}\n\n\tpublic listen<K extends keyof EventMap>(type: K, cb: EventListener<K>) {\n\t\tthis.listeners[type].push(cb)\n\t}\n\n\tpublic async fire<K extends keyof EventMap>(event: EventMap[K]) {\n\t\tfor (const listener of this.listeners[event.type]) {\n\t\t\tawait listener(event, this.mapper)\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAIO,MAAM,kBAAkB;AAAA,EAK9B,YACiB,QACA,MACf;AAFe,SAAA,SAAA;AACA,SAAA,OAAA;AANjB,kBAAA,MAAO,QAAO,mBAAA;AAEP,kBAAA,MAAA,YAAA;AAAA,EAAA;AAOR;AAEO,MAAM,iBAAiB;AAAA,EAG7B,YACiB,QACA,MACA,IACf;AAHe,SAAA,SAAA;AACA,SAAA,OAAA;AACA,SAAA,KAAA;AALjB,kBAAA,MAAO,QAAO,kBAAA;AAAA,EAAA;AAQf;AAGO,MAAM,kBAAkB;AAAA,EAK9B,YACiB,QACA,MACA,IACf;AAHe,SAAA,SAAA;AACA,SAAA,OAAA;AACA,SAAA,KAAA;AAPjB,kBAAA,MAAO,QAAO,mBAAA;AAEP,kBAAA,MAAA,YAAA;AAAA,EAAA;AAQR;AAEO,MAAM,iBAAiB;AAAA,EAK7B,YACiB,QACA,MACA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AAA,MACpB,mBAAmB,CAAC;AAAA,MACpB,kBAAkB,CAAC;AAAA,MACnB,2BAA2B,CAAC;AAAA,MAC5B,0BAA0B,CAAA;AAAA,IAAC,CAC5B;AAAA,EAAA;AAAA,EAOO,OAAiC,MAAS,IAAsB;AACtE,SAAK,UAAU,IAAI,EAAE,KAAK,EAAE;AAAA,EAAA;AAAA,EAG7B,MAAa,KAA+B,OAAoB;AAC/D,eAAW,YAAY,KAAK,UAAU,MAAM,IAAI,GAAG;AAC5C,YAAA,SAAS,OAAO,KAAK,MAAM;AAAA,IAAA;AAAA,EAClC;AAEF;"}
|
|
@@ -31,7 +31,6 @@ class Mapper {
|
|
|
31
31
|
this.updater = updater;
|
|
32
32
|
this.inserter = inserter;
|
|
33
33
|
this.pathFactory = pathFactory;
|
|
34
|
-
__publicField(this, "primaryKeyCache", {});
|
|
35
34
|
__publicField(this, "systemVariablesSetupDone");
|
|
36
35
|
__publicField(this, "deletedEntities", new DeletedEntitiesStorage.DeletedEntitiesStorage());
|
|
37
36
|
__publicField(this, "mutex", new Mutex.Mutex());
|
|
@@ -125,10 +124,8 @@ class Mapper {
|
|
|
125
124
|
}
|
|
126
125
|
await this.setupSystemVariables();
|
|
127
126
|
return ErrorUtils.tryMutation(this.schema, this.schemaDatabaseMetadata, async () => {
|
|
128
|
-
const primaryValue = await this.getPrimaryValue(entity, by);
|
|
129
|
-
if (
|
|
130
|
-
return [new Result.MutationEntryNotFoundError([], by)];
|
|
131
|
-
}
|
|
127
|
+
const [primaryValue, err] = await this.getPrimaryValue(entity, by);
|
|
128
|
+
if (err) return [err];
|
|
132
129
|
return await this.updater.update(this, entity, primaryValue, data, filter);
|
|
133
130
|
});
|
|
134
131
|
}
|
|
@@ -138,10 +135,8 @@ class Mapper {
|
|
|
138
135
|
}
|
|
139
136
|
await this.setupSystemVariables();
|
|
140
137
|
return ErrorUtils.tryMutation(this.schema, this.schemaDatabaseMetadata, async () => {
|
|
141
|
-
const primaryValue = await this.getPrimaryValue(entity, by);
|
|
142
|
-
if (
|
|
143
|
-
return [new Result.MutationEntryNotFoundError([], by)];
|
|
144
|
-
}
|
|
138
|
+
const [primaryValue, err] = await this.getPrimaryValue(entity, by);
|
|
139
|
+
if (err) return [err];
|
|
145
140
|
return await this.updater.updateCb(this, entity, primaryValue, builderCb);
|
|
146
141
|
});
|
|
147
142
|
}
|
|
@@ -151,7 +146,7 @@ class Mapper {
|
|
|
151
146
|
}
|
|
152
147
|
await this.setupSystemVariables();
|
|
153
148
|
return ErrorUtils.tryMutation(this.schema, this.schemaDatabaseMetadata, async () => {
|
|
154
|
-
const primaryValue = await this.getPrimaryValue(entity, by);
|
|
149
|
+
const [primaryValue] = await this.getPrimaryValue(entity, by);
|
|
155
150
|
if (primaryValue === void 0) {
|
|
156
151
|
return await this.insertInternal(entity, create);
|
|
157
152
|
}
|
|
@@ -161,8 +156,6 @@ class Mapper {
|
|
|
161
156
|
insertInternal(entity, data, builderCb = () => {
|
|
162
157
|
}) {
|
|
163
158
|
return this.inserter.insert(this, entity, data, (id) => {
|
|
164
|
-
const where = { [entity.primary]: id };
|
|
165
|
-
this.primaryKeyCache[this.hashWhere(entity.name, where)] = id;
|
|
166
159
|
}, builderCb);
|
|
167
160
|
}
|
|
168
161
|
async delete(entity, by, filter) {
|
|
@@ -214,23 +207,10 @@ class Mapper {
|
|
|
214
207
|
}
|
|
215
208
|
async getPrimaryValue(entity, where) {
|
|
216
209
|
if (where instanceof CheckedPrimary.CheckedPrimary) {
|
|
217
|
-
return where.primaryValue;
|
|
210
|
+
return [where.primaryValue, void 0];
|
|
218
211
|
}
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
return this.primaryKeyCache[hash];
|
|
222
|
-
}
|
|
223
|
-
const primaryPromise = this.selectField(entity, where, entity.primary);
|
|
224
|
-
this.primaryKeyCache[hash] = primaryPromise;
|
|
225
|
-
const primaryValue = await primaryPromise;
|
|
226
|
-
const uniqueFields = Object.keys(where);
|
|
227
|
-
if (primaryValue && (uniqueFields.length !== 1 || uniqueFields[0] !== entity.primary)) {
|
|
228
|
-
this.primaryKeyCache[this.hashWhere(entity.name, { [entity.primary]: primaryValue })] = primaryValue;
|
|
229
|
-
}
|
|
230
|
-
return primaryValue;
|
|
231
|
-
}
|
|
232
|
-
hashWhere(entityName, where) {
|
|
233
|
-
return JSON.stringify([entityName, where]);
|
|
212
|
+
const result = await this.selectField(entity, where, entity.primary);
|
|
213
|
+
return result ? [result, void 0] : [void 0, new Result.MutationEntryNotFoundError([], where)];
|
|
234
214
|
}
|
|
235
215
|
async setupSystemVariables() {
|
|
236
216
|
this.systemVariablesSetupDone ?? (this.systemVariablesSetupDone = (async () => {
|