@sap/cds 8.9.4 → 9.0.2
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/CHANGELOG.md +113 -680
- package/LICENSE +15 -21
- package/README.md +1 -1
- package/_i18n/i18n_sl.properties +3 -3
- package/_i18n/messages.properties +1 -1
- package/app/index.js +1 -1
- package/bin/serve.js +17 -19
- package/eslint.config.mjs +7 -1
- package/lib/compile/etc/_localized.js +3 -24
- package/lib/compile/etc/yaml.js +6 -15
- package/lib/compile/for/odata.js +2 -2
- package/lib/compile/load.js +15 -4
- package/lib/compile/minify.js +1 -0
- package/lib/compile/to/edm-files.js +4 -33
- package/lib/compile/to/hdbtabledata.js +16 -3
- package/lib/compile/to/sql.js +1 -2
- package/lib/core/linked-csn.js +7 -8
- package/lib/dbs/cds-deploy.js +4 -3
- package/lib/env/cds-env.js +9 -9
- package/lib/env/cds-requires.js +23 -50
- package/lib/env/defaults.js +15 -44
- package/lib/env/schemas/cds-package.js +1 -1
- package/lib/i18n/index.js +1 -0
- package/lib/i18n/locale.js +41 -0
- package/lib/index.js +25 -15
- package/lib/log/cds-error.js +12 -3
- package/lib/log/cds-log.js +43 -18
- package/lib/log/format/aspects/als.js +2 -15
- package/lib/plugins.js +11 -11
- package/lib/ql/CREATE.js +1 -1
- package/lib/ql/DELETE.js +1 -1
- package/lib/ql/DROP.js +1 -1
- package/lib/ql/INSERT.js +9 -18
- package/lib/ql/SELECT.js +12 -19
- package/lib/ql/UPDATE.js +1 -1
- package/lib/ql/UPSERT.js +1 -0
- package/lib/ql/Whereable.js +7 -6
- package/lib/ql/cds-ql.js +0 -12
- package/lib/ql/cds.ql-Query.js +28 -68
- package/lib/ql/cds.ql-infer.js +97 -108
- package/lib/ql/resolve.js +1 -3
- package/lib/req/context.js +5 -4
- package/lib/req/request.js +46 -42
- package/lib/req/response.js +5 -9
- package/lib/req/spawn.js +38 -0
- package/lib/req/validate.js +9 -8
- package/lib/srv/bindings.js +2 -1
- package/lib/srv/cds-connect.js +5 -2
- package/lib/srv/cds-serve.js +0 -2
- package/lib/srv/cds.Service.js +146 -86
- package/lib/srv/middlewares/auth/ias-auth.js +99 -88
- package/lib/srv/middlewares/auth/jwt-auth.js +44 -57
- package/lib/srv/middlewares/cds-context.js +1 -1
- package/lib/srv/middlewares/ctx-model.js +1 -1
- package/lib/srv/middlewares/errors.js +34 -42
- package/lib/srv/protocols/hcql.js +35 -25
- package/lib/srv/protocols/index.js +0 -9
- package/lib/srv/protocols/odata-v4.js +1 -6
- package/lib/srv/srv-dispatch.js +29 -31
- package/lib/srv/srv-handlers.js +14 -46
- package/lib/srv/srv-methods.js +15 -37
- package/lib/srv/srv-tx.js +19 -25
- package/lib/test/cds-test.js +4 -263
- package/lib/utils/cds-utils.js +18 -2
- package/lib/utils/tar.js +6 -8
- package/lib/utils/unit.js +19 -0
- package/libx/_runtime/.eslintrc +1 -1
- package/libx/_runtime/cds-services/util/assert.js +2 -72
- package/libx/_runtime/cds.js +13 -6
- package/libx/_runtime/common/Service.js +33 -75
- package/libx/_runtime/common/aspects/any.js +0 -38
- package/libx/_runtime/common/constants/events.js +5 -13
- package/libx/_runtime/common/generic/auth/autoexpose.js +10 -24
- package/libx/_runtime/common/generic/auth/capabilities.js +23 -20
- package/libx/_runtime/common/generic/auth/expand.js +3 -3
- package/libx/_runtime/common/generic/auth/index.js +3 -3
- package/libx/_runtime/common/generic/auth/insertOnly.js +3 -3
- package/libx/_runtime/common/generic/auth/readOnly.js +4 -4
- package/libx/_runtime/common/generic/auth/requires.js +4 -4
- package/libx/_runtime/common/generic/auth/restrict.js +12 -29
- package/libx/_runtime/common/generic/auth/service.js +3 -3
- package/libx/_runtime/common/generic/auth/utils.js +2 -12
- package/libx/_runtime/common/generic/crud.js +22 -53
- package/libx/_runtime/common/generic/etag.js +18 -31
- package/libx/_runtime/common/generic/input.js +51 -123
- package/libx/_runtime/common/generic/paging.js +4 -4
- package/libx/_runtime/common/generic/sorting.js +8 -19
- package/libx/_runtime/common/generic/stream-only.js +26 -0
- package/libx/_runtime/common/generic/stream.js +16 -48
- package/libx/_runtime/common/generic/temporal.js +15 -6
- package/libx/_runtime/common/utils/binary.js +1 -26
- package/libx/_runtime/common/utils/compareJson.js +1 -2
- package/libx/_runtime/common/utils/cqn.js +15 -14
- package/libx/_runtime/common/utils/differ.js +121 -44
- package/libx/_runtime/common/utils/keys.js +4 -5
- package/libx/_runtime/common/utils/postProcess.js +2 -2
- package/libx/_runtime/common/utils/propagateForeignKeys.js +21 -36
- package/libx/_runtime/common/utils/resolveView.js +105 -141
- package/libx/_runtime/common/utils/rewriteAsterisks.js +45 -12
- package/libx/_runtime/common/utils/streamProp.js +3 -9
- package/libx/_runtime/common/utils/waitingTime.js +13 -1
- package/libx/_runtime/fiori/lean-draft.js +174 -196
- package/libx/_runtime/messaging/common-utils/connections.js +1 -1
- package/libx/_runtime/messaging/enterprise-messaging-utils/EMManagement.js +1 -0
- package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +3 -3
- package/libx/_runtime/messaging/enterprise-messaging.js +2 -2
- package/libx/_runtime/messaging/file-based.js +2 -4
- package/libx/_runtime/messaging/redis-messaging.js +1 -1
- package/libx/_runtime/messaging/service.js +5 -19
- package/libx/_runtime/remote/Service.js +20 -33
- package/libx/_runtime/remote/utils/client.js +7 -25
- package/libx/_runtime/remote/utils/cloudSdkProvider.js +8 -13
- package/libx/_runtime/remote/utils/data.js +3 -34
- package/libx/_runtime/types/api.js +0 -8
- package/libx/_runtime/ucl/Service.js +1 -9
- package/libx/common/utils/path.js +2 -3
- package/libx/common/utils/streaming.js +2 -1
- package/libx/http/HttpRequest.js +13 -0
- package/libx/{odata/middleware → http}/body-parser.js +7 -5
- package/libx/http/location.js +41 -0
- package/libx/http/put.js +36 -0
- package/libx/odata/ODataAdapter.js +25 -59
- package/libx/odata/index.js +10 -23
- package/libx/odata/middleware/batch.js +29 -20
- package/libx/odata/middleware/create.js +6 -13
- package/libx/odata/middleware/delete.js +0 -4
- package/libx/odata/middleware/error.js +83 -27
- package/libx/odata/middleware/metadata.js +14 -25
- package/libx/odata/middleware/operation.js +10 -26
- package/libx/odata/middleware/read.js +10 -18
- package/libx/odata/middleware/stream.js +14 -34
- package/libx/odata/middleware/update.js +17 -26
- package/libx/odata/parse/afterburner.js +20 -16
- package/libx/odata/parse/cqn2odata.js +3 -1
- package/libx/odata/parse/grammar.peggy +221 -114
- package/libx/odata/parse/parser.js +1 -1
- package/libx/odata/utils/index.js +10 -38
- package/libx/odata/utils/metadata.js +1 -4
- package/libx/odata/utils/normalizeTimeData.js +4 -7
- package/libx/odata/utils/readAfterWrite.js +1 -1
- package/libx/{outbox/OutboxRunner.js → queue/TaskRunner.js} +17 -22
- package/libx/queue/index.js +530 -0
- package/libx/rest/RestAdapter.js +43 -82
- package/libx/rest/middleware/create.js +35 -33
- package/libx/rest/middleware/delete.js +9 -7
- package/libx/rest/middleware/error.js +11 -18
- package/libx/rest/middleware/operation.js +44 -137
- package/libx/rest/middleware/parse.js +114 -130
- package/libx/rest/middleware/read.js +23 -21
- package/libx/rest/middleware/update.js +20 -32
- package/libx/rest/middleware/upsert.js +31 -0
- package/libx/rest/pre-processing.js +8 -18
- package/package.json +6 -7
- package/srv/outbox.cds +1 -0
- package/bin/test.js +0 -125
- package/lib/env/plugins.js +0 -18
- package/lib/req/cds-context.js +0 -52
- package/lib/req/locale.js +0 -35
- package/lib/srv/cds.ServiceClient.js +0 -96
- package/lib/srv/cds.ServiceProvider.js +0 -20
- package/lib/srv/protocols/okra.js +0 -22
- package/lib/test/axios.js +0 -63
- package/lib/test/data.js +0 -52
- package/lib/test/expect.js +0 -343
- package/lib/test/reporter.js +0 -176
- package/libx/_runtime/cds-services/adapter/odata-v4/OData.js +0 -275
- package/libx/_runtime/cds-services/adapter/odata-v4/ODataRequest.js +0 -217
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/action.js +0 -101
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/create.js +0 -79
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/debug.js +0 -6
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/delete.js +0 -60
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/error.js +0 -161
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/language.js +0 -7
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/metadata.js +0 -59
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/read.js +0 -602
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/request.js +0 -64
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/update.js +0 -238
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/ExpressionToCQN.js +0 -327
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/applyToCQN.js +0 -243
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/boundToCQN.js +0 -43
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/createToCQN.js +0 -37
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/deleteToCQN.js +0 -36
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/expandToCQN.js +0 -250
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/index.js +0 -81
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/orderByToCQN.js +0 -51
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/readToCQN.js +0 -389
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/searchToCQN.js +0 -43
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/selectToCQN.js +0 -35
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/updateToCQN.js +0 -38
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/utils.js +0 -217
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/FeatureSupport.js +0 -70
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/FullQualifiedName.js +0 -94
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlAction.js +0 -139
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlActionImport.js +0 -82
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlAliasInfo.js +0 -44
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlAnnotation.js +0 -104
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlAnnotations.js +0 -71
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlComplexType.js +0 -133
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlEntityContainer.js +0 -142
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlEntityContainerInfo.js +0 -37
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlEntitySet.js +0 -107
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlEntityType.js +0 -177
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlEnumMember.js +0 -61
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlEnumType.js +0 -105
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlFunction.js +0 -149
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlFunctionImport.js +0 -105
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlInclude.js +0 -68
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlIncludeAnnotation.js +0 -71
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlJsonProvider.js +0 -1365
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlNavigationProperty.js +0 -190
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlNavigationPropertyBinding.js +0 -37
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlOnDelete.js +0 -70
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlParameter.js +0 -227
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlProperty.js +0 -250
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlPropertyRef.js +0 -49
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlProvider.js +0 -190
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlReference.js +0 -97
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlReferentialConstraint.js +0 -60
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlReturnType.js +0 -216
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlSchema.js +0 -328
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlSingleton.js +0 -84
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlTerm.js +0 -320
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/CsdlTypeDefinition.js +0 -193
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlAnnotationExpression.js +0 -73
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlAnnotationPathExpression.js +0 -33
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlApplyExpression.js +0 -105
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlArithmeticExpression.js +0 -72
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlBinaryExpression.js +0 -110
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlCastExpression.js +0 -188
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlCollectionExpression.js +0 -48
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlConstantExpression.js +0 -116
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlIfExpression.js +0 -62
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlIsOfExpression.js +0 -200
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlLabeledElementExpression.js +0 -42
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlLabeledElementReferenceExpression.js +0 -31
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlModelElementPathExpression.js +0 -29
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlNavigationPropertyPathExpression.js +0 -31
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlNegationExpression.js +0 -27
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlNotExpression.js +0 -31
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlNullExpression.js +0 -18
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlPathExpression.js +0 -32
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlPropertyPathExpression.js +0 -32
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlPropertyValueExpression.js +0 -55
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlRecordExpression.js +0 -54
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlUnknownExpression.js +0 -44
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/csdl/annotationExpression/CsdlUrlRefExpression.js +0 -31
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/AbstractEdmBindingTarget.js +0 -163
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/AbstractEdmFaceted.js +0 -136
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/AbstractEdmOperation.js +0 -205
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/AbstractEdmOperationImport.js +0 -126
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/AbstractEdmStructuredType.js +0 -275
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/Edm.js +0 -775
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmAction.js +0 -15
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmActionImport.js +0 -39
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmAnnotation.js +0 -106
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmAnnotations.js +0 -57
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmComplexType.js +0 -48
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmEntityContainer.js +0 -455
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmEntitySet.js +0 -43
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmEntityType.js +0 -119
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmEnumMember.js +0 -69
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmEnumType.js +0 -117
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmFunction.js +0 -39
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmFunctionImport.js +0 -59
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmInclude.js +0 -65
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmIncludeAnnotation.js +0 -48
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmKeyPropertyRef.js +0 -79
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmNavigationProperty.js +0 -182
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmNavigationPropertyBinding.js +0 -46
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmOnDelete.js +0 -44
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmParameter.js +0 -22
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmPrimitiveType.js +0 -31
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmPrimitiveTypeKind.js +0 -70
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmProperty.js +0 -39
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmProvider.js +0 -399
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmReference.js +0 -88
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmReferentialConstraint.js +0 -71
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmReturnType.js +0 -14
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmSchema.js +0 -355
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmSingleton.js +0 -15
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmTerm.js +0 -75
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmType.js +0 -95
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmTypeDefinition.js +0 -121
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmTypeFactory.js +0 -28
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmVocabularyTermType.js +0 -41
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/KeyFactory.js +0 -67
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/Target.js +0 -56
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/TransientStructuredType.js +0 -244
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/AnnotationExpressionFactory.js +0 -130
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmAnnotationExpression.js +0 -28
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmAnnotationPathExpression.js +0 -42
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmApplyExpression.js +0 -85
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmArithmeticExpression.js +0 -92
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmBinaryExpression.js +0 -96
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmCastExpression.js +0 -129
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmCollectionExpression.js +0 -52
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmConstantExpression.js +0 -83
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmIfExpression.js +0 -103
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmIsOfExpression.js +0 -125
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmLabeledElementExpression.js +0 -83
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmLabeledElementReferenceExpression.js +0 -41
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmModelElementPathExpression.js +0 -35
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmNavigationPropertyPathExpression.js +0 -37
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmNegationExpression.js +0 -70
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmNotExpression.js +0 -75
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmNullExpression.js +0 -50
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmPathExpression.js +0 -38
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmPropertyPathExpression.js +0 -37
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmPropertyValueExpression.js +0 -72
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmRecordExpression.js +0 -100
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmUnknownExpression.js +0 -72
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/annotationExpression/EdmUrlRefExpression.js +0 -73
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/errors/AbstractError.js +0 -82
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/errors/IllegalArgumentError.js +0 -58
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/errors/IllegalCallError.js +0 -21
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/errors/NotImplementedError.js +0 -19
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/errors/UriQueryOptionSemanticError.js +0 -49
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/errors/UriSemanticError.js +0 -48
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/errors/UriSyntaxError.js +0 -65
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/format/ContentTypeInfo.js +0 -105
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/format/JsonContentTypeInfo.js +0 -83
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/format/JsonFormat.js +0 -141
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/format/RepresentationKind.js +0 -251
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/http/HttpHeader.js +0 -42
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/http/HttpHeaderReader.js +0 -318
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/http/HttpMethod.js +0 -25
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/http/HttpStatusCode.js +0 -52
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/http/Preferences.js +0 -32
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/index.js +0 -69
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/logging/LoggerFacade.js +0 -183
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/AliasExpression.js +0 -47
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/ApplyParser.js +0 -946
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/BinaryExpression.js +0 -124
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/ExpandItem.js +0 -76
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/ExpandParser.js +0 -384
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/Expression.js +0 -46
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/ExpressionParser.js +0 -1988
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/FilterParser.js +0 -34
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/FunctionParameterParser.js +0 -106
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/KeyPredicateParser.js +0 -155
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/KeyValueParser.js +0 -213
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/LiteralExpression.js +0 -43
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/MemberExpression.js +0 -44
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/MethodExpression.js +0 -146
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/OrderByItem.js +0 -53
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/OrderByParser.js +0 -69
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/ResourcePathParser.js +0 -848
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/SearchParser.js +0 -127
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/SelectItem.js +0 -80
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/SelectParser.js +0 -294
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/TypeLiteralExpression.js +0 -28
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UnaryExpression.js +0 -64
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriHelper.js +0 -65
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriInfo.js +0 -165
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriParameter.js +0 -107
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriParser.js +0 -350
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriResource.js +0 -602
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriTokenizer.js +0 -1156
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/AggregateExpression.js +0 -164
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/AggregateTransformation.js +0 -38
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/BottomTopTransformation.js +0 -93
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/ComputeExpression.js +0 -52
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/ComputeTransformation.js +0 -38
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/ConcatTransformation.js +0 -38
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/CustomFunctionTransformation.js +0 -59
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/ExpandTransformation.js +0 -37
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/FilterTransformation.js +0 -37
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/GroupByItem.js +0 -71
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/GroupByTransformation.js +0 -58
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/IdentityTransformation.js +0 -17
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/OrderByTransformation.js +0 -37
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/SearchTransformation.js +0 -37
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/SkipTransformation.js +0 -37
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/TopTransformation.js +0 -37
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/apply/Transformation.js +0 -53
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/info.md +0 -116
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/utils/PrimitiveValueDecoder.js +0 -667
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/utils/PrimitiveValueEncoder.js +0 -349
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/utils/ValueConverter.js +0 -545
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/validator/ParameterValidator.js +0 -124
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/validator/ValueValidator.js +0 -743
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/ServiceFactory.js +0 -234
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/batch/BatchContext.js +0 -351
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/batch/BatchErrorInfo.js +0 -61
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/batch/BatchExitHandler.js +0 -239
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/batch/BatchProcessor.js +0 -281
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/batch/BatchValidator.js +0 -133
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/batch/BatchedRequestExecutor.js +0 -92
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/ComponentManager.js +0 -63
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/Context.js +0 -96
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/Dispatcher.js +0 -147
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/OdataRequest.js +0 -458
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/OdataRequestInBatch.js +0 -147
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/OdataResponse.js +0 -314
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/OdataResponseInBatch.js +0 -83
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/PlainHttpRequest.js +0 -175
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/PlainHttpResponse.js +0 -106
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/RequestContract.js +0 -111
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/ResponseContract.js +0 -111
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/ResponseHeaderSetter.js +0 -240
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/Service.js +0 -417
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/ServiceResolutions.js +0 -24
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/ApplicationHttpReader.js +0 -157
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/BatchJsonDeserializer.js +0 -171
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/BatchRequestListBuilder.js +0 -196
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/Cache.js +0 -154
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/ContentDeserializer.js +0 -222
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/DataReader.js +0 -220
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/DeserializerFactory.js +0 -240
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/HeaderReader.js +0 -133
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/LineReader.js +0 -61
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/MultipartReader.js +0 -419
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/PartReader.js +0 -99
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/Reader.js +0 -52
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/ResourceJsonDeserializer.js +0 -673
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/errors/ApplicationError.js +0 -108
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/errors/BadRequestError.js +0 -21
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/errors/ConflictError.js +0 -11
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/errors/DeserializationError.js +0 -19
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/errors/InternalServerError.js +0 -20
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/errors/MethodNotAllowedError.js +0 -17
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/errors/NotAcceptableError.js +0 -21
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/errors/NotFoundError.js +0 -33
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/errors/PreconditionFailedError.js +0 -11
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/errors/PreconditionRequiredError.js +0 -11
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/errors/SerializationError.js +0 -19
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/errors/UnauthorizedError.js +0 -17
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/format/AcceptTypeInfo.js +0 -86
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/format/CharsetInfo.js +0 -76
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/format/FormatDescription.js +0 -43
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/format/FormatManager.js +0 -91
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/format/RequestContentNegotiator.js +0 -62
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/format/ResponseContentNegotiator.js +0 -321
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/handler/BatchHandler.js +0 -36
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/handler/MetadataHandler.js +0 -21
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/handler/ServiceHandler.js +0 -25
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/http/CustomPreference.js +0 -31
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/http/HeaderInfo.js +0 -79
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/http/HttpHeader.js +0 -59
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/http/HttpHeaderReader.js +0 -452
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/http/HttpStatusCode.js +0 -117
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/http/Preferences.js +0 -222
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/http/PreferencesApplied.js +0 -199
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/index.js +0 -37
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/Command.js +0 -31
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/CommandExecutor.js +0 -94
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/CommandFactory.js +0 -203
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/ConditionalRequestControlCommand.js +0 -52
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/ConditionalRequestPreValidationCommand.js +0 -59
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/ContentNegotiatorCommand.js +0 -70
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/DebugContentNegotiatorCommand.js +0 -59
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/DebugDeserializingCommand.js +0 -44
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/DebugSerializingCommand.js +0 -51
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/DeserializingCommand.js +0 -69
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/DispatcherCommand.js +0 -95
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/ErrorContentNegotiatorCommand.js +0 -44
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/ErrorSerializingCommand.js +0 -51
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/EventListenerCommand.js +0 -59
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/LocaleNegotiatorCommand.js +0 -56
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/OdataVersionValidationCommand.js +0 -41
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/OperationValidationCommand.js +0 -34
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/ParsePreferHeaderCommand.js +0 -47
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/PresetResponseHeadersCommand.js +0 -47
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/QueryOptionsParserCommand.js +0 -43
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/QueryOptionsValidationCommand.js +0 -62
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/RequestContentValidationCommand.js +0 -51
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/SendResponseCommand.js +0 -37
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/SerializingCommand.js +0 -159
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/SetResponseHeadersCommand.js +0 -90
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/SetStatuscodeCommand.js +0 -51
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/UriParserCommand.js +0 -47
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/logging/DebugLogger.js +0 -97
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ApplicationHttpWriter.js +0 -65
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/BatchJsonSerializer.js +0 -46
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/BatchMultipartSerializer.js +0 -113
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ContextURLFactory.js +0 -405
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/DebugHtmlSerializer.js +0 -302
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/DebugJsonSerializer.js +0 -515
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ErrorJsonSerializer.js +0 -47
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ErrorSerializer.js +0 -39
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ErrorXmlSerializer.js +0 -98
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ExpressionTreeImage.js +0 -404
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/MetadataXmlSerializer.js +0 -1416
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/MultipartWriter.js +0 -202
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/NextLinkSerializer.js +0 -330
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ResourceJsonSerializer.js +0 -1220
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/SerializerFactory.js +0 -484
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ServiceJsonSerializer.js +0 -89
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/TrustedResourceJsonSerializer.js +0 -612
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/debugview.html +0 -157
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/utils/BufferedWriter.js +0 -59
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/utils/ExpandHelper.js +0 -96
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/utils/MetadataCache.js +0 -136
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/utils/PerformanceMonitor.js +0 -221
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/utils/UriHelper.js +0 -157
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/validator/ConditionalRequestValidator.js +0 -79
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/validator/OperationValidator.js +0 -199
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/validator/RequestValidator.js +0 -392
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/validator/VersionValidator.js +0 -62
- package/libx/_runtime/cds-services/adapter/odata-v4/to.js +0 -51
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js +0 -331
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/handlerUtils.js +0 -159
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/metaInfo.js +0 -404
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/oDataConfiguration.js +0 -55
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/omitValues.js +0 -86
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/readAfterWrite.js +0 -107
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/request.js +0 -64
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/result.js +0 -385
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/stream.js +0 -12
- package/libx/_runtime/cds-services/util/errors.js +0 -15
- package/libx/_runtime/common/aspects/relation.js +0 -40
- package/libx/_runtime/common/composition/data.js +0 -370
- package/libx/_runtime/common/composition/delete.js +0 -313
- package/libx/_runtime/common/composition/index.js +0 -22
- package/libx/_runtime/common/composition/insert.js +0 -108
- package/libx/_runtime/common/composition/tree.js +0 -275
- package/libx/_runtime/common/composition/update.js +0 -354
- package/libx/_runtime/common/composition/utils.js +0 -95
- package/libx/_runtime/common/error/constants.js +0 -20
- package/libx/_runtime/common/error/entry.js +0 -36
- package/libx/_runtime/common/error/frontend.js +0 -199
- package/libx/_runtime/common/error/index.js +0 -12
- package/libx/_runtime/common/error/log.js +0 -35
- package/libx/_runtime/common/error/standardError.js +0 -11
- package/libx/_runtime/common/error/utils.js +0 -18
- package/libx/_runtime/common/generic/auth/constants.js +0 -17
- package/libx/_runtime/common/generic/put.js +0 -85
- package/libx/_runtime/common/utils/columns.js +0 -177
- package/libx/_runtime/common/utils/compareJsonOLD.js +0 -280
- package/libx/_runtime/common/utils/cqn2cqn4sql.js +0 -1039
- package/libx/_runtime/common/utils/data.js +0 -16
- package/libx/_runtime/common/utils/dollar.js +0 -27
- package/libx/_runtime/common/utils/generateOnCond.js +0 -127
- package/libx/_runtime/common/utils/onlyKeysRemain.js +0 -10
- package/libx/_runtime/common/utils/path.js +0 -20
- package/libx/_runtime/common/utils/quotingStyles.js +0 -29
- package/libx/_runtime/common/utils/restrictions.js +0 -67
- package/libx/_runtime/common/utils/search2cqn4sql.js +0 -37
- package/libx/_runtime/common/utils/searchToLike.js +0 -56
- package/libx/_runtime/common/utils/stream.js +0 -103
- package/libx/_runtime/common/utils/ucsn.js +0 -119
- package/libx/_runtime/common/utils/union.js +0 -31
- package/libx/_runtime/common/utils/unionCqnTemplate.js +0 -174
- package/libx/_runtime/db/Service.js +0 -93
- package/libx/_runtime/db/data-conversion/post-processing.js +0 -175
- package/libx/_runtime/db/expand/expand-v2.js +0 -147
- package/libx/_runtime/db/expand/expandCQNToJoin.js +0 -1775
- package/libx/_runtime/db/expand/index.js +0 -13
- package/libx/_runtime/db/expand/rawToExpanded.js +0 -250
- package/libx/_runtime/db/generic/create.js +0 -30
- package/libx/_runtime/db/generic/delete.js +0 -18
- package/libx/_runtime/db/generic/index.js +0 -25
- package/libx/_runtime/db/generic/input.js +0 -227
- package/libx/_runtime/db/generic/read.js +0 -16
- package/libx/_runtime/db/generic/rewrite.js +0 -68
- package/libx/_runtime/db/generic/structured.js +0 -92
- package/libx/_runtime/db/generic/update.js +0 -97
- package/libx/_runtime/db/generic/virtual.js +0 -83
- package/libx/_runtime/db/query/delete.js +0 -39
- package/libx/_runtime/db/query/index.js +0 -13
- package/libx/_runtime/db/query/insert.js +0 -21
- package/libx/_runtime/db/query/read.js +0 -97
- package/libx/_runtime/db/query/run.js +0 -30
- package/libx/_runtime/db/query/update.js +0 -94
- package/libx/_runtime/db/result/InsertResult.js +0 -87
- package/libx/_runtime/db/sql-builder/BaseBuilder.js +0 -65
- package/libx/_runtime/db/sql-builder/CreateBuilder.js +0 -212
- package/libx/_runtime/db/sql-builder/DeleteBuilder.js +0 -87
- package/libx/_runtime/db/sql-builder/DropBuilder.js +0 -63
- package/libx/_runtime/db/sql-builder/ExpressionBuilder.js +0 -345
- package/libx/_runtime/db/sql-builder/FunctionBuilder.js +0 -232
- package/libx/_runtime/db/sql-builder/InsertBuilder.js +0 -494
- package/libx/_runtime/db/sql-builder/ReferenceBuilder.js +0 -135
- package/libx/_runtime/db/sql-builder/SelectBuilder.js +0 -482
- package/libx/_runtime/db/sql-builder/UpdateBuilder.js +0 -207
- package/libx/_runtime/db/sql-builder/UpsertBuilder.js +0 -25
- package/libx/_runtime/db/sql-builder/annotations.js +0 -50
- package/libx/_runtime/db/sql-builder/arrayed.js +0 -4
- package/libx/_runtime/db/sql-builder/dataTypes.js +0 -59
- package/libx/_runtime/db/sql-builder/dollar.js +0 -37
- package/libx/_runtime/db/sql-builder/index.js +0 -28
- package/libx/_runtime/db/sql-builder/sqlFactory.js +0 -104
- package/libx/_runtime/db/utils/coloredTxCommands.js +0 -7
- package/libx/_runtime/db/utils/columns.js +0 -41
- package/libx/_runtime/db/utils/deep.js +0 -71
- package/libx/_runtime/db/utils/generateAliases.js +0 -160
- package/libx/_runtime/db/utils/localized.js +0 -77
- package/libx/_runtime/db/utils/normalizeTimeData.js +0 -98
- package/libx/_runtime/db/utils/stream.js +0 -41
- package/libx/_runtime/hana/Service.js +0 -173
- package/libx/_runtime/hana/conversion.js +0 -73
- package/libx/_runtime/hana/customBuilder/CustomCreateBuilder.js +0 -11
- package/libx/_runtime/hana/customBuilder/CustomDeleteBuilder.js +0 -17
- package/libx/_runtime/hana/customBuilder/CustomDropBuilder.js +0 -12
- package/libx/_runtime/hana/customBuilder/CustomExpressionBuilder.js +0 -23
- package/libx/_runtime/hana/customBuilder/CustomFunctionBuilder.js +0 -34
- package/libx/_runtime/hana/customBuilder/CustomReferenceBuilder.js +0 -38
- package/libx/_runtime/hana/customBuilder/CustomSelectBuilder.js +0 -90
- package/libx/_runtime/hana/customBuilder/index.js +0 -11
- package/libx/_runtime/hana/driver.js +0 -205
- package/libx/_runtime/hana/dynatrace.js +0 -130
- package/libx/_runtime/hana/execute.js +0 -429
- package/libx/_runtime/hana/localized.js +0 -39
- package/libx/_runtime/hana/pool.js +0 -186
- package/libx/_runtime/hana/search.js +0 -20
- package/libx/_runtime/hana/search2Contains.js +0 -106
- package/libx/_runtime/hana/search2cqn4sql.js +0 -98
- package/libx/_runtime/hana/streaming.js +0 -248
- package/libx/_runtime/messaging/Outbox.js +0 -15
- package/libx/_runtime/sqlite/Service.js +0 -153
- package/libx/_runtime/sqlite/conversion.js +0 -47
- package/libx/_runtime/sqlite/convertAssocToOneManaged.js +0 -60
- package/libx/_runtime/sqlite/convertDraftAdminPathExpression.js +0 -74
- package/libx/_runtime/sqlite/customBuilder/CustomExpressionBuilder.js +0 -24
- package/libx/_runtime/sqlite/customBuilder/CustomFunctionBuilder.js +0 -102
- package/libx/_runtime/sqlite/customBuilder/CustomSelectBuilder.js +0 -16
- package/libx/_runtime/sqlite/customBuilder/CustomUpsertBuilder.js +0 -47
- package/libx/_runtime/sqlite/customBuilder/index.js +0 -49
- package/libx/_runtime/sqlite/execute.js +0 -345
- package/libx/_runtime/sqlite/localized.js +0 -49
- package/libx/outbox/index.js +0 -307
|
@@ -1,1775 +0,0 @@
|
|
|
1
|
-
const cds = require('../../cds')
|
|
2
|
-
|
|
3
|
-
const { Object_keys } = cds.utils
|
|
4
|
-
|
|
5
|
-
const { getAllKeys } = require('../../cds-services/adapter/odata-v4/odata-to-cqn/utils')
|
|
6
|
-
|
|
7
|
-
const { deepCopy } = require('../../common/utils/copy')
|
|
8
|
-
const { getNavigationIfStruct } = require('../../common/utils/structured')
|
|
9
|
-
const { ensureNoDraftsSuffix, ensureDraftsSuffix, ensureUnlocalized } = require('../../common/utils/draft')
|
|
10
|
-
const { isAsteriskColumn } = require('../../common/utils/rewriteAsterisks')
|
|
11
|
-
const { getCQNUnionFrom } = require('../../common/utils/union')
|
|
12
|
-
|
|
13
|
-
const { DRAFT_COLUMNS_MAP } = require('../../common/constants/draft')
|
|
14
|
-
|
|
15
|
-
const getError = require('../../common/error')
|
|
16
|
-
|
|
17
|
-
// Symbols are used to add extra information in response structure
|
|
18
|
-
const GET_KEY_VALUE = Symbol.for('sap.cds.getKeyValue')
|
|
19
|
-
const TO_MANY = Symbol.for('sap.cds.toMany')
|
|
20
|
-
const TO_ACTIVE = Symbol.for('sap.cds.toActive')
|
|
21
|
-
const SKIP_MAPPING = Symbol.for('sap.cds.skipMapping')
|
|
22
|
-
const IDENTIFIER = Symbol.for('sap.cds.identifier')
|
|
23
|
-
const IS_ACTIVE = Symbol.for('sap.cds.isActive')
|
|
24
|
-
const IS_UNION_DRAFT = Symbol.for('sap.cds.isUnionDraft')
|
|
25
|
-
const CLEANUP_KEYS = Symbol.for('sap.cds.cleanupKeys')
|
|
26
|
-
|
|
27
|
-
function getCqnCopy(readToOneCQN) {
|
|
28
|
-
// REVISIT: Use query.clone() instead
|
|
29
|
-
const readToOneCQNCopy = deepCopy(readToOneCQN)
|
|
30
|
-
if (readToOneCQN[GET_KEY_VALUE] !== undefined) readToOneCQNCopy[GET_KEY_VALUE] = readToOneCQN[GET_KEY_VALUE]
|
|
31
|
-
if (readToOneCQN[TO_MANY] !== undefined) readToOneCQNCopy[TO_MANY] = readToOneCQN[TO_MANY]
|
|
32
|
-
if (readToOneCQN[TO_ACTIVE] !== undefined) readToOneCQNCopy[TO_ACTIVE] = readToOneCQN[TO_ACTIVE]
|
|
33
|
-
if (readToOneCQN[SKIP_MAPPING] !== undefined) readToOneCQNCopy[SKIP_MAPPING] = readToOneCQN[SKIP_MAPPING]
|
|
34
|
-
if (readToOneCQN[IDENTIFIER] !== undefined) readToOneCQNCopy[IDENTIFIER] = readToOneCQN[IDENTIFIER]
|
|
35
|
-
if (readToOneCQN[IS_ACTIVE] !== undefined) readToOneCQNCopy[IS_ACTIVE] = readToOneCQN[IS_ACTIVE]
|
|
36
|
-
if (readToOneCQN[IS_UNION_DRAFT] !== undefined) readToOneCQNCopy[IS_UNION_DRAFT] = readToOneCQN[IS_UNION_DRAFT]
|
|
37
|
-
if (readToOneCQN[CLEANUP_KEYS] !== undefined) readToOneCQNCopy[CLEANUP_KEYS] = readToOneCQN[CLEANUP_KEYS]
|
|
38
|
-
return readToOneCQNCopy
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const entity_keys = entity =>
|
|
42
|
-
Object_keys(entity.keys).filter(key => key !== 'IsActiveEntity' && !entity.keys[key].isAssociation)
|
|
43
|
-
|
|
44
|
-
class JoinCQNFromExpanded {
|
|
45
|
-
constructor(cqn, csn, locale) {
|
|
46
|
-
this._SELECT = {}
|
|
47
|
-
for (const prop in cqn.SELECT) this._SELECT[prop] = cqn.SELECT[prop]
|
|
48
|
-
this._csn = csn
|
|
49
|
-
// REVISIT: locale is only passed in case of sqlite -> bad coding
|
|
50
|
-
if (cds.env.i18n.for_sqlite.includes(locale)) {
|
|
51
|
-
this._locale = locale
|
|
52
|
-
}
|
|
53
|
-
this.queries = []
|
|
54
|
-
this.mappings = {}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Build one to N queries and construct the post processing configs.
|
|
59
|
-
* Each expand with a to many target will result in an extra query and config.
|
|
60
|
-
*
|
|
61
|
-
* @returns {this}
|
|
62
|
-
*/
|
|
63
|
-
buildJoinQueries() {
|
|
64
|
-
// side effect: this_aliases is set
|
|
65
|
-
const aliases = this._getTableAlias(this._SELECT, [])
|
|
66
|
-
|
|
67
|
-
// Update elements at WHERE, so there are no issues with ambiguity
|
|
68
|
-
this._adaptWhereOrderBy(this._SELECT, aliases)
|
|
69
|
-
|
|
70
|
-
// Get first level of expanding regarding to many and all to one if not part of a nested to many expand.
|
|
71
|
-
this._createJoinCQNFromExpanded(this._SELECT, [])
|
|
72
|
-
return this
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
_getUnionTable(SELECT) {
|
|
76
|
-
if (!SELECT.from.SET) return
|
|
77
|
-
// Ensure the draft table is picked, no matter, which position
|
|
78
|
-
for (const arg of SELECT.from.SET.args) {
|
|
79
|
-
const ref = this._getRef(arg.SELECT)
|
|
80
|
-
// Do not handle non draft cases, as it will be unclear, which entity to pick from
|
|
81
|
-
if (ref.table.endsWith('_drafts')) {
|
|
82
|
-
return ref
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
_isDraftTargetActive(table) {
|
|
88
|
-
return Boolean(this._csn.definitions[table])
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
_isDraftTree(table) {
|
|
92
|
-
// TODO: this is a workaround until the service is flagged as draft enabled by cds-services
|
|
93
|
-
if (!this._isDraft) {
|
|
94
|
-
const entity =
|
|
95
|
-
this._csn.definitions[ensureUnlocalized(table)] || this._csn.definitions[table.replace(/_drafts$/i, '')]
|
|
96
|
-
this._isDraft = entity._isDraftEnabled
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return this._isDraft
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// There can be a limit/offset for the target entity.
|
|
103
|
-
// The current expand implementation applys a `DISTINCT` on
|
|
104
|
-
// `filterExpand`, which changes the sorting in absence of `ORDER BY`.
|
|
105
|
-
// Therefore, add an implicit `ORDER BY` in those cases.
|
|
106
|
-
_addImplicitOrderBy(cqn, entity, alias) {
|
|
107
|
-
if (cqn.orderBy || !cqn.limit || !entity) return // not needed
|
|
108
|
-
const orderByColumns = cqn.groupBy || getAllKeys(entity).map(key => ({ ref: [alias, key] }))
|
|
109
|
-
cqn.orderBy = orderByColumns
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Build first level of expanding regarding to many and all to one if not part of a nested to many expand.
|
|
114
|
-
*
|
|
115
|
-
* @param {object} SELECT - SELECT part of a CQN.
|
|
116
|
-
* @param {Array} toManyTree - Holds information how deeply nested the expand is and where the result is added in the tree.
|
|
117
|
-
* @param {boolean} defaultLanguage - Use default language for localized fields
|
|
118
|
-
* @private
|
|
119
|
-
*/
|
|
120
|
-
_createJoinCQNFromExpanded(SELECT, toManyTree, defaultLanguage) {
|
|
121
|
-
const joinArgs = SELECT.from.args
|
|
122
|
-
const isJoinOfTwoSelects = joinArgs?.every(a => a.SELECT)
|
|
123
|
-
const unionTableRef = this._getUnionTable(SELECT)
|
|
124
|
-
const unionTable = unionTableRef?.table
|
|
125
|
-
const tableAlias = this._getTableAlias(SELECT, toManyTree)
|
|
126
|
-
const readToOneCQN = this._getReadToOneCQN(SELECT, isJoinOfTwoSelects ? 'filterExpand' : tableAlias)
|
|
127
|
-
|
|
128
|
-
if (isJoinOfTwoSelects) {
|
|
129
|
-
// mappings
|
|
130
|
-
const mappings = this._getMappingObject(toManyTree)
|
|
131
|
-
const prefix = `${tableAlias}_`
|
|
132
|
-
SELECT.columns
|
|
133
|
-
.filter(c => c.as && c.as.startsWith(prefix) && c[SKIP_MAPPING] !== true)
|
|
134
|
-
.forEach(c => {
|
|
135
|
-
mappings[c.as.replace(prefix, '')] = c.as
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
// expand to one
|
|
139
|
-
const entity = this._csn.definitions[joinArgs[0].SELECT.from.SET.args[1].SELECT.from.ref[0]]
|
|
140
|
-
this._addImplicitOrderBy(readToOneCQN, entity, tableAlias)
|
|
141
|
-
const givenColumns = readToOneCQN.columns
|
|
142
|
-
readToOneCQN.columns = []
|
|
143
|
-
if (entity['@cds.localized'] === false) defaultLanguage = true
|
|
144
|
-
this._expandedToFlat({ entity, givenColumns, readToOneCQN, tableAlias, toManyTree, defaultLanguage })
|
|
145
|
-
} else {
|
|
146
|
-
const table = unionTable || this._getRef(SELECT).table
|
|
147
|
-
const isDraftTree = this._isDraftTree(table)
|
|
148
|
-
const entity = this._getEntityForTable(table)
|
|
149
|
-
this._addImplicitOrderBy(readToOneCQN, entity, tableAlias)
|
|
150
|
-
if (unionTable) readToOneCQN[IS_UNION_DRAFT] = true
|
|
151
|
-
readToOneCQN[IS_ACTIVE] = isDraftTree ? this._isDraftTargetActive(table) : true
|
|
152
|
-
const givenColumns = readToOneCQN.columns
|
|
153
|
-
readToOneCQN.columns = []
|
|
154
|
-
if (entity['@cds.localized'] === false) defaultLanguage = true
|
|
155
|
-
this._expandedToFlat({ entity, givenColumns, readToOneCQN, tableAlias, toManyTree, defaultLanguage })
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// brute force hack
|
|
159
|
-
readToOneCQN.columns = readToOneCQN.columns.filter(c => c.as !== 'filterExpand_IsActiveEntity')
|
|
160
|
-
|
|
161
|
-
// Add at start, so that the deepest level is post processed first
|
|
162
|
-
this.queries.push({
|
|
163
|
-
SELECT: readToOneCQN,
|
|
164
|
-
_toManyTree: toManyTree
|
|
165
|
-
})
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Self referencing associations, two expanded entities based on same table, ...
|
|
170
|
-
* Requires an abstract name to prevent ambiguity issues.
|
|
171
|
-
* Use hash to prevent names longer than support by DB.
|
|
172
|
-
*
|
|
173
|
-
* @param SELECT
|
|
174
|
-
* @param toManyTree
|
|
175
|
-
* @param unionTable
|
|
176
|
-
* @returns {string}
|
|
177
|
-
* @private
|
|
178
|
-
*/
|
|
179
|
-
_getTableAlias(SELECT, toManyTree) {
|
|
180
|
-
const ref = this._getRef(SELECT)
|
|
181
|
-
return this._createAlias(toManyTree.length === 0 ? ref.table : toManyTree.join(':'), ref.as)
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
_getRef(SELECT) {
|
|
185
|
-
const unionTableRef = this._getUnionTable(SELECT)
|
|
186
|
-
if (unionTableRef) return unionTableRef
|
|
187
|
-
|
|
188
|
-
const table = Object.prototype.hasOwnProperty.call(SELECT.from, 'join')
|
|
189
|
-
? this._getRefFromJoin(SELECT.from.args)
|
|
190
|
-
: SELECT.from
|
|
191
|
-
|
|
192
|
-
return {
|
|
193
|
-
table: table.SELECT ? this._getRef(table.SELECT).table : table.ref[0],
|
|
194
|
-
as: table.as
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
_getRefFromJoin(args) {
|
|
199
|
-
if (args[0].join) {
|
|
200
|
-
return this._getRefFromJoin(args[0].args)
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (args[0].ref) {
|
|
204
|
-
return args[0]
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Order is reversed
|
|
208
|
-
return args[args.length - 1]
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Create an alias from value.
|
|
213
|
-
*
|
|
214
|
-
* @param {string} value
|
|
215
|
-
* @param {string} [alias]
|
|
216
|
-
* @returns {string}
|
|
217
|
-
* @private
|
|
218
|
-
*/
|
|
219
|
-
_createAlias(value, alias) {
|
|
220
|
-
if (!this._aliases) {
|
|
221
|
-
this._aliases = {}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (!this._aliases[value]) {
|
|
225
|
-
if (alias) {
|
|
226
|
-
this._aliases[value] = alias
|
|
227
|
-
return alias
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
const aliasNum = Object.keys(this._aliases).length
|
|
231
|
-
|
|
232
|
-
if (aliasNum < 26) {
|
|
233
|
-
this._aliases[value] = String.fromCharCode(aliasNum + 97)
|
|
234
|
-
} else {
|
|
235
|
-
this._aliases[value] = `alias${aliasNum + 1}`
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return this._aliases[value]
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
_getEntityForTable(table) {
|
|
243
|
-
if (table === 'DraftAdministrativeData') {
|
|
244
|
-
table = `DRAFT.${table}`
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (this._isDraft) {
|
|
248
|
-
return this._csn.definitions[table] || this._csn.definitions[table.replace(/_drafts/i, '')]
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return this._csn.definitions[table]
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Get base CQN, with the same filters as origin.
|
|
256
|
-
*
|
|
257
|
-
* @param {object} SELECT
|
|
258
|
-
* @param {string} tableAlias
|
|
259
|
-
* @returns {object}
|
|
260
|
-
* @private
|
|
261
|
-
*/
|
|
262
|
-
_getReadToOneCQN(SELECT, tableAlias) {
|
|
263
|
-
const cqn = Object.assign({}, SELECT, { from: Object.assign({}, SELECT.from) })
|
|
264
|
-
|
|
265
|
-
if (Object.prototype.hasOwnProperty.call(cqn.from, 'join')) {
|
|
266
|
-
this._adaptJoin(tableAlias, cqn, cqn.from)
|
|
267
|
-
} else {
|
|
268
|
-
if (cqn.from.SET) {
|
|
269
|
-
cqn.from.SET = Object.assign({}, cqn.from.SET, { args: this._adaptUnionArgs(cqn.from.SET.args) })
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
cqn.from.as = tableAlias
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
return cqn
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
_adaptTableNameInColumn(column, originalIdentifier, tableAlias) {
|
|
279
|
-
return column.ref && column.ref[0] === originalIdentifier
|
|
280
|
-
? Object.assign({}, column, { ref: [tableAlias, column.ref[1]] })
|
|
281
|
-
: column
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
_adaptJoin(tableAlias, cqn, from, mapping = {}) {
|
|
285
|
-
from.args = from.args.slice(0)
|
|
286
|
-
if (Object.prototype.hasOwnProperty.call(from.args[0], 'join')) {
|
|
287
|
-
this._adaptJoin(tableAlias, cqn, from.args[0], mapping)
|
|
288
|
-
if (from.on) {
|
|
289
|
-
// we come here for SiblingEntity with expand
|
|
290
|
-
for (const originalIdentifier in mapping) {
|
|
291
|
-
from.on = from.on.map(column =>
|
|
292
|
-
this._adaptTableNameInColumn(column, originalIdentifier, mapping[originalIdentifier])
|
|
293
|
-
)
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
} else {
|
|
297
|
-
const index = from.args[0].ref ? 0 : from.args.length - 1
|
|
298
|
-
const target = Object.assign({}, from.args[index], { as: tableAlias })
|
|
299
|
-
const originalIdentifier = from.args[index].as || from.args[index].ref[0]
|
|
300
|
-
|
|
301
|
-
from.args[index] = target
|
|
302
|
-
from.on = from.on.map(column => this._adaptTableNameInColumn(column, originalIdentifier, tableAlias))
|
|
303
|
-
cqn.columns = cqn.columns.map(column => this._adaptTableNameInColumn(column, originalIdentifier, tableAlias))
|
|
304
|
-
mapping[originalIdentifier] = tableAlias
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
_adaptUnionArgs(args) {
|
|
309
|
-
return args.map(arg => {
|
|
310
|
-
if (arg.SELECT.columns) {
|
|
311
|
-
// remove the expands from the sub selects, as they are joined against the unioned result
|
|
312
|
-
arg = Object.assign({}, arg, { SELECT: Object.assign({}, arg.SELECT) })
|
|
313
|
-
arg.SELECT.columns = arg.SELECT.columns.filter(element => {
|
|
314
|
-
return !element.expand || typeof element.expand === 'function'
|
|
315
|
-
})
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
return arg
|
|
319
|
-
})
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
_adaptWhereElement(element, cqn, tableAlias) {
|
|
323
|
-
if (element.list) {
|
|
324
|
-
return Object.assign(element, {
|
|
325
|
-
list: element.list.map(element => this._checkOrderByWhereElementRecursive(cqn, element, tableAlias))
|
|
326
|
-
})
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
return this._checkOrderByWhereElementRecursive(cqn, element, tableAlias)
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Ensure that columns are accessed in combination with table alias.
|
|
334
|
-
* Prevents ambiguity issues.
|
|
335
|
-
*
|
|
336
|
-
* @param {object} cqn
|
|
337
|
-
* @param {string} tableAlias
|
|
338
|
-
* @returns {object}
|
|
339
|
-
* @private
|
|
340
|
-
*/
|
|
341
|
-
_adaptWhereOrderBy(cqn, tableAlias) {
|
|
342
|
-
if (cqn.where) {
|
|
343
|
-
cqn.where = cqn.where.map(element => this._adaptWhereElement(element, cqn, tableAlias))
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
if (cqn.having) {
|
|
347
|
-
cqn.having = cqn.having.map(element => this._adaptWhereElement(element, cqn, tableAlias))
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
if (cqn.orderBy) {
|
|
351
|
-
cqn.orderBy = cqn.orderBy.map(element => this._checkOrderByWhereElementRecursive(cqn, element, tableAlias))
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
if (cqn.groupBy) {
|
|
355
|
-
cqn.groupBy = cqn.groupBy.map(element => this._checkOrderByWhereElementRecursive(cqn, element, tableAlias))
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
return cqn
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
_addAlias(whereElement) {
|
|
362
|
-
whereElement.ref && whereElement.ref.splice(0, 1, Object.values(this._aliases)[0])
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
_navigationNeedsAlias(element, { table } = {}) {
|
|
366
|
-
const entity = this._csn.definitions[table]
|
|
367
|
-
if (entity) {
|
|
368
|
-
const e = this._csn.definitions[table].elements[element.ref[0]]
|
|
369
|
-
return e && e.isAssociation
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
return false
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
_checkOrderByWhereElementRecursive(cqn, element, tableAlias) {
|
|
376
|
-
if (element.func) {
|
|
377
|
-
element = Object.assign({}, element)
|
|
378
|
-
this._functionNeedsReplacement(cqn, tableAlias, element)
|
|
379
|
-
} else if (element.ref) {
|
|
380
|
-
element = Object.assign({}, element)
|
|
381
|
-
element.ref = element.ref.slice(0)
|
|
382
|
-
|
|
383
|
-
if (element.ref.length === 1) {
|
|
384
|
-
element.ref.unshift(tableAlias)
|
|
385
|
-
} else if (this._elementAliasNeedsReplacement(element, this._getRef(cqn))) {
|
|
386
|
-
element.ref[0] = tableAlias
|
|
387
|
-
} else if (this._navigationNeedsAlias(element, this._getRef(cqn))) {
|
|
388
|
-
element.ref.unshift(tableAlias)
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
this._functionNeedsReplacement(cqn, tableAlias, element)
|
|
392
|
-
} else if (element.xpr) {
|
|
393
|
-
element = Object.assign({}, element)
|
|
394
|
-
element.xpr = element.xpr.map(nestedElement => {
|
|
395
|
-
return this._checkOrderByWhereElementRecursive(cqn, nestedElement, tableAlias)
|
|
396
|
-
})
|
|
397
|
-
} else if (element.SELECT?.where) {
|
|
398
|
-
element = {
|
|
399
|
-
SELECT: Object.assign({}, element.SELECT, {
|
|
400
|
-
where: this._adaptWhereSELECT(this._getRef(cqn), element.SELECT.where, tableAlias)
|
|
401
|
-
})
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
return element
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* @param aliasedTable
|
|
410
|
-
* @param {Array} where
|
|
411
|
-
* @param tableAlias
|
|
412
|
-
* @private
|
|
413
|
-
* @returns {Array}
|
|
414
|
-
*/
|
|
415
|
-
_adaptWhereSELECT(aliasedTable, where, tableAlias) {
|
|
416
|
-
return where.map(element => {
|
|
417
|
-
if (element.xpr) {
|
|
418
|
-
return { xpr: this._adaptWhereSELECT(aliasedTable, element.xpr, tableAlias) }
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
return this._elementAliasNeedsReplacement(element, aliasedTable)
|
|
422
|
-
? Object.assign({}, element, { ref: [tableAlias, element.ref[1]] })
|
|
423
|
-
: element
|
|
424
|
-
})
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
_elementAliasNeedsReplacement(element, { table, as }) {
|
|
428
|
-
// ref contains a single column, no replacement needed
|
|
429
|
-
if (!element.ref || element.ref.length < 2) {
|
|
430
|
-
return false
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
switch (element.ref[0]) {
|
|
434
|
-
case table:
|
|
435
|
-
case as:
|
|
436
|
-
return true
|
|
437
|
-
default:
|
|
438
|
-
return false
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
_isValidFunc(element) {
|
|
443
|
-
if (typeof element.func === 'string' && Array.isArray(element.args)) {
|
|
444
|
-
return true
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
if (
|
|
448
|
-
typeof element.ref[0] === 'string' &&
|
|
449
|
-
typeof element.ref[1] === 'object' &&
|
|
450
|
-
Array.isArray(element.ref[1].args)
|
|
451
|
-
) {
|
|
452
|
-
return true
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
_mapArg(arg, cqn, tableAlias) {
|
|
457
|
-
if (Array.isArray(arg.list)) {
|
|
458
|
-
arg = Object.assign({}, arg)
|
|
459
|
-
arg.list = arg.list.map(item => {
|
|
460
|
-
return this._checkOrderByWhereElementRecursive(cqn, item, tableAlias)
|
|
461
|
-
})
|
|
462
|
-
|
|
463
|
-
return arg
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
return this._checkOrderByWhereElementRecursive(cqn, arg, tableAlias)
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
_functionNeedsReplacement(cqn, tableAlias, element) {
|
|
470
|
-
if (!this._isValidFunc(element)) {
|
|
471
|
-
return
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
if (element.ref) {
|
|
475
|
-
element.ref[1] = Object.assign({}, element.ref[1])
|
|
476
|
-
element.ref[1].args = element.ref[1].args.map(arg => this._mapArg(arg, cqn, tableAlias))
|
|
477
|
-
} else {
|
|
478
|
-
element.args = element.args.slice(0)
|
|
479
|
-
element.args = element.args.map(arg => this._mapArg(arg, cqn, tableAlias))
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
_skip(targetEntity) {
|
|
484
|
-
return targetEntity && targetEntity._hasPersistenceSkip
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* Build CQN(s) with JOINs for expanding. In case of expanding with to many an additional CQN will be pushed to toManyCQN.
|
|
489
|
-
*
|
|
490
|
-
* @param {object} arg - Avoiding many arguments and issues that come with it by using an object.
|
|
491
|
-
* @param {object} arg.entity - Entity that is taken from CSN.
|
|
492
|
-
* @param {Array} arg.givenColumns - List of read columns taken from CQN.
|
|
493
|
-
* @param {object} arg.readToOneCQN - Build CQN the JOIN(s) should be added to or it will be used to filter an expanded to many entity.
|
|
494
|
-
* @param {string} arg.tableAlias - Table alias
|
|
495
|
-
* @param {Array} arg.toManyTree - Information, where the expand array is located in the result array.
|
|
496
|
-
* @param {boolean} arg.defaultLanguage - Use default language for localized fields
|
|
497
|
-
* @private
|
|
498
|
-
*/
|
|
499
|
-
_expandedToFlat({ entity, givenColumns, readToOneCQN, tableAlias, toManyTree, defaultLanguage }) {
|
|
500
|
-
const toManyColumns = []
|
|
501
|
-
const mappings = this._getMappingObject(toManyTree)
|
|
502
|
-
const readToOneCQNCopy = getCqnCopy(readToOneCQN)
|
|
503
|
-
|
|
504
|
-
for (const column of givenColumns) {
|
|
505
|
-
let navigation
|
|
506
|
-
|
|
507
|
-
if (column.expand) {
|
|
508
|
-
navigation = getNavigationIfStruct(entity, tableAlias === column.ref[0] ? column.ref.slice(1) : column.ref)
|
|
509
|
-
if (this._skip(navigation && navigation._target)) continue
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
if (this._isExpandToMany(column, entity, navigation)) {
|
|
513
|
-
// To many can only be build, once all other columns have been processed.
|
|
514
|
-
const trgt = column.ref[column.ref.length - 1]
|
|
515
|
-
mappings[trgt] = { [TO_MANY]: true }
|
|
516
|
-
if (entity._isDraftEnabled && entity.elements[trgt]._isAssociationStrict) mappings[trgt][TO_ACTIVE] = true
|
|
517
|
-
toManyColumns.push({ parentAlias: tableAlias, column: column })
|
|
518
|
-
} else if (typeof column.expand === 'object') {
|
|
519
|
-
// Expands with to one target can be processed directly
|
|
520
|
-
const navProp = column.ref[column.ref.length - 1]
|
|
521
|
-
const navTarget = entity.elements[navProp]
|
|
522
|
-
|
|
523
|
-
if (
|
|
524
|
-
entity._isDraftEnabled &&
|
|
525
|
-
navTarget._isAssociationStrict &&
|
|
526
|
-
!navTarget['@odata.draft.enclosed'] &&
|
|
527
|
-
navTarget.name !== 'DraftAdministrativeData' &&
|
|
528
|
-
!entity.elements[navProp]._isCompositionBacklink
|
|
529
|
-
) {
|
|
530
|
-
mappings[navProp] = { [TO_ACTIVE]: true }
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
this._addJoinAndElements({
|
|
534
|
-
column,
|
|
535
|
-
entity,
|
|
536
|
-
readToOneCQN,
|
|
537
|
-
toManyTree,
|
|
538
|
-
parentAlias: tableAlias,
|
|
539
|
-
defaultLanguage
|
|
540
|
-
})
|
|
541
|
-
} else {
|
|
542
|
-
// No expand, directly add the column and its mapping.
|
|
543
|
-
const columnAliased = this._addAliasToColumn(column, entity, tableAlias, mappings)
|
|
544
|
-
readToOneCQN.columns.push(columnAliased)
|
|
545
|
-
|
|
546
|
-
// REVISIT required for other cqn properties as well?
|
|
547
|
-
this.adjustOrderBy(readToOneCQN.orderBy, mappings, column, tableAlias)
|
|
548
|
-
|
|
549
|
-
// In case active parent entity has orderBy with draft specific columns we need to add them to parent CQN
|
|
550
|
-
if (
|
|
551
|
-
readToOneCQN[IS_ACTIVE] &&
|
|
552
|
-
readToOneCQN.orderBy &&
|
|
553
|
-
column.as &&
|
|
554
|
-
(column.as === 'IsActiveEntity' || column.as === 'HasActiveEntity' || column.as === 'HasDraftEntity')
|
|
555
|
-
) {
|
|
556
|
-
readToOneCQNCopy.orderBy = readToOneCQN.orderBy
|
|
557
|
-
this._addColumnsInCaseOrderByHasDraft(readToOneCQNCopy, readToOneCQN.columns[readToOneCQN.columns.length - 1])
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
// only as second step handle expand to many, or else keys might still be unknown
|
|
563
|
-
this._toMany({
|
|
564
|
-
entity,
|
|
565
|
-
readToOneCQN,
|
|
566
|
-
tableAlias,
|
|
567
|
-
toManyColumns,
|
|
568
|
-
toManyTree,
|
|
569
|
-
mappings,
|
|
570
|
-
defaultLanguage,
|
|
571
|
-
readToOneCQNCopy
|
|
572
|
-
})
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
adjustOrderBy(orderBy, mappings, column, tableAlias) {
|
|
576
|
-
const colName = column.as || (column.ref && column.ref[column.ref.length - 1])
|
|
577
|
-
if (orderBy && mappings[colName]) {
|
|
578
|
-
orderBy.forEach(order => {
|
|
579
|
-
if (order.args) {
|
|
580
|
-
this.adjustOrderBy(order.args, mappings, column, tableAlias)
|
|
581
|
-
} else {
|
|
582
|
-
if (order.ref[0] === tableAlias && order.ref[1] === colName) {
|
|
583
|
-
order.as = mappings[colName]
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
})
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
_addColumnsInCaseOrderByHasDraft(readToOneCQNCopy, column) {
|
|
591
|
-
readToOneCQNCopy.orderBy.forEach(order => {
|
|
592
|
-
if (order.as === column.as) {
|
|
593
|
-
readToOneCQNCopy.columns.push(column)
|
|
594
|
-
}
|
|
595
|
-
})
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
/**
|
|
599
|
-
* Follow the tree to get to the relevant config object.
|
|
600
|
-
*
|
|
601
|
-
* @param {Array} toManyTree
|
|
602
|
-
* @returns {object}
|
|
603
|
-
* @private
|
|
604
|
-
*/
|
|
605
|
-
_getMappingObject(toManyTree) {
|
|
606
|
-
let mappings = this.mappings
|
|
607
|
-
for (const element of toManyTree) {
|
|
608
|
-
if (!mappings[element]) mappings[element] = {}
|
|
609
|
-
mappings = mappings[element]
|
|
610
|
-
}
|
|
611
|
-
return mappings
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
_addJoinCompToOne(cqn, entity, tableAlias) {
|
|
615
|
-
const draftTable = ensureDraftsSuffix(entity.target)
|
|
616
|
-
const on = []
|
|
617
|
-
for (const key in entity._target.keys) {
|
|
618
|
-
if (key !== 'IsActiveEntity') {
|
|
619
|
-
if (on.length) on.push('AND')
|
|
620
|
-
on.push({ ref: [`${tableAlias}_drafts`, key] }, '=', { ref: [tableAlias, key] })
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
return {
|
|
625
|
-
args: [cqn, { ref: [draftTable], as: `${tableAlias}_drafts` }],
|
|
626
|
-
join: 'left',
|
|
627
|
-
on: [{ xpr: [...on] }]
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
_isExpandToMany(column, entity, navigation) {
|
|
632
|
-
return typeof column.expand === 'function' ||
|
|
633
|
-
(column.expand && column.ref[column.ref.length - 1] === 'DraftAdministrativeData')
|
|
634
|
-
? false
|
|
635
|
-
: navigation && navigation.is2many
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
_isNavigationToOne(activeTable, target) {
|
|
639
|
-
return target && ((activeTable && target.isComposition) || target._isAssociationStrict) && target.is2one
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
_getTarget(entity, column, parentAlias) {
|
|
643
|
-
const navigation = getNavigationIfStruct(entity, column.ref[0] === parentAlias ? column.ref.slice(1) : column.ref)
|
|
644
|
-
return (navigation && navigation.target) || column.ref[0]
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
/**
|
|
648
|
-
* Adds JOIN instructions to CQN for expands with 1:1 target and returns config how to map it back.
|
|
649
|
-
*
|
|
650
|
-
* @param {object} args
|
|
651
|
-
* @param args.column
|
|
652
|
-
* @param args.entity
|
|
653
|
-
* @param args.readToOneCQN
|
|
654
|
-
* @param args.toManyTree
|
|
655
|
-
* @param args.parentAlias
|
|
656
|
-
* @param args.defaultLanguage
|
|
657
|
-
* @private
|
|
658
|
-
*/
|
|
659
|
-
_addJoinAndElements({ column, entity, readToOneCQN, toManyTree, parentAlias, defaultLanguage }) {
|
|
660
|
-
const extendedToManyTree = toManyTree.concat(column.ref[0] === parentAlias ? column.ref.slice(1) : column.ref)
|
|
661
|
-
const tableAlias = this._createAlias(extendedToManyTree.join(':'))
|
|
662
|
-
const target = this._getTarget(entity, column, parentAlias)
|
|
663
|
-
const name = column.ref[column.ref.length - 1]
|
|
664
|
-
const element = name && entity.elements[name]
|
|
665
|
-
|
|
666
|
-
// if union always only expand with active, otherwise evaluate flag
|
|
667
|
-
// if flag shows false, we check entity for associations to non draft
|
|
668
|
-
const activeTableRequired =
|
|
669
|
-
readToOneCQN[IS_UNION_DRAFT] || // > REVISIT: blocks expanding comp2one
|
|
670
|
-
readToOneCQN[IS_ACTIVE] ||
|
|
671
|
-
(element &&
|
|
672
|
-
element._isAssociationStrict &&
|
|
673
|
-
!element['@odata.draft.enclosed'] &&
|
|
674
|
-
!element._isCompositionBacklink) ||
|
|
675
|
-
!this._csn.definitions[target]._isDraftEnabled
|
|
676
|
-
|
|
677
|
-
const colTarget = target && ensureUnlocalized(target)
|
|
678
|
-
const defaultLanguageThis =
|
|
679
|
-
defaultLanguage ||
|
|
680
|
-
entity['@cds.localized'] === false ||
|
|
681
|
-
(colTarget && this._csn.definitions[colTarget] && this._csn.definitions[colTarget]['@cds.localized'] === false)
|
|
682
|
-
|
|
683
|
-
const join =
|
|
684
|
-
column.ref[0] === 'DraftAdministrativeData' || !(element && element.notNull) || this._isDraft ? 'left' : 'inner'
|
|
685
|
-
|
|
686
|
-
const args = [
|
|
687
|
-
readToOneCQN.from.SET ? this._unionToSubQuery(readToOneCQN) : readToOneCQN.from,
|
|
688
|
-
{
|
|
689
|
-
ref: [this._refFromRefByExpand(column.ref[0], colTarget, defaultLanguageThis, activeTableRequired)],
|
|
690
|
-
as: tableAlias
|
|
691
|
-
}
|
|
692
|
-
]
|
|
693
|
-
|
|
694
|
-
readToOneCQN.from = {
|
|
695
|
-
join,
|
|
696
|
-
args,
|
|
697
|
-
on: null
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
const expandedEntity = this._getEntityForTable(target)
|
|
701
|
-
if (readToOneCQN[IS_UNION_DRAFT] && expandedEntity.drafts) {
|
|
702
|
-
const cols = column.expand.filter(c => c.ref && !c.expand && !(c.ref[0] in DRAFT_COLUMNS_MAP)).map(c => c.ref[0])
|
|
703
|
-
const ks = Object.keys(expandedEntity.keys).filter(
|
|
704
|
-
c => !expandedEntity.keys[c].isAssociation && !(c in DRAFT_COLUMNS_MAP)
|
|
705
|
-
)
|
|
706
|
-
const user = cds.context?.user.id
|
|
707
|
-
|
|
708
|
-
const assoc = entity.associations[column.ref[0]]
|
|
709
|
-
if (assoc.is2one && assoc.on) {
|
|
710
|
-
const onCond = entity._relations[assoc.name].join('target', 'source')
|
|
711
|
-
const xpr = onCond[0].xpr
|
|
712
|
-
const fks = (xpr && xpr.filter(e => e.ref && e.ref[0] === 'target').map(e => e.ref[1])) || []
|
|
713
|
-
for (const k of fks) {
|
|
714
|
-
if (!cols.includes(k)) cols.push(k)
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
const unionFrom = getCQNUnionFrom(cols, expandedEntity.name, expandedEntity.name + '.drafts', ks, user)
|
|
719
|
-
readToOneCQN.from.args[1] = {
|
|
720
|
-
SELECT: {
|
|
721
|
-
columns: cols,
|
|
722
|
-
from: unionFrom
|
|
723
|
-
},
|
|
724
|
-
as: tableAlias
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
// note: set the on condition after the join kind and args are set
|
|
729
|
-
readToOneCQN.from.on = this._getOnCond(entity, column.ref, tableAlias, parentAlias, readToOneCQN)
|
|
730
|
-
|
|
731
|
-
if (column.ref[0] !== 'DraftAdministrativeData') {
|
|
732
|
-
this._addJoinKeyColumnsToUnion(readToOneCQN.from.args, readToOneCQN.from.on, parentAlias)
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
// special case of navigation to one requires additional LEFT JOIN and CASE for HasDraftEntity
|
|
736
|
-
const compToOne = this._isNavigationToOne(readToOneCQN[IS_ACTIVE], element)
|
|
737
|
-
const index = column.expand.findIndex(col => col.ref && col.ref[col.ref.length - 1] === 'HasDraftEntity')
|
|
738
|
-
|
|
739
|
-
if (compToOne && index !== -1) {
|
|
740
|
-
readToOneCQN.from = this._addJoinCompToOne(readToOneCQN.from, element, tableAlias)
|
|
741
|
-
if (activeTableRequired) {
|
|
742
|
-
column.expand[index] = {
|
|
743
|
-
xpr: [
|
|
744
|
-
'case',
|
|
745
|
-
'when',
|
|
746
|
-
`${tableAlias}_drafts.DraftAdministrativeData_DraftUUID`,
|
|
747
|
-
'IS NOT NULL',
|
|
748
|
-
'then',
|
|
749
|
-
'true',
|
|
750
|
-
'else',
|
|
751
|
-
'false',
|
|
752
|
-
'end'
|
|
753
|
-
],
|
|
754
|
-
as: 'HasDraftEntity',
|
|
755
|
-
cast: { type: 'cds.Boolean' }
|
|
756
|
-
}
|
|
757
|
-
} else {
|
|
758
|
-
column.expand[index] = {
|
|
759
|
-
val: false,
|
|
760
|
-
as: 'HasDraftEntity',
|
|
761
|
-
cast: { type: 'cds.Boolean' }
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
const givenColumns = column.expand.map(col => {
|
|
767
|
-
if (
|
|
768
|
-
activeTableRequired &&
|
|
769
|
-
col.ref?.length &&
|
|
770
|
-
(col.ref[0] === 'IsActiveEntity' || col.ref[0] === 'HasActiveEntity')
|
|
771
|
-
) {
|
|
772
|
-
return {
|
|
773
|
-
val: col.ref[0] === 'IsActiveEntity',
|
|
774
|
-
as: col.ref[0],
|
|
775
|
-
cast: { type: 'cds.Boolean' }
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
return col
|
|
779
|
-
})
|
|
780
|
-
|
|
781
|
-
const targetEntity = this._getEntityForTable(target)
|
|
782
|
-
|
|
783
|
-
// ignore structured keys for now
|
|
784
|
-
let targetKeys = entity_keys(targetEntity).filter(key => !targetEntity.keys[key]._isStructured)
|
|
785
|
-
// ignore groupBy for now
|
|
786
|
-
if (targetKeys.length > 0 && !readToOneCQN.groupBy) {
|
|
787
|
-
const notOnlyExpandInColumns = !givenColumns.some(col => col.expand)
|
|
788
|
-
if (notOnlyExpandInColumns) {
|
|
789
|
-
const missingKeys = targetKeys.filter(keyName => !givenColumns.some(col => keyName === col.ref?.[0]))
|
|
790
|
-
if (missingKeys.length) {
|
|
791
|
-
givenColumns.push(...missingKeys.map(keyName => ({ ref: [keyName] })))
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
if (
|
|
797
|
-
'IsActiveEntity' in targetEntity.elements &&
|
|
798
|
-
this._isNotIncludedIn(givenColumns)('IsActiveEntity') &&
|
|
799
|
-
typeof activeTableRequired === 'boolean'
|
|
800
|
-
) {
|
|
801
|
-
const col = this._createCalculatedBooleanColumn('IsActiveEntity', activeTableRequired)
|
|
802
|
-
col[CLEANUP_KEYS] = true
|
|
803
|
-
givenColumns.push(col)
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
this._expandedToFlat({
|
|
807
|
-
entity: targetEntity,
|
|
808
|
-
givenColumns,
|
|
809
|
-
readToOneCQN,
|
|
810
|
-
tableAlias,
|
|
811
|
-
toManyTree: extendedToManyTree,
|
|
812
|
-
defaultLanguage: defaultLanguageThis
|
|
813
|
-
})
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
_refFromRefByExpand(column, target, defaultLanguage, isActiveRequired = true) {
|
|
817
|
-
if (column === 'DraftAdministrativeData') {
|
|
818
|
-
return 'DRAFT.DraftAdministrativeData'
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
if (this._SELECT.localized !== false && isActiveRequired && !defaultLanguage) {
|
|
822
|
-
const locale = this._locale ? `${this._locale}.` : ''
|
|
823
|
-
const localized = `localized.${locale}${target}`
|
|
824
|
-
if (this._csn.definitions[localized]) {
|
|
825
|
-
target = localized
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
return `${target}${isActiveRequired ? '' : '_drafts'}`
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
_unionToSubQuery(readToOneCQN) {
|
|
833
|
-
return {
|
|
834
|
-
SELECT: {
|
|
835
|
-
columns: Array.from(readToOneCQN.columns),
|
|
836
|
-
from: readToOneCQN.from
|
|
837
|
-
},
|
|
838
|
-
as: readToOneCQN.from.as
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
_getAliases(columns) {
|
|
843
|
-
return columns.reduce((aliases, entry) => {
|
|
844
|
-
if (!entry.ref) {
|
|
845
|
-
return aliases
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
if (!aliases[entry.ref[0]]) {
|
|
849
|
-
aliases[entry.ref[0]] = {}
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
aliases[entry.ref[0]][entry[IDENTIFIER]] = entry.as
|
|
853
|
-
return aliases
|
|
854
|
-
}, {})
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
_getSubSelectColumns(cqn) {
|
|
858
|
-
const args = cqn.args || cqn.from.args
|
|
859
|
-
|
|
860
|
-
if (args) {
|
|
861
|
-
for (const arg of args) {
|
|
862
|
-
if (arg.ref) {
|
|
863
|
-
continue
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
if (arg.SELECT?.columns.some(column => column[IDENTIFIER])) {
|
|
867
|
-
return arg.SELECT.columns
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
return this._getSubSelectColumns(arg.SELECT || arg)
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
if (!cqn.from) return []
|
|
875
|
-
|
|
876
|
-
const columns = cqn.from.SELECT ? cqn.from.SELECT.columns : cqn.columns
|
|
877
|
-
return columns.some(column => column[IDENTIFIER]) ? columns : []
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
_getOnCond(entity, columns, tableAlias, parentAlias, readToOneCQN) {
|
|
881
|
-
if (columns[0] === 'DraftAdministrativeData') {
|
|
882
|
-
if (readToOneCQN[IS_ACTIVE]) {
|
|
883
|
-
const subWhere = []
|
|
884
|
-
|
|
885
|
-
for (const key in entity.keys) {
|
|
886
|
-
if (key === 'IsActiveEntity' || entity.keys[key]._isAssociationStrict) continue
|
|
887
|
-
if (subWhere.length) {
|
|
888
|
-
subWhere.push('and')
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
subWhere.push({ ref: [key] }, '=', { ref: [parentAlias, key] })
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
return [
|
|
895
|
-
{ ref: [tableAlias, 'DraftUUID'] },
|
|
896
|
-
'in',
|
|
897
|
-
{
|
|
898
|
-
SELECT: {
|
|
899
|
-
from: { ref: [ensureDraftsSuffix(entity.name)] },
|
|
900
|
-
columns: [{ ref: ['DraftAdministrativeData_DraftUUID'] }],
|
|
901
|
-
where: subWhere
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
]
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
return [{ ref: [tableAlias, 'DraftUUID'] }, '=', { ref: [parentAlias, 'DraftAdministrativeData_DraftUUID'] }]
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
// No sub select
|
|
911
|
-
const subSelectColumns = this._getSubSelectColumns(readToOneCQN)
|
|
912
|
-
|
|
913
|
-
if (subSelectColumns.length === 0) {
|
|
914
|
-
return entity._relations[
|
|
915
|
-
tableAlias === columns[0] || parentAlias === columns[0] ? columns.slice(1) : columns
|
|
916
|
-
].join(tableAlias, parentAlias)
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
const aliases = this._getAliases(subSelectColumns)
|
|
920
|
-
const on = entity._relations[tableAlias === columns[0] ? columns.slice(1) : columns].join(tableAlias, parentAlias)
|
|
921
|
-
|
|
922
|
-
this._adjustAliases(on, aliases)
|
|
923
|
-
|
|
924
|
-
return on
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
_adjustAliases(on, aliases) {
|
|
928
|
-
for (const element of on) {
|
|
929
|
-
if (element.xpr) {
|
|
930
|
-
this._adjustAliases(element.xpr, aliases)
|
|
931
|
-
continue
|
|
932
|
-
}
|
|
933
|
-
if (element.ref && aliases[element.ref[0]] && aliases[element.ref[0]][element.ref[1]]) {
|
|
934
|
-
element.ref[1] = aliases[element.ref[0]][element.ref[1]]
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
_addJoinKeyColumnsToUnion(args, on, parentAlias) {
|
|
940
|
-
for (const arg of args) {
|
|
941
|
-
if (arg.ref) {
|
|
942
|
-
continue
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
if (arg.args) {
|
|
946
|
-
this._addJoinKeyColumnsToUnion(arg.args, on, parentAlias)
|
|
947
|
-
} else if (arg.SELECT.from.SET && (arg.as === parentAlias || arg.SELECT.from.as === parentAlias)) {
|
|
948
|
-
for (const _arg of arg.SELECT.from.SET.args) {
|
|
949
|
-
this._addColumns(_arg.SELECT.columns, on, parentAlias)
|
|
950
|
-
}
|
|
951
|
-
if (arg.SELECT.columns) {
|
|
952
|
-
this._addColumns(arg.SELECT.columns, on, parentAlias, true)
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
_addColumns(columns, on, parentAlias, withAlias = false) {
|
|
959
|
-
for (const entry of on) {
|
|
960
|
-
if (entry.xpr) {
|
|
961
|
-
this._addColumns(columns, entry.xpr, parentAlias, withAlias)
|
|
962
|
-
continue
|
|
963
|
-
}
|
|
964
|
-
if (
|
|
965
|
-
entry.ref &&
|
|
966
|
-
entry.ref[0] === parentAlias &&
|
|
967
|
-
!columns.some(column => column.ref && column.ref[column.ref.length - 1] === entry.ref[1])
|
|
968
|
-
) {
|
|
969
|
-
columns.push(
|
|
970
|
-
withAlias
|
|
971
|
-
? { ref: [parentAlias, entry.ref[1]], as: `${parentAlias}_${entry.ref[1]}` }
|
|
972
|
-
: { ref: [entry.ref[1]] }
|
|
973
|
-
)
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
/**
|
|
979
|
-
* Add a unique alias to each column, to avoid ambiguity.
|
|
980
|
-
* Add this information to the post process config.
|
|
981
|
-
*
|
|
982
|
-
* @param {object} column
|
|
983
|
-
* @param entity
|
|
984
|
-
* @param tableAlias
|
|
985
|
-
* @param mappings
|
|
986
|
-
* @returns {object}
|
|
987
|
-
* @private
|
|
988
|
-
*/
|
|
989
|
-
_addAliasToColumn(column, entity, tableAlias, mappings) {
|
|
990
|
-
// No identifier for this row entry or technical column
|
|
991
|
-
if (this._isAliasNotNeeded(column)) return column
|
|
992
|
-
|
|
993
|
-
if (Array.isArray(column.xpr)) {
|
|
994
|
-
return this._buildNewAliasColumn(
|
|
995
|
-
{
|
|
996
|
-
...column,
|
|
997
|
-
xpr: column.xpr.map(x => {
|
|
998
|
-
if (x.ref) {
|
|
999
|
-
const res = this._buildNewAliasColumn(x, entity, tableAlias, mappings, true)
|
|
1000
|
-
delete res.as
|
|
1001
|
-
return res
|
|
1002
|
-
}
|
|
1003
|
-
if (x.func && x.args) {
|
|
1004
|
-
x.args = x.args.map(arg => {
|
|
1005
|
-
if (arg.ref) {
|
|
1006
|
-
const res = this._buildNewAliasColumn(arg, entity, tableAlias, mappings, true)
|
|
1007
|
-
delete res.as
|
|
1008
|
-
return res
|
|
1009
|
-
} else return arg
|
|
1010
|
-
})
|
|
1011
|
-
return x
|
|
1012
|
-
} else return x
|
|
1013
|
-
})
|
|
1014
|
-
},
|
|
1015
|
-
entity,
|
|
1016
|
-
tableAlias,
|
|
1017
|
-
mappings
|
|
1018
|
-
)
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
return this._buildNewAliasColumn(column, entity, tableAlias, mappings)
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
/**
|
|
1025
|
-
* Technical or a value without a casted ensureNoDraftsSuffixname, or some other not yet supported combinations should not be refactored.
|
|
1026
|
-
*
|
|
1027
|
-
* @param {object} column
|
|
1028
|
-
* @returns {boolean}
|
|
1029
|
-
* @private
|
|
1030
|
-
*/
|
|
1031
|
-
_isAliasNotNeeded(column) {
|
|
1032
|
-
// functions, direct values, ...
|
|
1033
|
-
if (!column.ref && !column.as) {
|
|
1034
|
-
return true
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
// No column name specified means false
|
|
1038
|
-
return column.ref && typeof column.ref[column.ref.length - 1] !== 'string'
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
_buildNewAliasColumn(column, entity, tableAlias, mappings, skipMapping = false) {
|
|
1042
|
-
// Casted name, vs column name
|
|
1043
|
-
const identifier = this._getIdentifier(column, tableAlias)
|
|
1044
|
-
const as = column[SKIP_MAPPING] ? column.as : `${tableAlias}_${identifier}`
|
|
1045
|
-
const aliasedElement = Object.assign({}, column)
|
|
1046
|
-
|
|
1047
|
-
aliasedElement.as = as
|
|
1048
|
-
|
|
1049
|
-
// Add table alias or name to handle cases, where joined tables have same column names
|
|
1050
|
-
if (this._isElement(column.ref, entity)) {
|
|
1051
|
-
const alias = tableAlias || ensureNoDraftsSuffix(entity.name)
|
|
1052
|
-
aliasedElement.ref = alias ? [alias, ...column.ref] : [...column.ref]
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
if (skipMapping) return aliasedElement
|
|
1056
|
-
|
|
1057
|
-
if (!column[SKIP_MAPPING]) {
|
|
1058
|
-
mappings[column[IDENTIFIER] || identifier] = as
|
|
1059
|
-
if (column[CLEANUP_KEYS]) {
|
|
1060
|
-
delete aliasedElement[CLEANUP_KEYS]
|
|
1061
|
-
if (!mappings[CLEANUP_KEYS]) mappings[CLEANUP_KEYS] = {}
|
|
1062
|
-
mappings[CLEANUP_KEYS][column[IDENTIFIER] || identifier] = as
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
return aliasedElement
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
_getIdentifier(column, tableAlias) {
|
|
1070
|
-
if (column.as) {
|
|
1071
|
-
return column.as.startsWith(`${tableAlias}_`) && column.ref ? column.ref[column.ref.length - 1] : column.as
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
return column.ref[column.ref.length - 1]
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
_isElement(ref, entity) {
|
|
1078
|
-
if (!ref) return false
|
|
1079
|
-
if (ref.length > 1) {
|
|
1080
|
-
return entity.elements[ref[0]]?.isAssociation
|
|
1081
|
-
}
|
|
1082
|
-
// Normal element
|
|
1083
|
-
if (entity.elements[ref[0]]) return true
|
|
1084
|
-
|
|
1085
|
-
// structured element
|
|
1086
|
-
const splitted = ref[0].split('_')
|
|
1087
|
-
if (splitted.length > 1 && entity.elements[splitted[0]]) return true
|
|
1088
|
-
|
|
1089
|
-
// Draft column
|
|
1090
|
-
return ref[0] in DRAFT_COLUMNS_MAP
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
_toMany({
|
|
1094
|
-
entity,
|
|
1095
|
-
readToOneCQN,
|
|
1096
|
-
tableAlias,
|
|
1097
|
-
toManyColumns,
|
|
1098
|
-
toManyTree,
|
|
1099
|
-
mappings,
|
|
1100
|
-
defaultLanguage,
|
|
1101
|
-
readToOneCQNCopy
|
|
1102
|
-
}) {
|
|
1103
|
-
if (toManyColumns.length === 0) return
|
|
1104
|
-
this._addKeysIfNeeded({ entity, readToOneCQN, tableAlias })
|
|
1105
|
-
|
|
1106
|
-
for (const { column, parentAlias } of toManyColumns) {
|
|
1107
|
-
const select = this._buildExpandedCQN({
|
|
1108
|
-
column,
|
|
1109
|
-
entity,
|
|
1110
|
-
readToOneCQN: readToOneCQNCopy,
|
|
1111
|
-
toManyTree,
|
|
1112
|
-
mappings,
|
|
1113
|
-
parentAlias,
|
|
1114
|
-
defaultLanguage
|
|
1115
|
-
})
|
|
1116
|
-
|
|
1117
|
-
this._createJoinCQNFromExpanded(select, toManyTree.concat([column.ref[column.ref.length - 1]]), defaultLanguage)
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
/**
|
|
1122
|
-
* In case of to many relations, a key is needed for post processing.
|
|
1123
|
-
*
|
|
1124
|
-
* @param {object} args
|
|
1125
|
-
* @param args.entity
|
|
1126
|
-
* @param args.readToOneCQN
|
|
1127
|
-
* @param args.tableAlias
|
|
1128
|
-
* @private
|
|
1129
|
-
*/
|
|
1130
|
-
_addKeysIfNeeded({ entity, readToOneCQN, tableAlias }) {
|
|
1131
|
-
for (const name of this._getMissingKeys({ entity, readToOneCQN, tableAlias })) {
|
|
1132
|
-
if (name === 'IsActiveEntity') {
|
|
1133
|
-
readToOneCQN.columns.push({
|
|
1134
|
-
val: readToOneCQN[IS_ACTIVE],
|
|
1135
|
-
as: 'IsActiveEntity',
|
|
1136
|
-
cast: { type: 'cds.Boolean' },
|
|
1137
|
-
[CLEANUP_KEYS]: true
|
|
1138
|
-
})
|
|
1139
|
-
} else {
|
|
1140
|
-
readToOneCQN.columns.push({
|
|
1141
|
-
as: `${tableAlias}_${name}`,
|
|
1142
|
-
ref: [tableAlias, name],
|
|
1143
|
-
[CLEANUP_KEYS]: true
|
|
1144
|
-
})
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
/**
|
|
1150
|
-
* Compare the list of available keys with keys listed already listed at CQN and return missing.
|
|
1151
|
-
*
|
|
1152
|
-
* @param {object} args
|
|
1153
|
-
* @param args.entity
|
|
1154
|
-
* @param args.readToOneCQN
|
|
1155
|
-
* @param args.tableAlias
|
|
1156
|
-
* @returns {Array}
|
|
1157
|
-
* @private
|
|
1158
|
-
*/
|
|
1159
|
-
_getMissingKeys({ entity, readToOneCQN, tableAlias }) {
|
|
1160
|
-
const keyNames = getAllKeys(entity)
|
|
1161
|
-
|
|
1162
|
-
if (!keyNames) {
|
|
1163
|
-
return []
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
return keyNames.filter(name => {
|
|
1167
|
-
return !readToOneCQN.columns.some(column => column.as === `${tableAlias}_${name}` || column.as === name)
|
|
1168
|
-
})
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
/**
|
|
1172
|
-
* Construct the base CQN for a to many expands.
|
|
1173
|
-
*
|
|
1174
|
-
* @param {object} args
|
|
1175
|
-
* @param args.column
|
|
1176
|
-
* @param args.entity
|
|
1177
|
-
* @param args.readToOneCQN
|
|
1178
|
-
* @param args.toManyTree
|
|
1179
|
-
* @param args.mappings
|
|
1180
|
-
* @param args.parentAlias
|
|
1181
|
-
* @param args.defaultLanguage
|
|
1182
|
-
* @returns {object}
|
|
1183
|
-
* @private
|
|
1184
|
-
*/
|
|
1185
|
-
_buildExpandedCQN({ column, entity, readToOneCQN, toManyTree, mappings, parentAlias, defaultLanguage }) {
|
|
1186
|
-
const isUnion = !!readToOneCQN.from.SET
|
|
1187
|
-
const colRef = parentAlias === column.ref[0] ? column.ref.slice(1) : column.ref.slice(0)
|
|
1188
|
-
const element = entity.elements[colRef[0]]
|
|
1189
|
-
const colTarget = ensureUnlocalized(element.target)
|
|
1190
|
-
const defaultLanguageThis =
|
|
1191
|
-
defaultLanguage ||
|
|
1192
|
-
entity['@cds.localized'] === false ||
|
|
1193
|
-
this._csn.definitions[colTarget]['@cds.localized'] === false
|
|
1194
|
-
const expandActive =
|
|
1195
|
-
readToOneCQN[IS_ACTIVE] ||
|
|
1196
|
-
(element._isAssociationStrict && !element['@odata.draft.enclosed']) ||
|
|
1197
|
-
!this._csn.definitions[colTarget]._isDraftEnabled
|
|
1198
|
-
const ref = this._refFromRefByExpand(column.ref[0], colTarget, defaultLanguageThis, expandActive)
|
|
1199
|
-
const tableAlias = this._createAlias(toManyTree.concat(colRef).join(':'))
|
|
1200
|
-
const on = entity._relations[colRef[0]].join(tableAlias, 'filterExpand')
|
|
1201
|
-
const filterExpand = this._getFilterExpandCQN(readToOneCQN, on, parentAlias, entity.keys)
|
|
1202
|
-
const expandedEntity = this._csn.definitions[colTarget]
|
|
1203
|
-
const joinColumns = this._getJoinColumnsFromOnAddToMapping(mappings[colRef[0]], parentAlias, on, entity)
|
|
1204
|
-
let cqn = {
|
|
1205
|
-
from: {
|
|
1206
|
-
join: 'inner',
|
|
1207
|
-
args: [{ ref: [ref], as: tableAlias }, filterExpand],
|
|
1208
|
-
on
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
if (typeof readToOneCQN[IS_ACTIVE] === 'boolean') {
|
|
1213
|
-
cqn[IS_ACTIVE] = !ref.endsWith('_drafts')
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
cqn.columns = this._getColumnsForExpand({
|
|
1217
|
-
tableAlias,
|
|
1218
|
-
columnList: column,
|
|
1219
|
-
entity: expandedEntity,
|
|
1220
|
-
joinColumns,
|
|
1221
|
-
isActive: cqn[IS_ACTIVE],
|
|
1222
|
-
parentEntity: entity
|
|
1223
|
-
})
|
|
1224
|
-
|
|
1225
|
-
if (column.where) {
|
|
1226
|
-
cqn.where = this._copyWhere(column.where).map(element => this._adaptWhereElement(element, cqn, tableAlias))
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
if (column.orderBy) {
|
|
1230
|
-
cqn.orderBy = this._copyOrderBy(column.orderBy, tableAlias, expandedEntity)
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
if (column.limit) throw getError(501, 'Pagination is not supported in expand')
|
|
1234
|
-
cqn = this._adaptWhereOrderBy(cqn, tableAlias)
|
|
1235
|
-
|
|
1236
|
-
if (isUnion) {
|
|
1237
|
-
const cols = column.expand.filter(c => !c.expand && !(c.ref[0] in DRAFT_COLUMNS_MAP)).map(c => c.ref[0])
|
|
1238
|
-
|
|
1239
|
-
// ensure the join columns are selected
|
|
1240
|
-
for (const each of joinColumns) {
|
|
1241
|
-
const col = each.ref[each.ref.length - 1]
|
|
1242
|
-
if (!cols.includes(col)) cols.push(col)
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
// ensure the foreign keys are selected in case of expand to one
|
|
1246
|
-
for (const each of cqn.columns) {
|
|
1247
|
-
if (each.expand) {
|
|
1248
|
-
const assoc = expandedEntity.associations[each.ref[0]]
|
|
1249
|
-
if (assoc.is2one) {
|
|
1250
|
-
const fks = Object.values(expandedEntity.elements).filter(ele => ele._foreignKey4 === assoc.name)
|
|
1251
|
-
cols.push(...fks.map(fk => fk.name))
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
if (!cqn[IS_ACTIVE]) {
|
|
1257
|
-
const ks = Object.keys(expandedEntity.keys).filter(
|
|
1258
|
-
c => !expandedEntity.keys[c].isAssociation && !(c in DRAFT_COLUMNS_MAP)
|
|
1259
|
-
)
|
|
1260
|
-
const user = cds.context?.user.id
|
|
1261
|
-
const unionFrom = getCQNUnionFrom(cols, ref.replace(/_drafts$/, ''), ref, ks, user)
|
|
1262
|
-
|
|
1263
|
-
for (const each of cqn.columns) {
|
|
1264
|
-
if (!each.as) continue
|
|
1265
|
-
|
|
1266
|
-
// replace val with ref
|
|
1267
|
-
if (each.as === 'IsActiveEntity' || each.as === 'HasActiveEntity') {
|
|
1268
|
-
delete each.val
|
|
1269
|
-
each.ref = [tableAlias, each.as]
|
|
1270
|
-
each.as = tableAlias + '_' + each.as
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
// ensure the cast
|
|
1274
|
-
if (
|
|
1275
|
-
each.as.match(/IsActiveEntity$/) ||
|
|
1276
|
-
each.as.match(/HasActiveEntity$/) ||
|
|
1277
|
-
each.as.match(/HasDraftEntity$/)
|
|
1278
|
-
) {
|
|
1279
|
-
each.cast = { type: 'cds.Boolean' }
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
const cs = cqn.columns
|
|
1284
|
-
.filter(c => !c.expand && c.ref && c.ref[0] === tableAlias)
|
|
1285
|
-
.map(c => ({ ref: [c.ref[1]] }))
|
|
1286
|
-
const unionArgs = cqn.from.args
|
|
1287
|
-
unionArgs[0].SELECT = { columns: cs, from: unionFrom, distinct: true }
|
|
1288
|
-
delete unionArgs[0].ref
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
return cqn
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
_isPathExpressionToOne(ref, entity) {
|
|
1296
|
-
const ref0 = ref[0]
|
|
1297
|
-
const el = entity.elements[ref0]
|
|
1298
|
-
return el && el.is2one
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
_copyOrderBy(orderBy, alias, expandedEntity) {
|
|
1302
|
-
return orderBy.map(element => {
|
|
1303
|
-
const sort = element.sort
|
|
1304
|
-
if (element.args)
|
|
1305
|
-
return { func: element.func, args: this._copyOrderBy(element.args, alias, expandedEntity), sort }
|
|
1306
|
-
|
|
1307
|
-
const ref =
|
|
1308
|
-
element.ref[0] === alias
|
|
1309
|
-
? [...element.ref]
|
|
1310
|
-
: element.ref.length === 1
|
|
1311
|
-
? [alias, element.ref[0]]
|
|
1312
|
-
: this._isPathExpressionToOne(element.ref, expandedEntity)
|
|
1313
|
-
? [alias, ...element.ref]
|
|
1314
|
-
: [alias, element.ref[1]]
|
|
1315
|
-
|
|
1316
|
-
return (sort && { ref, sort }) || { ref }
|
|
1317
|
-
})
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
_getHasDraftEntityXpr(expandedEntity, tableAlias) {
|
|
1321
|
-
const draftTable = ensureDraftsSuffix(expandedEntity.name)
|
|
1322
|
-
const where = entity_keys(expandedEntity).reduce((res, keyName) => {
|
|
1323
|
-
if (res.length !== 0) res.push('and')
|
|
1324
|
-
res.push({ ref: [draftTable, keyName] }, '=', { ref: [tableAlias, keyName] })
|
|
1325
|
-
return res
|
|
1326
|
-
}, [])
|
|
1327
|
-
const hasDraftQuery = {
|
|
1328
|
-
SELECT: {
|
|
1329
|
-
from: { ref: [draftTable] },
|
|
1330
|
-
columns: [{ val: 1 }],
|
|
1331
|
-
where: where
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
|
|
1335
|
-
return {
|
|
1336
|
-
xpr: ['case', 'when', hasDraftQuery, 'IS NOT NULL', 'then', 'true', 'else', 'false', 'end'],
|
|
1337
|
-
as: 'HasDraftEntity',
|
|
1338
|
-
cast: { type: 'cds.Boolean' }
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
|
-
_copyColumns(columns, alias) {
|
|
1343
|
-
return columns.map(element => {
|
|
1344
|
-
const column = {
|
|
1345
|
-
ref: [alias, element.ref[element.ref.length - 1]]
|
|
1346
|
-
}
|
|
1347
|
-
|
|
1348
|
-
if (element.as) {
|
|
1349
|
-
column.as = element.as
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
return column
|
|
1353
|
-
})
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
_convertOnToWhere(on, currentAlias, newAlias) {
|
|
1357
|
-
return on.map(element => {
|
|
1358
|
-
if (typeof element === 'object' && element.ref) {
|
|
1359
|
-
return {
|
|
1360
|
-
ref: [element.ref[0] === currentAlias ? newAlias : element.ref[0], element.ref[1]]
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
return element
|
|
1365
|
-
})
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
_copyWhere(list) {
|
|
1369
|
-
return list.map(entry => {
|
|
1370
|
-
return typeof entry === 'object' ? this._copyObject(entry) : entry
|
|
1371
|
-
})
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
_copyObject(obj) {
|
|
1375
|
-
const newObj = {}
|
|
1376
|
-
|
|
1377
|
-
for (const key in obj) {
|
|
1378
|
-
if (Array.isArray(obj[key])) {
|
|
1379
|
-
newObj[key] = Array.from(obj[key])
|
|
1380
|
-
} else {
|
|
1381
|
-
newObj[key] = obj[key]
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
return newObj
|
|
1386
|
-
}
|
|
1387
|
-
|
|
1388
|
-
_getFilterColumns(readToOneCQN, on, parentAlias) {
|
|
1389
|
-
const columns = []
|
|
1390
|
-
const outerColumns = []
|
|
1391
|
-
|
|
1392
|
-
const _sameRef = (col1, col2) => {
|
|
1393
|
-
if (!col1.ref || !col2.ref) return false // only handle refs
|
|
1394
|
-
if (col1.ref.length !== col2.ref.length) return false
|
|
1395
|
-
if (col1.as !== col2.as) return false
|
|
1396
|
-
for (let i = 0; i < col1.ref.length; i++) {
|
|
1397
|
-
if (col1.ref[i] !== col2.ref[i]) return false
|
|
1398
|
-
}
|
|
1399
|
-
return true
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
|
-
for (const entry of on) {
|
|
1403
|
-
if (entry.xpr) {
|
|
1404
|
-
const { columns: cols, outerColumns: outerCols } = this._getFilterColumns(readToOneCQN, entry.xpr, parentAlias)
|
|
1405
|
-
|
|
1406
|
-
// de-duplicate
|
|
1407
|
-
for (const col of cols) {
|
|
1408
|
-
if (!columns.some(c => _sameRef(c, col))) columns.push(col)
|
|
1409
|
-
}
|
|
1410
|
-
for (const col of outerCols) {
|
|
1411
|
-
if (!outerColumns.some(c => _sameRef(c, col))) outerColumns.push(col)
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
continue
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
if (typeof entry === 'object' && entry.ref && entry.ref[0] === 'filterExpand') {
|
|
1418
|
-
columns.push(this._getColumnObjectForFilterExpand(readToOneCQN, parentAlias, entry.ref[1]))
|
|
1419
|
-
outerColumns.push({ ref: [entry.ref[1]] })
|
|
1420
|
-
}
|
|
1421
|
-
}
|
|
1422
|
-
|
|
1423
|
-
return { columns, outerColumns }
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
/**
|
|
1427
|
-
* Reduce column list to column(s) needed to merge the result into one.
|
|
1428
|
-
*
|
|
1429
|
-
* @param readToOneCQN
|
|
1430
|
-
* @param on
|
|
1431
|
-
* @param parentAlias
|
|
1432
|
-
* @param keyObject
|
|
1433
|
-
* @returns {object}
|
|
1434
|
-
* @private
|
|
1435
|
-
*/
|
|
1436
|
-
_getFilterExpandCQN(readToOneCQN, on, parentAlias, keyObject) {
|
|
1437
|
-
const keys = Object.keys(keyObject).filter(
|
|
1438
|
-
key =>
|
|
1439
|
-
key !== 'IsActiveEntity' && !keyObject[key].is2one && !keyObject[key].is2many && !keyObject[key]._isStructured
|
|
1440
|
-
)
|
|
1441
|
-
|
|
1442
|
-
const { columns, outerColumns } = this._getFilterColumns(readToOneCQN, on, parentAlias)
|
|
1443
|
-
|
|
1444
|
-
for (const key of keys) {
|
|
1445
|
-
if (!columns.map(entry => entry.as).includes(key)) {
|
|
1446
|
-
columns.push(this._getColumnObjectForFilterExpand(readToOneCQN, parentAlias, key))
|
|
1447
|
-
outerColumns.push({ ref: [key] })
|
|
1448
|
-
}
|
|
1449
|
-
}
|
|
1450
|
-
|
|
1451
|
-
if (readToOneCQN[IS_ACTIVE] && readToOneCQN.columns.length > 0) {
|
|
1452
|
-
readToOneCQN.columns.forEach(column => {
|
|
1453
|
-
if (
|
|
1454
|
-
column.as === `${parentAlias}_IsActiveEntity` ||
|
|
1455
|
-
column.as === `${parentAlias}_HasActiveEntity` ||
|
|
1456
|
-
column.as === `${parentAlias}_HasDraftEntity`
|
|
1457
|
-
)
|
|
1458
|
-
columns.push(column)
|
|
1459
|
-
})
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
const subSelect = Object.assign({}, readToOneCQN, { columns })
|
|
1463
|
-
|
|
1464
|
-
const SELECT = { from: { SELECT: subSelect }, columns: outerColumns, distinct: true }
|
|
1465
|
-
|
|
1466
|
-
return {
|
|
1467
|
-
SELECT: SELECT,
|
|
1468
|
-
as: 'filterExpand'
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
|
|
1472
|
-
_getColumnObjectForFilterExpand(readToOneCQN, parentAlias, key) {
|
|
1473
|
-
const relevantColumn = readToOneCQN.columns.find(
|
|
1474
|
-
column => column[IDENTIFIER] === key && column.ref[0] === parentAlias
|
|
1475
|
-
)
|
|
1476
|
-
return {
|
|
1477
|
-
ref: [parentAlias, (relevantColumn && relevantColumn.as) || key],
|
|
1478
|
-
as: key
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
_getValueFromEntry(entry, parentAlias, key, struct) {
|
|
1483
|
-
let value = entry[key] ?? entry[key.toUpperCase()]
|
|
1484
|
-
if (value === undefined) {
|
|
1485
|
-
value = entry[`${parentAlias}_${key}`] || entry[`${parentAlias}_${key}`.toUpperCase()]
|
|
1486
|
-
}
|
|
1487
|
-
|
|
1488
|
-
if (
|
|
1489
|
-
value === undefined &&
|
|
1490
|
-
((cds.env.effective.odata && cds.env.effective.odata.structs) || cds.env.features.ucsn_struct_conversion)
|
|
1491
|
-
) {
|
|
1492
|
-
// here, it should be a structured key
|
|
1493
|
-
const keys = Object.keys(entry).filter(k => k.startsWith(key + '_'))
|
|
1494
|
-
if (keys.length) {
|
|
1495
|
-
// find struct
|
|
1496
|
-
if (!struct) {
|
|
1497
|
-
let current = this._csn.definitions[this._SELECT.from.ref[0]]
|
|
1498
|
-
let navs
|
|
1499
|
-
for (const k in this._aliases) {
|
|
1500
|
-
if (this._aliases[k] === parentAlias) {
|
|
1501
|
-
navs = k
|
|
1502
|
-
}
|
|
1503
|
-
}
|
|
1504
|
-
navs = navs.split(':')
|
|
1505
|
-
while (navs.length) {
|
|
1506
|
-
const element = current.elements[navs.shift()]
|
|
1507
|
-
if (element) {
|
|
1508
|
-
current = this._csn.definitions[element.target]
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
struct = current.elements[key.replace(parentAlias + '_', '')]
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
// build value for spreading (cf. mapping[GET_KEY_VALUE])
|
|
1515
|
-
value = []
|
|
1516
|
-
for (const k in struct.elements) {
|
|
1517
|
-
const ele = struct.elements[k]
|
|
1518
|
-
const l = key + '_' + k
|
|
1519
|
-
if (ele._isStructured) value.push(...this._getValueFromEntry(entry, parentAlias, l, ele))
|
|
1520
|
-
else value.push(this._getValueFromEntry(entry, parentAlias, l))
|
|
1521
|
-
}
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
return value
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
_addColumNames(entity, parentAlias, columnNames) {
|
|
1529
|
-
for (const keyName in entity.keys) {
|
|
1530
|
-
const key = entity.keys[keyName]
|
|
1531
|
-
if (key.is2one || key.is2many) continue
|
|
1532
|
-
const columnNameAlt = keyName === 'IsActiveEntity' ? 'IsActiveEntity' : `${parentAlias}_${keyName}`
|
|
1533
|
-
if (!columnNames.includes(columnNameAlt)) {
|
|
1534
|
-
columnNames.push(columnNameAlt)
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
/**
|
|
1540
|
-
* In case a column is used at a JOIN, it needs to be added to the list of selected columns.
|
|
1541
|
-
*
|
|
1542
|
-
* @param mapping
|
|
1543
|
-
* @param parentAlias
|
|
1544
|
-
* @param on
|
|
1545
|
-
* @param entity
|
|
1546
|
-
* @returns {Array}
|
|
1547
|
-
* @private
|
|
1548
|
-
*/
|
|
1549
|
-
_getJoinColumnsFromOnAddToMapping(mapping, parentAlias, on, entity) {
|
|
1550
|
-
const columns = []
|
|
1551
|
-
const columnNames = []
|
|
1552
|
-
|
|
1553
|
-
this._addColumNames(entity, parentAlias, columnNames)
|
|
1554
|
-
|
|
1555
|
-
for (const entry of on) {
|
|
1556
|
-
if (entry.xpr) {
|
|
1557
|
-
columns.push(...this._getJoinColumnsFromOnAddToMapping(mapping, parentAlias, entry.xpr, entity))
|
|
1558
|
-
continue
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
if (typeof entry === 'object' && entry.ref && entry.ref[0] !== 'filterExpand') {
|
|
1562
|
-
const as = entry.ref.join('_')
|
|
1563
|
-
columns.push({
|
|
1564
|
-
ref: entry.ref,
|
|
1565
|
-
as: as,
|
|
1566
|
-
[SKIP_MAPPING]: true
|
|
1567
|
-
})
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
|
|
1571
|
-
// Function will be used a post processing to create unique keys for cache and lookup the same
|
|
1572
|
-
mapping[GET_KEY_VALUE] = (atExpanded, entry) => {
|
|
1573
|
-
const keyValue = []
|
|
1574
|
-
const keyList = atExpanded
|
|
1575
|
-
? Object.keys(entry).filter(keyName => keyName.toLowerCase().startsWith('filterexpand_'))
|
|
1576
|
-
: columnNames
|
|
1577
|
-
|
|
1578
|
-
for (const key of keyList) {
|
|
1579
|
-
const parts = key.split('_')
|
|
1580
|
-
|
|
1581
|
-
// For draft-enabled entities, associations may not take over 'IsActiveEntity', e.g.
|
|
1582
|
-
// when a draft points to an active entity
|
|
1583
|
-
if (parts[parts.length - 1] !== 'IsActiveEntity') {
|
|
1584
|
-
let val = this._getValueFromEntry(entry, parentAlias, key)
|
|
1585
|
-
if (val instanceof Buffer) {
|
|
1586
|
-
val = Buffer.from(val).toString('base64')
|
|
1587
|
-
}
|
|
1588
|
-
if (!Array.isArray(val)) val = [val]
|
|
1589
|
-
keyValue.push(...val)
|
|
1590
|
-
}
|
|
1591
|
-
}
|
|
1592
|
-
|
|
1593
|
-
return keyValue.join(':')
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
return columns
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
|
-
/**
|
|
1600
|
-
* Get the explicitly named columns for expand and add ID columns, so the result can be added to the correct part at merged result.
|
|
1601
|
-
*
|
|
1602
|
-
* @param {object} args
|
|
1603
|
-
* @param args.tableAlias
|
|
1604
|
-
* @param args.columnList
|
|
1605
|
-
* @param args.entity
|
|
1606
|
-
* @param args.joinColumns
|
|
1607
|
-
* @param args.isActive
|
|
1608
|
-
* @param args.parentEntity
|
|
1609
|
-
* @returns {object}
|
|
1610
|
-
* @private
|
|
1611
|
-
*/
|
|
1612
|
-
_getColumnsForExpand({ tableAlias, columnList, entity, joinColumns, isActive, parentEntity = {} }) {
|
|
1613
|
-
const columns = []
|
|
1614
|
-
const keys = getAllKeys(entity)
|
|
1615
|
-
const parentKeys = getAllKeys(parentEntity)
|
|
1616
|
-
|
|
1617
|
-
for (const column of columnList.expand) {
|
|
1618
|
-
if (column.expand || !column.ref) {
|
|
1619
|
-
columns.push(column)
|
|
1620
|
-
} else {
|
|
1621
|
-
this._addToColumnList(columns, entity, tableAlias, column, isActive)
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
this._addMissingJoinElements(columns, joinColumns)
|
|
1626
|
-
this._addMissingKeyColumns(columns, tableAlias, keys, isActive, entity)
|
|
1627
|
-
this._addMissingParentKeyColumns(columns, 'filterExpand', parentKeys, isActive)
|
|
1628
|
-
return columns
|
|
1629
|
-
}
|
|
1630
|
-
|
|
1631
|
-
_createCalculatedBooleanColumn(alias, isActive) {
|
|
1632
|
-
return {
|
|
1633
|
-
val: isActive,
|
|
1634
|
-
as: alias,
|
|
1635
|
-
cast: { type: 'cds.Boolean' }
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
|
|
1639
|
-
_createIsActiveEntityOfParent(isActive, tableAlias) {
|
|
1640
|
-
return {
|
|
1641
|
-
val: isActive,
|
|
1642
|
-
as: `${tableAlias}_IsActiveEntity`,
|
|
1643
|
-
cast: { type: 'cds.Boolean' },
|
|
1644
|
-
[SKIP_MAPPING]: true
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
|
-
_addToColumnList(columns, entity, tableAlias, column, isActive) {
|
|
1649
|
-
const columnName = column.ref[column.ref.length - 1]
|
|
1650
|
-
|
|
1651
|
-
if (typeof isActive === 'boolean') {
|
|
1652
|
-
if (columnName === 'IsActiveEntity') {
|
|
1653
|
-
columns.push(this._createCalculatedBooleanColumn('IsActiveEntity', isActive))
|
|
1654
|
-
return
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1657
|
-
if (isActive) {
|
|
1658
|
-
if (columnName === 'HasActiveEntity') {
|
|
1659
|
-
columns.push(this._createCalculatedBooleanColumn('HasActiveEntity', false))
|
|
1660
|
-
return
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
if (columnName === 'HasDraftEntity') {
|
|
1664
|
-
columns.push(this._getHasDraftEntityXpr(entity, tableAlias))
|
|
1665
|
-
return
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
|
|
1670
|
-
columns.push({
|
|
1671
|
-
ref: [tableAlias, columnName],
|
|
1672
|
-
as: column.as || `${tableAlias}_${columnName}`
|
|
1673
|
-
})
|
|
1674
|
-
}
|
|
1675
|
-
|
|
1676
|
-
_isNotIncludedIn(columns) {
|
|
1677
|
-
if (columns.some(column => isAsteriskColumn(column))) return () => false
|
|
1678
|
-
return entry =>
|
|
1679
|
-
!columns.some(
|
|
1680
|
-
column =>
|
|
1681
|
-
(typeof column === 'object' && column.ref && column.ref[column.ref.length - 1] === entry) ||
|
|
1682
|
-
('val' in column && column.as === entry)
|
|
1683
|
-
)
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
|
-
/**
|
|
1687
|
-
* Add join columns if they are not already existing in the list.
|
|
1688
|
-
*
|
|
1689
|
-
* @private
|
|
1690
|
-
*/
|
|
1691
|
-
|
|
1692
|
-
_addMissingJoinElements(columns, joinColumns) {
|
|
1693
|
-
const isNotIncludedInColumns = this._isNotIncludedIn(columns)
|
|
1694
|
-
for (const joinColumn of joinColumns) {
|
|
1695
|
-
if (isNotIncludedInColumns(joinColumn.ref[1])) {
|
|
1696
|
-
columns.push(joinColumn)
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
|
|
1701
|
-
/**
|
|
1702
|
-
* Add key columns if they are not already existing in the list.
|
|
1703
|
-
*
|
|
1704
|
-
* @param columns
|
|
1705
|
-
* @param tableAlias
|
|
1706
|
-
* @param keys
|
|
1707
|
-
* @param isActive
|
|
1708
|
-
* @param entity
|
|
1709
|
-
* @private
|
|
1710
|
-
*/
|
|
1711
|
-
_addMissingKeyColumns(columns, tableAlias, keys, isActive, entity) {
|
|
1712
|
-
for (const key of keys.filter(this._isNotIncludedIn(columns))) {
|
|
1713
|
-
if (key === 'IsActiveEntity' && typeof isActive === 'boolean') {
|
|
1714
|
-
const col = this._createCalculatedBooleanColumn(key, isActive)
|
|
1715
|
-
col[CLEANUP_KEYS] = true
|
|
1716
|
-
columns.push(col)
|
|
1717
|
-
} else if (!entity.elements[key].elements) {
|
|
1718
|
-
// > don't add if complex key
|
|
1719
|
-
columns.push({
|
|
1720
|
-
ref: [tableAlias, key],
|
|
1721
|
-
as: `${tableAlias}_${key}`,
|
|
1722
|
-
[CLEANUP_KEYS]: true
|
|
1723
|
-
})
|
|
1724
|
-
}
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
|
|
1728
|
-
_addMissingParentKeyColumns(columns, tableAlias, keys, parentIsActive) {
|
|
1729
|
-
for (const key of keys) {
|
|
1730
|
-
if (key === 'IsActiveEntity' && typeof parentIsActive === 'boolean') {
|
|
1731
|
-
columns.push(this._createIsActiveEntityOfParent(parentIsActive, tableAlias))
|
|
1732
|
-
} else {
|
|
1733
|
-
columns.push({
|
|
1734
|
-
ref: [tableAlias, key],
|
|
1735
|
-
as: `${tableAlias}_${key}`,
|
|
1736
|
-
[SKIP_MAPPING]: true
|
|
1737
|
-
})
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
/**
|
|
1744
|
-
* Creates CQN(s) by using JOIN for all expanded entries, as expanding is not supported by SQL.
|
|
1745
|
-
*
|
|
1746
|
-
* @param {object} cqn - CQN with expanded columns
|
|
1747
|
-
* @param {object} csn - Services CSN
|
|
1748
|
-
* @param {string} locale
|
|
1749
|
-
* @returns {object}
|
|
1750
|
-
* @private
|
|
1751
|
-
*/
|
|
1752
|
-
const createJoinCQNFromExpanded = (cqn, csn, locale) => {
|
|
1753
|
-
return new JoinCQNFromExpanded(cqn, csn, locale).buildJoinQueries()
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1756
|
-
/**
|
|
1757
|
-
* Check if the given CQN is of type select and contains expand.
|
|
1758
|
-
*
|
|
1759
|
-
* @param {object} cqn
|
|
1760
|
-
* @returns {boolean}
|
|
1761
|
-
* @private
|
|
1762
|
-
*/
|
|
1763
|
-
const hasExpand = cqn => {
|
|
1764
|
-
if (!cqn) return false
|
|
1765
|
-
const { SELECT } = cqn
|
|
1766
|
-
if (!SELECT) return false
|
|
1767
|
-
const { columns } = SELECT
|
|
1768
|
-
if (!columns) return false
|
|
1769
|
-
return columns.some(col => col.expand)
|
|
1770
|
-
}
|
|
1771
|
-
|
|
1772
|
-
module.exports = {
|
|
1773
|
-
createJoinCQNFromExpanded,
|
|
1774
|
-
hasExpand
|
|
1775
|
-
}
|