@sap/cds 5.9.6 → 6.0.1
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 +266 -20
- package/apis/services.d.ts +1 -1
- package/app/fiori/preview.js +2 -6
- package/app/index.js +3 -3
- package/bin/build/buildTaskEngine.js +17 -15
- package/bin/build/buildTaskFactory.js +29 -19
- package/bin/build/buildTaskHandler.js +27 -11
- package/bin/build/buildTaskProvider.js +2 -4
- package/bin/build/buildTaskProviderFactory.js +11 -16
- package/bin/build/constants.js +14 -6
- package/bin/build/csv-reader.js +2 -1
- package/bin/build/index.js +12 -18
- package/bin/build/provider/buildTaskHandlerEdmx.js +3 -39
- package/bin/build/provider/buildTaskHandlerFeatureToggles.js +149 -0
- package/bin/build/provider/buildTaskHandlerInternal.js +2 -3
- package/bin/build/provider/buildTaskProviderInternal.js +108 -239
- package/bin/build/provider/fiori/index.js +2 -2
- package/bin/build/provider/hana/2migration.js +11 -11
- package/bin/build/provider/hana/2tabledata.js +3 -3
- package/bin/build/provider/hana/index.js +89 -99
- package/bin/build/provider/hana/migrationtable.js +4 -3
- package/bin/build/provider/java/index.js +101 -0
- package/bin/build/provider/java-cf/index.js +1 -101
- package/bin/build/provider/mtx/index.js +90 -53
- package/bin/build/provider/mtx/resourcesTarBuilder.js +68 -0
- package/bin/build/provider/mtx-sidecar/index.js +80 -0
- package/bin/build/provider/node-cf/index.js +1 -308
- package/bin/build/provider/nodejs/index.js +189 -0
- package/bin/build/util.js +19 -31
- package/bin/cds.js +5 -3
- package/bin/deploy/to-hana/cfUtil.js +31 -6
- package/bin/deploy/to-hana/gitUtil.js +5 -3
- package/bin/deploy/to-hana/hana.js +9 -10
- package/bin/{build → deploy/to-hana}/mtaUtil.js +10 -9
- package/bin/mtx/in-cds.js +19 -7
- package/bin/serve.js +56 -21
- package/bin/utils/log.js +13 -30
- package/bin/version.js +5 -4
- package/common.cds +61 -16
- package/lib/compile/cdsc.js +3 -2
- package/lib/compile/etc/_localized.js +15 -14
- package/lib/compile/for/drafts.js +3 -4
- package/lib/compile/for/java.js +13 -10
- package/lib/compile/for/nodejs.js +8 -8
- package/lib/compile/for/odata.js +7 -12
- package/lib/compile/for/sql.js +5 -6
- package/lib/compile/index.js +5 -4
- package/lib/compile/load.js +9 -11
- package/lib/compile/minify.js +8 -5
- package/lib/compile/parse.js +4 -2
- package/lib/compile/resolve.js +18 -15
- package/lib/compile/to/edm.js +0 -1
- package/lib/compile/to/gql.js +3 -2
- package/lib/compile/to/json.js +24 -17
- package/lib/connect/bindings.js +3 -2
- package/lib/connect/index.js +5 -5
- package/lib/core/classes.js +74 -2
- package/lib/core/entities.js +52 -3
- package/lib/core/reflect.js +2 -1
- package/lib/deploy.js +11 -8
- package/lib/env/defaults.js +4 -3
- package/lib/env/index.js +71 -31
- package/lib/env/presets.js +1 -14
- package/lib/env/requires.js +70 -20
- package/lib/env/serviceBindings.js +147 -0
- package/lib/i18n/localize.js +22 -23
- package/lib/index.js +148 -144
- package/lib/log/errors.js +55 -12
- package/lib/log/format/kibana.js +1 -1
- package/lib/log/index.js +4 -0
- package/lib/ql/SELECT.js +7 -2
- package/lib/ql/Whereable.js +8 -2
- package/lib/ql/index.js +2 -2
- package/lib/req/assert.js +71 -0
- package/lib/req/cds-context.js +38 -70
- package/lib/req/context.js +34 -21
- package/lib/req/request.js +12 -18
- package/lib/req/response.js +6 -2
- package/lib/req/user.js +30 -22
- package/lib/serve/Service-api.js +17 -12
- package/lib/serve/Service-dispatch.js +5 -9
- package/lib/serve/Service-methods.js +4 -3
- package/lib/serve/Transaction.js +24 -21
- package/lib/serve/adapters.js +15 -5
- package/lib/serve/factory.js +23 -20
- package/lib/serve/index.js +51 -54
- package/lib/utils/axios.js +8 -12
- package/lib/utils/index.js +3 -3
- package/lib/utils/resources/index.js +1 -44
- package/lib/utils/resources/tar.js +2 -1
- package/lib/utils/tests.js +13 -15
- package/libx/_runtime/.eslintrc +1 -1
- package/libx/_runtime/audit/Service.js +6 -4
- package/libx/_runtime/audit/generic/personal/access.js +19 -43
- package/libx/_runtime/audit/generic/personal/index.js +40 -34
- package/libx/_runtime/audit/generic/personal/modification.js +11 -9
- package/libx/_runtime/audit/generic/personal/utils.js +13 -6
- package/libx/_runtime/audit/utils/v2.js +6 -3
- package/libx/_runtime/auth/index.js +71 -66
- package/libx/_runtime/auth/strategies/JWT.js +3 -2
- package/libx/_runtime/auth/strategies/mock.js +54 -53
- package/libx/_runtime/auth/strategies/xssecUtils.js +3 -4
- package/libx/_runtime/auth/strategies/xsuaa.js +3 -2
- package/libx/_runtime/auth/utils.js +2 -15
- package/libx/_runtime/cds-services/adapter/odata-v4/Dispatcher.js +128 -42
- package/libx/_runtime/cds-services/adapter/odata-v4/OData.js +6 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/ODataRequest.js +93 -73
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/action.js +10 -45
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/create.js +5 -9
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/error.js +9 -5
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/metadata.js +4 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/read.js +60 -53
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/request.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/update.js +15 -21
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/ExpressionToCQN.js +8 -15
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/expandToCQN.js +29 -41
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/index.js +1 -4
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/readToCQN.js +13 -13
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/selectToCQN.js +0 -7
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/utils.js +24 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/EdmEntityContainer.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriHelper.js +4 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/utils/PrimitiveValueDecoder.js +4 -5
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/utils/ValueConverter.js +4 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/validator/ValueValidator.js +5 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/ResponseHeaderSetter.js +2 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/DebugSerializingCommand.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/PresetResponseHeadersCommand.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/SerializingCommand.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/SetResponseHeadersCommand.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ContextURLFactory.js +3 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ErrorJsonSerializer.js +3 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/SerializerFactory.js +1 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/TrustedResourceJsonSerializer.js +3 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js +36 -25
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/handlerUtils.js +100 -91
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/metaInfo.js +382 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/oDataConfiguration.js +1 -4
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/omitValues.js +5 -6
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/readAfterWrite.js +77 -21
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/request.js +3 -11
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/result.js +91 -69
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/stream.js +27 -6
- package/libx/_runtime/cds-services/adapter/rest/utils/validation-checks.js +7 -17
- package/libx/_runtime/cds-services/services/Service.js +17 -76
- package/libx/_runtime/cds-services/services/utils/columns.js +6 -4
- package/libx/_runtime/cds-services/services/utils/compareJson.js +1 -53
- package/libx/_runtime/cds-services/services/utils/differ.js +15 -19
- package/libx/_runtime/cds-services/util/assert.js +107 -34
- package/libx/_runtime/cds.js +1 -31
- package/libx/_runtime/common/aspects/Association.js +40 -54
- package/libx/_runtime/common/aspects/any.js +61 -6
- package/libx/_runtime/common/aspects/entity.js +19 -79
- package/libx/_runtime/common/composition/data.js +2 -2
- package/libx/_runtime/common/composition/delete.js +16 -18
- package/libx/_runtime/common/composition/tree.js +10 -10
- package/libx/_runtime/common/composition/update.js +3 -2
- package/libx/_runtime/common/constants/events.js +15 -0
- package/libx/_runtime/common/error/entry.js +9 -3
- package/libx/_runtime/common/error/frontend.js +13 -19
- package/libx/_runtime/common/error/index.js +8 -3
- package/libx/_runtime/common/generic/auth/capabilities.js +2 -1
- package/libx/_runtime/common/generic/auth/constants.js +1 -4
- package/libx/_runtime/common/generic/auth/requires.js +1 -1
- package/libx/_runtime/common/generic/auth/restrict.js +12 -28
- package/libx/_runtime/common/generic/auth/restrictions.js +12 -4
- package/libx/_runtime/common/generic/auth/utils.js +2 -1
- package/libx/_runtime/common/generic/crud.js +9 -60
- package/libx/_runtime/common/generic/etag.js +41 -7
- package/libx/_runtime/common/generic/input.js +128 -66
- package/libx/_runtime/common/generic/paging.js +9 -3
- package/libx/_runtime/common/generic/put.js +2 -2
- package/libx/_runtime/common/generic/sorting.js +11 -4
- package/libx/_runtime/common/generic/temporal.js +0 -5
- package/libx/_runtime/common/i18n/messages.properties +2 -1
- package/libx/_runtime/common/utils/binary.js +69 -0
- package/libx/_runtime/common/utils/cqn.js +39 -14
- package/libx/_runtime/common/utils/cqn2cqn4sql.js +93 -59
- package/libx/_runtime/common/utils/csn.js +87 -85
- package/libx/_runtime/common/utils/dollar.js +8 -7
- package/libx/_runtime/common/utils/draft.js +1 -1
- package/libx/_runtime/common/utils/foreignKeyPropagations.js +23 -7
- package/libx/_runtime/common/utils/generateOnCond.js +2 -1
- package/libx/_runtime/common/utils/keys.js +30 -13
- package/libx/_runtime/common/utils/postProcessing.js +6 -1
- package/libx/_runtime/common/utils/quotingStyles.js +0 -23
- package/libx/_runtime/common/utils/resolveStructured.js +23 -26
- package/libx/_runtime/common/utils/resolveView.js +4 -1
- package/libx/_runtime/common/utils/rewriteAsterisks.js +3 -0
- package/libx/_runtime/common/utils/search2cqn4sql.js +4 -13
- package/libx/_runtime/common/utils/searchToLike.js +9 -13
- package/libx/_runtime/common/utils/streamProp.js +35 -0
- package/libx/_runtime/common/utils/structured.js +12 -18
- package/libx/_runtime/common/utils/template.js +3 -5
- package/libx/_runtime/common/utils/templateProcessor.js +22 -14
- package/libx/_runtime/common/utils/unionCqnTemplate.js +4 -14
- package/libx/_runtime/db/Service.js +2 -1
- package/libx/_runtime/db/expand/expand-v2.js +2 -2
- package/libx/_runtime/db/expand/expandCQNToJoin.js +7 -6
- package/libx/_runtime/db/generic/input.js +14 -17
- package/libx/_runtime/db/generic/integrity.js +1 -2
- package/libx/_runtime/db/generic/update.js +14 -1
- package/libx/_runtime/db/query/read.js +0 -1
- package/libx/_runtime/db/query/update.js +1 -1
- package/libx/_runtime/db/sql-builder/BaseBuilder.js +1 -1
- package/libx/_runtime/db/sql-builder/ExpressionBuilder.js +5 -31
- package/libx/_runtime/db/sql-builder/InsertBuilder.js +1 -1
- package/libx/_runtime/db/sql-builder/ReferenceBuilder.js +0 -9
- package/libx/_runtime/db/sql-builder/SelectBuilder.js +11 -10
- package/libx/_runtime/db/sql-builder/UpdateBuilder.js +2 -2
- package/libx/_runtime/db/sql-builder/annotations.js +1 -2
- package/libx/_runtime/db/utils/coloredTxCommands.js +5 -0
- package/libx/_runtime/db/utils/columns.js +1 -1
- package/libx/_runtime/db/utils/propagateForeignKeys.js +10 -2
- package/libx/_runtime/extensibility/activate.js +69 -0
- package/libx/_runtime/extensibility/add.js +41 -0
- package/libx/_runtime/extensibility/addExtension.js +68 -0
- package/libx/_runtime/extensibility/defaults.js +39 -0
- package/libx/_runtime/extensibility/{uiflex/handler → handler}/transformREAD.js +0 -0
- package/libx/_runtime/extensibility/{uiflex/handler → handler}/transformRESULT.js +2 -2
- package/libx/_runtime/extensibility/{uiflex/handler → handler}/transformWRITE.js +2 -2
- package/libx/_runtime/extensibility/push.js +61 -0
- package/libx/_runtime/extensibility/service.js +21 -0
- package/libx/_runtime/extensibility/{uiflex/utils.js → utils.js} +39 -3
- package/libx/_runtime/extensibility/validation.js +53 -0
- package/libx/_runtime/extensibility/views.js +12 -0
- package/libx/_runtime/fiori/generic/activate.js +6 -4
- package/libx/_runtime/fiori/generic/before.js +17 -29
- package/libx/_runtime/fiori/generic/cancel.js +2 -4
- package/libx/_runtime/fiori/generic/delete.js +2 -4
- package/libx/_runtime/fiori/generic/edit.js +3 -7
- package/libx/_runtime/fiori/generic/index.js +31 -0
- package/libx/_runtime/fiori/generic/new.js +2 -4
- package/libx/_runtime/fiori/generic/patch.js +4 -8
- package/libx/_runtime/fiori/generic/prepare.js +2 -4
- package/libx/_runtime/fiori/generic/read.js +137 -162
- package/libx/_runtime/fiori/generic/readOverDraft.js +10 -4
- package/libx/_runtime/fiori/utils/handler.js +10 -5
- package/libx/_runtime/fiori/utils/where.js +1 -4
- package/libx/_runtime/hana/Service.js +14 -7
- package/libx/_runtime/hana/customBuilder/CustomSelectBuilder.js +1 -1
- package/libx/_runtime/hana/dynatrace.js +2 -2
- package/libx/_runtime/hana/localized.js +7 -6
- package/libx/_runtime/hana/pool.js +9 -6
- package/libx/_runtime/hana/search.js +2 -3
- package/libx/_runtime/hana/{searchToContains.js → search2Contains.js} +5 -2
- package/libx/_runtime/hana/search2cqn4sql.js +20 -17
- package/libx/_runtime/index.js +2 -6
- package/libx/_runtime/messaging/AMQPWebhookMessaging.js +11 -2
- package/libx/_runtime/messaging/common-utils/AMQPClient.js +4 -3
- package/libx/_runtime/messaging/common-utils/appId.js +9 -0
- package/libx/_runtime/messaging/common-utils/authorizedRequest.js +2 -18
- package/libx/_runtime/messaging/common-utils/connections.js +1 -1
- package/libx/_runtime/messaging/enterprise-messaging-shared.js +2 -2
- package/libx/_runtime/messaging/enterprise-messaging-utils/EMManagement.js +305 -231
- package/libx/_runtime/messaging/enterprise-messaging-utils/cloudEvents.js +2 -2
- package/libx/_runtime/messaging/enterprise-messaging-utils/options-management.js +15 -8
- package/libx/_runtime/messaging/enterprise-messaging-utils/options-messaging.js +57 -14
- package/libx/_runtime/messaging/enterprise-messaging.js +14 -19
- package/libx/_runtime/messaging/file-based.js +2 -1
- package/libx/_runtime/messaging/http-utils/token.js +18 -6
- package/libx/_runtime/messaging/message-queuing-utils/options-management.js +22 -12
- package/libx/_runtime/messaging/message-queuing-utils/options-messaging.js +27 -14
- package/libx/_runtime/messaging/message-queuing.js +138 -85
- package/libx/_runtime/messaging/outbox/utils.js +13 -7
- package/libx/_runtime/messaging/redis-messaging.js +0 -1
- package/libx/_runtime/messaging/service.js +4 -1
- package/libx/_runtime/remote/Service.js +24 -18
- package/libx/_runtime/remote/utils/client.js +84 -46
- package/libx/_runtime/remote/utils/data.js +23 -6
- package/libx/_runtime/sqlite/Service.js +14 -13
- package/libx/_runtime/sqlite/convertAssocToOneManaged.js +2 -0
- package/libx/_runtime/sqlite/customBuilder/CustomSelectBuilder.js +1 -0
- package/libx/_runtime/sqlite/execute.js +3 -9
- package/libx/_runtime/types/api.js +23 -11
- package/libx/common/utils/ucsn.js +15 -9
- package/libx/odata/afterburner.js +109 -29
- package/libx/odata/cqn2odata.js +48 -9
- package/libx/odata/grammar.pegjs +261 -157
- package/libx/odata/index.js +21 -9
- package/libx/odata/parseToCqn.js +8 -5
- package/libx/odata/parser.js +1 -1
- package/libx/odata/utils.js +13 -3
- package/libx/rest/RestAdapter.js +173 -113
- package/libx/rest/RestRequest.js +3 -2
- package/libx/rest/middleware/create.js +8 -6
- package/libx/rest/middleware/delete.js +6 -13
- package/libx/rest/middleware/error.js +1 -1
- package/libx/rest/middleware/input.js +6 -6
- package/libx/rest/middleware/operation.js +8 -3
- package/libx/rest/middleware/parse.js +3 -3
- package/libx/rest/middleware/payload.js +12 -0
- package/libx/rest/middleware/read.js +12 -2
- package/libx/rest/middleware/update.js +3 -3
- package/package.json +4 -6
- package/server.js +3 -44
- package/srv/extensibility-service.cds +56 -0
- package/srv/extensibility-service.js +1 -0
- package/srv/extensions.cds +8 -0
- package/srv/model-provider.cds +59 -0
- package/srv/model-provider.js +163 -0
- package/srv/mtx.cds +2 -0
- package/srv/mtx.js +22 -0
- package/srv/outbox.cds +2 -0
- package/tasks/enterprise-messaging-deploy.js +19 -12
- package/lib/serve/Service-compat.js +0 -36
- package/libx/_runtime/audit/generic/personal/constants.js +0 -4
- package/libx/_runtime/auth/strategies/dwc.js +0 -45
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/dispatcherUtils.js +0 -56
- package/libx/_runtime/cds-services/adapter/rest/Rest.js +0 -183
- package/libx/_runtime/cds-services/adapter/rest/RestRequest.js +0 -67
- package/libx/_runtime/cds-services/adapter/rest/handlers/create.js +0 -82
- package/libx/_runtime/cds-services/adapter/rest/handlers/delete.js +0 -39
- package/libx/_runtime/cds-services/adapter/rest/handlers/operation.js +0 -63
- package/libx/_runtime/cds-services/adapter/rest/handlers/read.js +0 -52
- package/libx/_runtime/cds-services/adapter/rest/handlers/update.js +0 -81
- package/libx/_runtime/cds-services/adapter/rest/rest-to-cqn/index.js +0 -56
- package/libx/_runtime/cds-services/adapter/rest/rest-to-cqn/utils.js +0 -33
- package/libx/_runtime/cds-services/adapter/rest/to.js +0 -8
- package/libx/_runtime/cds-services/adapter/rest/utils/binary.js +0 -50
- package/libx/_runtime/cds-services/adapter/rest/utils/data.js +0 -117
- package/libx/_runtime/cds-services/adapter/rest/utils/header-checks.js +0 -14
- package/libx/_runtime/cds-services/adapter/rest/utils/key-value-utils.js +0 -30
- package/libx/_runtime/cds-services/adapter/rest/utils/parse-url.js +0 -250
- package/libx/_runtime/cds-services/adapter/rest/utils/result.js +0 -26
- package/libx/_runtime/cds-services/services/utils/handlerUtils.js +0 -200
- package/libx/_runtime/common/aspects/utils.js +0 -152
- package/libx/_runtime/common/toggles/handler.js +0 -21
- package/libx/_runtime/common/utils/extensibilityUtils.js +0 -18
- package/libx/_runtime/extensibility/mps/index.js +0 -5
- package/libx/_runtime/extensibility/mps/service.js +0 -111
- package/libx/_runtime/extensibility/mps/tar.js +0 -42
- package/libx/_runtime/extensibility/mps/utils.js +0 -11
- package/libx/_runtime/extensibility/uiflex/index.js +0 -54
- package/libx/_runtime/extensibility/uiflex/service.js +0 -276
- package/libx/_runtime/messaging/common-utils/naming-conventions.js +0 -20
- package/libx/_runtime/remote/utils/client-types.d.ts +0 -7
- package/libx/gql/GraphQLAdapter.js +0 -33
- package/libx/gql/constants/adapter.js +0 -69
- package/libx/gql/constants/cds.js +0 -18
- package/libx/gql/constants/graphql.js +0 -33
- package/libx/gql/readme.md +0 -1
- package/libx/gql/resolvers/crud/create.js +0 -20
- package/libx/gql/resolvers/crud/delete.js +0 -29
- package/libx/gql/resolvers/crud/index.js +0 -6
- package/libx/gql/resolvers/crud/read.js +0 -30
- package/libx/gql/resolvers/crud/update.js +0 -42
- package/libx/gql/resolvers/crud/utils/index.js +0 -36
- package/libx/gql/resolvers/field.js +0 -5
- package/libx/gql/resolvers/index.js +0 -7
- package/libx/gql/resolvers/mutation.js +0 -23
- package/libx/gql/resolvers/parse/ast/enrich.js +0 -52
- package/libx/gql/resolvers/parse/ast/fragment.js +0 -11
- package/libx/gql/resolvers/parse/ast/fromObject.js +0 -39
- package/libx/gql/resolvers/parse/ast/index.js +0 -3
- package/libx/gql/resolvers/parse/ast/meta.js +0 -4
- package/libx/gql/resolvers/parse/ast/variable.js +0 -7
- package/libx/gql/resolvers/parse/ast2cqn/columns.js +0 -44
- package/libx/gql/resolvers/parse/ast2cqn/entries.js +0 -31
- package/libx/gql/resolvers/parse/ast2cqn/index.js +0 -8
- package/libx/gql/resolvers/parse/ast2cqn/limit.js +0 -6
- package/libx/gql/resolvers/parse/ast2cqn/orderBy.js +0 -24
- package/libx/gql/resolvers/parse/ast2cqn/utils/index.js +0 -3
- package/libx/gql/resolvers/parse/ast2cqn/where.js +0 -70
- package/libx/gql/resolvers/parse/utils/index.js +0 -8
- package/libx/gql/resolvers/query.js +0 -13
- package/libx/gql/resolvers/root.js +0 -34
- package/libx/gql/schema/generate.js +0 -18
- package/libx/gql/schema/index.js +0 -5
- package/libx/gql/schema/mutation.js +0 -76
- package/libx/gql/schema/query.js +0 -108
- package/libx/gql/schema/typeDefMap.js +0 -45
- package/libx/gql/schema/utils/index.js +0 -54
- package/libx/gql/utils/index.js +0 -12
- package/libx/rest/middleware/auth.js +0 -20
- package/libx/rest/middleware/content.js +0 -19
- package/srv/flex.cds +0 -21
- package/srv/flex.js +0 -1
- package/srv/mps.cds +0 -23
- package/srv/mps.js +0 -1
- package/srv/outbox.js +0 -0
|
@@ -38,6 +38,11 @@ const _modifyCQN = (cqnDraft, where, context) => {
|
|
|
38
38
|
const fromRef = cqnDraft.SELECT.from.ref
|
|
39
39
|
cqnDraft.SELECT.from.ref[fromRef.length - 1] = ensureDraftsSuffix(fromRef[fromRef.length - 1])
|
|
40
40
|
}
|
|
41
|
+
if (cqnDraft.SELECT.columns) {
|
|
42
|
+
cqnDraft.SELECT.columns = cqnDraft.SELECT.columns.map(e =>
|
|
43
|
+
e.ref && e.ref.includes('IsActiveEntity') ? { val: true, as: 'IsActiveEntity', cast: { type: 'cds.Boolean' } } : e
|
|
44
|
+
)
|
|
45
|
+
}
|
|
41
46
|
|
|
42
47
|
_modifyWhere(cqnDraft.SELECT.where, context)
|
|
43
48
|
}
|
|
@@ -66,8 +71,9 @@ const _shouldReadOverDraft = (req, definitions) => {
|
|
|
66
71
|
|
|
67
72
|
if (!fromRef) return false
|
|
68
73
|
|
|
69
|
-
// read over the draft if the navigation target is non-draft-enabled
|
|
70
|
-
|
|
74
|
+
// for $expand requests, read over the draft if the navigation target is non-draft-enabled
|
|
75
|
+
// REVISIT: this is an interim workaround to be removed
|
|
76
|
+
if (!req.target._isDraftEnabled && SELECT.columns && SELECT.columns.some(column => column.expand)) return true
|
|
71
77
|
|
|
72
78
|
// read over the draft only for navigation scenarios
|
|
73
79
|
if (fromRef.length === 1) return false
|
|
@@ -136,6 +142,6 @@ const _readOverDraftHandler = async function (req, next) {
|
|
|
136
142
|
return cds.tx(req).run(sqlQuery)
|
|
137
143
|
}
|
|
138
144
|
|
|
139
|
-
module.exports = cds.service.impl(function readOverDraft() {
|
|
140
|
-
|
|
145
|
+
module.exports = cds.service.impl(function readOverDraft(srv) {
|
|
146
|
+
srv.on('READ', '*', _readOverDraftHandler)
|
|
141
147
|
})
|
|
@@ -137,17 +137,17 @@ const getEnrichedCQN = (cqn, select, draftWhere, scenarioAlias, addLimitOrder =
|
|
|
137
137
|
if (select.one) cqn.SELECT.one = true
|
|
138
138
|
|
|
139
139
|
if (select.having) {
|
|
140
|
-
cqn.having(_aliased(select.having, alias))
|
|
140
|
+
cqn.having(_aliased(select.having, select.columns, alias))
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
// groupBy, orderBy and limit do not support partial CQNs
|
|
144
144
|
if (select.groupBy) {
|
|
145
|
-
cqn.SELECT.groupBy = _aliased(select.groupBy, alias)
|
|
145
|
+
cqn.SELECT.groupBy = _aliased(select.groupBy, select.columns, alias)
|
|
146
146
|
cqn.SELECT.columns = _getSelectedColumns(cqn.SELECT.columns, select.columns)
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
if (select.orderBy && addLimitOrder) {
|
|
150
|
-
cqn.SELECT.orderBy = _aliased(select.orderBy, alias)
|
|
150
|
+
cqn.SELECT.orderBy = _aliased(select.orderBy, select.columns, alias)
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
if (select.limit && addLimitOrder) {
|
|
@@ -169,9 +169,14 @@ const _aliasRef = (ref, alias) => {
|
|
|
169
169
|
const getDeleteDraftAdminCqn = draftUUID =>
|
|
170
170
|
DELETE.from('DRAFT.DraftAdministrativeData').where([{ ref: ['DraftUUID'] }, '=', { val: draftUUID }])
|
|
171
171
|
|
|
172
|
-
const _aliased = (arr, alias) =>
|
|
172
|
+
const _aliased = (arr, columns, alias) =>
|
|
173
173
|
arr.map(item => {
|
|
174
|
-
if (
|
|
174
|
+
if (item.ref && columns.some(c => c.as === item.ref[item.ref.length - 1])) {
|
|
175
|
+
// remove table alias if present for a calculated field
|
|
176
|
+
if (item.ref[0] === alias) {
|
|
177
|
+
return item.ref.splice(0, 1)
|
|
178
|
+
}
|
|
179
|
+
} else if (alias && item.ref && item.ref[0] !== alias) {
|
|
175
180
|
return Object.assign({}, item, { ref: _aliasRef(item.ref, alias) })
|
|
176
181
|
}
|
|
177
182
|
return item
|
|
@@ -54,8 +54,6 @@ const _removeIsActiveEntityCondition = where => {
|
|
|
54
54
|
i = i + 3
|
|
55
55
|
} else if (where[i] === 'and' && _isActiveEntity(where[i + 1])) {
|
|
56
56
|
i = i + 4
|
|
57
|
-
} else if (where[i] === 'and' && where[i + 1] === '(' && _isActiveEntity(where[i + 2])) {
|
|
58
|
-
i = i + 6
|
|
59
57
|
} else if (where[i].xpr) {
|
|
60
58
|
if (where[i].xpr.length) {
|
|
61
59
|
newWhere.push({ xpr: _removeIsActiveEntityCondition(where[i].xpr) })
|
|
@@ -69,8 +67,6 @@ const _removeIsActiveEntityCondition = where => {
|
|
|
69
67
|
|
|
70
68
|
if (newWhere[0] === 'and' || newWhere[0] === 'or') {
|
|
71
69
|
newWhere.splice(0, 1)
|
|
72
|
-
} else if (newWhere[0] === '(' && newWhere[1] === 'and') {
|
|
73
|
-
newWhere.splice(0, 2)
|
|
74
70
|
}
|
|
75
71
|
|
|
76
72
|
return newWhere
|
|
@@ -144,6 +140,7 @@ const removeIsActiveEntityRecursively = where => {
|
|
|
144
140
|
entry.xpr = removeIsActiveEntityRecursively(entry.xpr)
|
|
145
141
|
continue
|
|
146
142
|
}
|
|
143
|
+
|
|
147
144
|
if (entry.SELECT && entry.SELECT.where && entry.SELECT.from.ref && !entry.SELECT.from.ref[0].endsWith('_drafts')) {
|
|
148
145
|
entry.SELECT.where = removeIsActiveEntityRecursively(entry.SELECT.where)
|
|
149
146
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const cds = require('../cds')
|
|
2
2
|
const LOG = cds.log('hana|db|sql')
|
|
3
|
+
const coloredTxCommands = require('../db/utils/coloredTxCommands')
|
|
3
4
|
|
|
4
5
|
const DatabaseService = require('../db/Service')
|
|
5
6
|
const pool = require('./pool')
|
|
@@ -22,9 +23,10 @@ const _setSessionContext = (dbc, property, value) => {
|
|
|
22
23
|
if (dbc._connection) {
|
|
23
24
|
// Works, but bad practice to access an internal scope
|
|
24
25
|
dbc._connection.getClientInfo().setProperty(property, value)
|
|
25
|
-
|
|
26
|
-
dbc.setClientInfo(property, value)
|
|
26
|
+
return
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
dbc.setClientInfo(property, value)
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
/*
|
|
@@ -53,7 +55,8 @@ class HanaDatabase extends DatabaseService {
|
|
|
53
55
|
/*
|
|
54
56
|
* tx
|
|
55
57
|
*/
|
|
56
|
-
this.on('BEGIN',
|
|
58
|
+
this.on('BEGIN', function () {
|
|
59
|
+
LOG._debug && LOG.debug(coloredTxCommands['BEGIN'])
|
|
57
60
|
this.dbc.setAutoCommit(false)
|
|
58
61
|
return 'dummy'
|
|
59
62
|
})
|
|
@@ -62,6 +65,7 @@ class HanaDatabase extends DatabaseService {
|
|
|
62
65
|
this.before('COMMIT', this._integrity.performCheck)
|
|
63
66
|
|
|
64
67
|
this.on(['COMMIT', 'ROLLBACK'], function (req) {
|
|
68
|
+
LOG._debug && LOG.debug(coloredTxCommands[req.event])
|
|
65
69
|
return new Promise((resolve, reject) => {
|
|
66
70
|
this.dbc[req.event.toLowerCase()](async err => {
|
|
67
71
|
try {
|
|
@@ -70,6 +74,7 @@ class HanaDatabase extends DatabaseService {
|
|
|
70
74
|
// REVISIT: what to do?
|
|
71
75
|
return reject(e)
|
|
72
76
|
}
|
|
77
|
+
|
|
73
78
|
if (err) return reject(err)
|
|
74
79
|
resolve('dummy')
|
|
75
80
|
})
|
|
@@ -121,21 +126,24 @@ class HanaDatabase extends DatabaseService {
|
|
|
121
126
|
// eslint-disable-next-line complexity
|
|
122
127
|
async acquire(arg) {
|
|
123
128
|
// REVISIT: remove fallback arg.user.tenant with cds^6 (still needed for cds-mtx)
|
|
124
|
-
const tenant = (typeof arg === 'string' ? arg : arg.tenant || (arg.user && arg.user.tenant))
|
|
129
|
+
const tenant = arg && (typeof arg === 'string' ? arg : arg.tenant || (arg.user && arg.user.tenant))
|
|
125
130
|
const dbc = await pool.acquire(tenant, this)
|
|
126
131
|
|
|
127
|
-
if (typeof arg !== 'string') {
|
|
132
|
+
if (arg && typeof arg !== 'string') {
|
|
128
133
|
_setSessionContext(dbc, 'APPLICATIONUSER', arg.user.id || 'ANONYMOUS')
|
|
129
134
|
_setSessionContext(dbc, 'LOCALE', arg.locale || 'en')
|
|
135
|
+
|
|
130
136
|
// REVISIT: stable access
|
|
131
137
|
const validFrom = (arg.context && arg.context._ && arg.context._['VALID-FROM']) || (arg._ && arg._['VALID-FROM'])
|
|
132
138
|
const validto = (arg.context && arg.context._ && arg.context._['VALID-TO']) || (arg._ && arg._['VALID-TO'])
|
|
139
|
+
|
|
133
140
|
if (validFrom)
|
|
134
141
|
_setSessionContext(
|
|
135
142
|
dbc,
|
|
136
143
|
'VALID-FROM',
|
|
137
144
|
validFrom instanceof Date ? validFrom.toISOString().replace('T', ' ') : validFrom.replace('T', ' ')
|
|
138
145
|
)
|
|
146
|
+
|
|
139
147
|
if (validto)
|
|
140
148
|
_setSessionContext(
|
|
141
149
|
dbc,
|
|
@@ -145,12 +153,12 @@ class HanaDatabase extends DatabaseService {
|
|
|
145
153
|
}
|
|
146
154
|
|
|
147
155
|
dbc._tenant = tenant
|
|
148
|
-
|
|
149
156
|
return dbc
|
|
150
157
|
}
|
|
151
158
|
|
|
152
159
|
release(dbc) {
|
|
153
160
|
if (dbc) return pool.release(dbc)
|
|
161
|
+
|
|
154
162
|
// should not happen, but just in case
|
|
155
163
|
LOG._warn && LOG.warn(new Error('Release called without client. Please report this warning.'))
|
|
156
164
|
}
|
|
@@ -158,7 +166,6 @@ class HanaDatabase extends DatabaseService {
|
|
|
158
166
|
// REVISIT: should happen automatically after a configurable time
|
|
159
167
|
// poolOnly: private param for mtx
|
|
160
168
|
async disconnect(tenant, poolOnly) {
|
|
161
|
-
tenant = tenant || 'anonymous'
|
|
162
169
|
await pool.drain(tenant)
|
|
163
170
|
if (!poolOnly) super.disconnect(tenant)
|
|
164
171
|
}
|
|
@@ -79,7 +79,7 @@ if (cds.env.sql.names === 'plain') {
|
|
|
79
79
|
CustomSelectBuilder.prototype._buildRefElement = function (col, res, noQuoting) {
|
|
80
80
|
res = new this.ReferenceBuilder(col, this._options, this._csn).build()
|
|
81
81
|
|
|
82
|
-
if (!noQuoting && !col.as
|
|
82
|
+
if (!noQuoting && !col.as) {
|
|
83
83
|
res.sql += ` AS ${this._options.delimiter}${col.ref[col.ref.length - 1]}${this._options.delimiter}`
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -65,7 +65,7 @@ const _preparedStmtUsingDynatrace = function (client, prepareFn, dbInfo) {
|
|
|
65
65
|
|
|
66
66
|
const dynatraceClient = (client, credentials, tenant) => {
|
|
67
67
|
const dbInfo = {
|
|
68
|
-
name: `SAPHANA${tenant
|
|
68
|
+
name: `SAPHANA${tenant ? `-${tenant}` : ''}`,
|
|
69
69
|
vendor: dynatrace.sdk.DatabaseVendor.HANADB,
|
|
70
70
|
host: credentials.host,
|
|
71
71
|
port: Number(credentials.port)
|
|
@@ -90,7 +90,7 @@ const _createHanaClientStreamingStatement = function (extension, createStmtFn) {
|
|
|
90
90
|
// args = [sql, options, callback] --> options is optional
|
|
91
91
|
return function (dbc, sql, cb) {
|
|
92
92
|
const dbInfo = {
|
|
93
|
-
name: `SAPHANA${dbc._tenant
|
|
93
|
+
name: `SAPHANA${dbc._tenant ? `-${dbc._tenant}` : ''}`,
|
|
94
94
|
vendor: dynatrace.sdk.DatabaseVendor.HANADB,
|
|
95
95
|
host: dbc._creds.host,
|
|
96
96
|
port: Number(dbc._creds.port)
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
const { ensureUnlocalized } = require('../common/utils/draft')
|
|
2
2
|
const { redirect } = require('../db/utils/localized')
|
|
3
3
|
|
|
4
|
-
const getLocalize =
|
|
4
|
+
const getLocalize = model => name => {
|
|
5
5
|
if (name.endsWith('_drafts')) return name
|
|
6
6
|
|
|
7
|
-
// if we get here via onReadDraft, target is already localized
|
|
8
|
-
// because of
|
|
7
|
+
// if we get here via onReadDraft, the target is already localized
|
|
8
|
+
// because of sub-request using SELECT.from as the new target
|
|
9
9
|
const target = model.definitions[ensureUnlocalized(name)]
|
|
10
10
|
const localizedView = target && target['@cds.localized'] !== false && model.definitions[`localized.${name}`]
|
|
11
|
-
|
|
12
11
|
return localizedView ? localizedView.name : name
|
|
13
12
|
}
|
|
14
13
|
|
|
@@ -28,10 +27,12 @@ const localizedHandler = function (req) {
|
|
|
28
27
|
const columns = query.SELECT.columns
|
|
29
28
|
if (columns && columns.length === 1 && columns[0].func === 'count') return
|
|
30
29
|
|
|
31
|
-
// suppress localization
|
|
30
|
+
// suppress localization (no redirection to localized view) for queries that
|
|
31
|
+
// lock the selected record (exclusive and shared locks)
|
|
32
32
|
if (query.SELECT.forUpdate) return
|
|
33
|
+
if (query.SELECT.forShareLock) return
|
|
33
34
|
|
|
34
|
-
redirect(query, getLocalize(
|
|
35
|
+
redirect(query, getLocalize(this.model))
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
localizedHandler._initial = true
|
|
@@ -5,6 +5,7 @@ const { pool } = require('@sap/cds-foss')
|
|
|
5
5
|
const hana = require('./driver')
|
|
6
6
|
|
|
7
7
|
const _require = require('../common/utils/require')
|
|
8
|
+
const getError = require('../common/error')
|
|
8
9
|
|
|
9
10
|
function multiTenantInstanceManager(config = cds.env.requires.db) {
|
|
10
11
|
const { credentials } = config
|
|
@@ -65,7 +66,7 @@ function singleTenantInstanceManager(config = cds.env.requires.db) {
|
|
|
65
66
|
async function credentials4(tenant, db) {
|
|
66
67
|
if (!db._instance_manager) {
|
|
67
68
|
const opts = db.options && db.options.credentials ? db.options : undefined
|
|
68
|
-
db._instance_manager = cds.
|
|
69
|
+
db._instance_manager = cds.requires.multitenancy
|
|
69
70
|
? await multiTenantInstanceManager(opts)
|
|
70
71
|
: singleTenantInstanceManager(opts)
|
|
71
72
|
}
|
|
@@ -221,12 +222,14 @@ async function resilientAcquire(pool, attempts = 1) {
|
|
|
221
222
|
}
|
|
222
223
|
}
|
|
223
224
|
if (client) return client
|
|
224
|
-
err.statusCode = 503
|
|
225
|
-
err.message =
|
|
226
|
-
'Acquiring client from pool timed out. Please review your system setup, transaction handling, and pool configuration.'
|
|
227
|
-
err._attempts = attempt
|
|
228
225
|
const { borrowed, pending, size, available, max } = pool
|
|
229
|
-
err
|
|
226
|
+
err = getError(
|
|
227
|
+
Object.assign(err, {
|
|
228
|
+
statusCode: 503,
|
|
229
|
+
message: `Acquiring client from pool timed out. Please review your system setup, transaction handling, and pool configuration. Pool State: borrowed: ${borrowed}, pending: ${pending}, size: ${size}, available: ${available}, max: ${max}`
|
|
230
|
+
})
|
|
231
|
+
)
|
|
232
|
+
err._attempts = attempt
|
|
230
233
|
LOG._debug && LOG.debug(err)
|
|
231
234
|
throw err
|
|
232
235
|
}
|
|
@@ -11,9 +11,8 @@ function searchHandler(req) {
|
|
|
11
11
|
// REVISIT: remove feature toggle optimized_search after grace period
|
|
12
12
|
// inject the search2cqn4sql module into the rewrite handler only when
|
|
13
13
|
// the optimized search feature toggle is turned on
|
|
14
|
-
if (cds.env.features.optimized_search)
|
|
15
|
-
|
|
16
|
-
}
|
|
14
|
+
if (cds.env.features.optimized_search === false) return
|
|
15
|
+
_setSearchOptions(req.query, { search2cqn4sql, locale: req.locale })
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
// handlers marked with `._initial = true` run in sequence
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* @param {import("../types/api").ColumnRefs} columns The columns to be searched
|
|
25
25
|
* @returns {import("../types/api").searchContainsExp} The `CONTAINS` CQN expression
|
|
26
26
|
*/
|
|
27
|
-
const
|
|
27
|
+
const search2Contains = (cqnSearchPhrase, columns) => {
|
|
28
28
|
// serialize the CQN search phrase
|
|
29
29
|
const searchString = cqnSearchPhrase.reduce((searchStringAccumulator, currentValue) => {
|
|
30
30
|
// Multiple search terms separated by an space are automatically
|
|
@@ -92,4 +92,7 @@ const isContainsPredicateSupported = query => {
|
|
|
92
92
|
return true
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
module.exports = {
|
|
95
|
+
module.exports = {
|
|
96
|
+
isContainsPredicateSupported,
|
|
97
|
+
search2Contains
|
|
98
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { computeColumnsToBeSearched } = require('../cds-services/services/utils/columns')
|
|
2
2
|
const searchToLike = require('../common/utils/searchToLike')
|
|
3
|
-
const { isContainsPredicateSupported,
|
|
3
|
+
const { isContainsPredicateSupported, search2Contains } = require('./search2Contains')
|
|
4
4
|
const { addAliasToExpression } = require('../db/utils/generateAliases')
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -24,7 +24,7 @@ const search2cqn4sql = (query, entity, options) => {
|
|
|
24
24
|
const cqnSearchPhrase = query.SELECT.search
|
|
25
25
|
if (!cqnSearchPhrase) return query
|
|
26
26
|
|
|
27
|
-
let { columns:
|
|
27
|
+
let { columns: columns2Search = computeColumnsToBeSearched(query, entity), locale } = options
|
|
28
28
|
const localizedAssociation = _getLocalizedAssociation(entity)
|
|
29
29
|
|
|
30
30
|
// If the localized association is defined for the target entity,
|
|
@@ -34,14 +34,15 @@ const search2cqn4sql = (query, entity, options) => {
|
|
|
34
34
|
// suppress the localize handler from redirecting the query's target to the localized view
|
|
35
35
|
Object.defineProperty(query, '_suppressLocalization', { value: true })
|
|
36
36
|
|
|
37
|
+
const columnsDefs = entity.query && entity.query.SELECT.columns
|
|
38
|
+
const isSomeColumn2SearchUseFunction = _isSomeColumn2SearchAFunction(columns2Search, columnsDefs)
|
|
39
|
+
|
|
37
40
|
if (resolveLocalizedDataAtRuntime) {
|
|
38
41
|
const onCondition = entity._relations[localizedAssociation.name].join(localizedAssociation.target, entity.name)
|
|
39
42
|
|
|
40
43
|
// REVISIT this is dirty but works for now
|
|
41
44
|
// replace $user_locale placeholder with the user locale or the HANA session context
|
|
42
|
-
|
|
43
|
-
onCondition[0].xpr[onCondition[0].xpr.length - 1] = { val: locale || "SESSION_CONTEXT('LOCALE')" }
|
|
44
|
-
} else onCondition[onCondition.length - 2] = { val: locale || "SESSION_CONTEXT('LOCALE')" }
|
|
45
|
+
onCondition[0].xpr[onCondition[0].xpr.length - 1] = { val: locale || "SESSION_CONTEXT('LOCALE')" }
|
|
45
46
|
|
|
46
47
|
// inner join the target table with the _texts table (the _texts table contains
|
|
47
48
|
// the translated texts)
|
|
@@ -49,25 +50,18 @@ const search2cqn4sql = (query, entity, options) => {
|
|
|
49
50
|
query.join(localizedEntityName).on(onCondition)
|
|
50
51
|
|
|
51
52
|
// prevent SQL ambiguity error for columns with the same name
|
|
52
|
-
|
|
53
|
+
columns2Search = _addAliasToQuery(query, entity, columns2Search)
|
|
53
54
|
} // else --> resolve localized texts via localized view (default)
|
|
54
55
|
|
|
55
|
-
const useContains = isContainsPredicateSupported(query)
|
|
56
|
+
const useContains = !isSomeColumn2SearchUseFunction && isContainsPredicateSupported(query)
|
|
56
57
|
let expression
|
|
57
58
|
|
|
58
59
|
if (useContains) {
|
|
59
|
-
|
|
60
|
-
expression = searchToContains(cqnSearchPhrase, namedColumns)
|
|
61
|
-
|
|
62
|
-
// func columns handling
|
|
63
|
-
if (columnsToBeSearched.length > namedColumns.length) {
|
|
64
|
-
const funcColumns = columnsToBeSearched.filter(col => col.func)
|
|
65
|
-
expression = [expression, 'or', ...searchToLike(cqnSearchPhrase, funcColumns)]
|
|
66
|
-
}
|
|
60
|
+
expression = search2Contains(cqnSearchPhrase, columns2Search)
|
|
67
61
|
} else {
|
|
68
62
|
// No CONTAINS optimization possible. The search implementation for localized
|
|
69
63
|
// texts falls back to the LIKE predicate.
|
|
70
|
-
expression = searchToLike(cqnSearchPhrase,
|
|
64
|
+
expression = searchToLike(cqnSearchPhrase, columns2Search)
|
|
71
65
|
}
|
|
72
66
|
|
|
73
67
|
// REVISIT: find out here if where or having must be used
|
|
@@ -75,7 +69,16 @@ const search2cqn4sql = (query, entity, options) => {
|
|
|
75
69
|
return query
|
|
76
70
|
}
|
|
77
71
|
|
|
78
|
-
const
|
|
72
|
+
const _isSomeColumn2SearchAFunction = (columns2Search, columnsDefs) =>
|
|
73
|
+
columns2Search.some(column2Search => {
|
|
74
|
+
if (column2Search.func) return true
|
|
75
|
+
return columnsDefs && columnsDefs.some(columnDef => columnDef.func && columnDef.as === column2Search.ref[0])
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const _getLocalizedAssociation = entity => {
|
|
79
|
+
const associations = entity.associations
|
|
80
|
+
return associations && associations.localized
|
|
81
|
+
}
|
|
79
82
|
|
|
80
83
|
// The inner join modifies the original SELECT ... FROM query and adds ambiguity,
|
|
81
84
|
// therefore add the table/entity name (as a preceding element) to the columns ref
|
package/libx/_runtime/index.js
CHANGED
|
@@ -5,12 +5,8 @@ module.exports = {
|
|
|
5
5
|
return this._odatav4 || (this._odatav4 = require('./cds-services/adapter/odata-v4/to'))
|
|
6
6
|
},
|
|
7
7
|
|
|
8
|
-
get
|
|
9
|
-
return this.
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
get new_rest() {
|
|
13
|
-
return this._new_rest || (this._new_rest = require('../rest'))
|
|
8
|
+
get rest() {
|
|
9
|
+
return this._rest || (this._rest = require('../rest'))
|
|
14
10
|
}
|
|
15
11
|
},
|
|
16
12
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const cds = require('../cds')
|
|
2
2
|
const MessagingService = require('./service.js')
|
|
3
|
-
const { queueName } = require('./common-utils/naming-conventions')
|
|
4
3
|
const optionsApp = require('../common/utils/vcap.js')
|
|
5
4
|
const normalizeIncomingMessage = require('./common-utils/normalizeIncomingMessage')
|
|
5
|
+
const appId = require('./common-utils/appId')
|
|
6
6
|
|
|
7
7
|
class AMQPWebhookMessaging extends MessagingService {
|
|
8
8
|
async init() {
|
|
@@ -12,7 +12,10 @@ class AMQPWebhookMessaging extends MessagingService {
|
|
|
12
12
|
delete queueConfig.name
|
|
13
13
|
if (Object.keys(queueConfig).length) this.queueConfig = queueConfig
|
|
14
14
|
}
|
|
15
|
-
this.queueName =
|
|
15
|
+
this.queueName = this.prepareQueueName(
|
|
16
|
+
(this.options.queue && this.options.queue.name) ||
|
|
17
|
+
(this.options.credentials && this.options.credentials.namespace ? '$namespace/$appId' : '$appId')
|
|
18
|
+
)
|
|
16
19
|
|
|
17
20
|
cds.once('listening', () => {
|
|
18
21
|
this.startListening()
|
|
@@ -28,6 +31,12 @@ class AMQPWebhookMessaging extends MessagingService {
|
|
|
28
31
|
return client.emit(_msg)
|
|
29
32
|
}
|
|
30
33
|
|
|
34
|
+
prepareQueueName(queueName) {
|
|
35
|
+
const queue = queueName.replace(/\$appId/g, appId())
|
|
36
|
+
const namespace = (this.options.credentials && this.options.credentials.namespace) || ''
|
|
37
|
+
return queue.replace(/\$namespace/g, namespace)
|
|
38
|
+
}
|
|
39
|
+
|
|
31
40
|
startListening(opt = {}) {
|
|
32
41
|
if (this.subscribedTopics.size) {
|
|
33
42
|
const management = this.getManagement()
|
|
@@ -4,7 +4,7 @@ const { connect, disconnect } = require('./connections')
|
|
|
4
4
|
const { hasPersistentOutbox } = require('../outbox/utils')
|
|
5
5
|
|
|
6
6
|
const addDataListener = (client, queue, prefix, cb) =>
|
|
7
|
-
new Promise(
|
|
7
|
+
new Promise(resolve => {
|
|
8
8
|
const source = `${prefix}${queue}`
|
|
9
9
|
client
|
|
10
10
|
.receiver(queue)
|
|
@@ -53,13 +53,14 @@ class AMQPClient {
|
|
|
53
53
|
this.prefix = prefix
|
|
54
54
|
this.keepAlive = keepAlive
|
|
55
55
|
this.service = service
|
|
56
|
+
cds.on('shutdown', () => this.disconnect())
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
connect() {
|
|
59
|
+
async connect() {
|
|
59
60
|
this.client = new ClientAmqp(this.optionsAMQP)
|
|
60
61
|
this.sender = sender(this.client, this.service.optionsApp)
|
|
61
62
|
this.stream = this.sender.attach('')
|
|
62
|
-
|
|
63
|
+
await connect(this.client, this.service.LOG, this.keepAlive)
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
async disconnect() {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const optionsApp = require('../../common/utils/vcap')
|
|
2
|
+
const appId = () => {
|
|
3
|
+
const appName = optionsApp.appName || 'CAP'
|
|
4
|
+
const appID = optionsApp.appID || '00000000'
|
|
5
|
+
const shrunkAppID = appID.substring(0, 4)
|
|
6
|
+
return `${appName}/${shrunkAppID}`
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
module.exports = appId
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
const https = require('https')
|
|
2
2
|
const requestToken = require('../http-utils/token')
|
|
3
3
|
|
|
4
|
-
const authorizedRequest = ({
|
|
5
|
-
method,
|
|
6
|
-
uri,
|
|
7
|
-
path,
|
|
8
|
-
oa2,
|
|
9
|
-
tenant,
|
|
10
|
-
dataObj,
|
|
11
|
-
headers,
|
|
12
|
-
tokenStore,
|
|
13
|
-
attemptInfo,
|
|
14
|
-
errMsg,
|
|
15
|
-
target
|
|
16
|
-
}) => {
|
|
17
|
-
attemptInfo()
|
|
4
|
+
const authorizedRequest = ({ method, uri, path, oa2, tenant, dataObj, headers, tokenStore }) => {
|
|
18
5
|
return new Promise((resolve, reject) => {
|
|
19
6
|
;((tokenStore.token && Promise.resolve(tokenStore.token)) || requestToken(oa2, tenant, tokenStore))
|
|
20
7
|
.catch(err => reject(err))
|
|
@@ -56,10 +43,7 @@ const authorizedRequest = ({
|
|
|
56
43
|
}
|
|
57
44
|
const result = { body, headers: res.headers, statusCode: res.statusCode }
|
|
58
45
|
if (res.statusCode < 200 || (res.statusCode >= 300 && !(res.statusCode === 404 && method === 'DELETE'))) {
|
|
59
|
-
|
|
60
|
-
errObj.target = target
|
|
61
|
-
errObj.response = result
|
|
62
|
-
reject(errObj)
|
|
46
|
+
reject(result)
|
|
63
47
|
} else {
|
|
64
48
|
resolve(result)
|
|
65
49
|
}
|
|
@@ -7,7 +7,7 @@ const _connectUntilConnected = (client, LOG, x) => {
|
|
|
7
7
|
.then(() => {
|
|
8
8
|
LOG._warn && LOG.warn('Reconnected to Enterprise Messaging Client')
|
|
9
9
|
})
|
|
10
|
-
.catch(
|
|
10
|
+
.catch(() => {
|
|
11
11
|
LOG._warn &&
|
|
12
12
|
LOG.warn(
|
|
13
13
|
`Connection to Enterprise Messaging Client lost: Reconnecting in ${Math.round(_waitingTime / 1000)} s`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const AMQPWebhookMessaging = require('./AMQPWebhookMessaging')
|
|
2
2
|
const AMQPClient = require('./common-utils/AMQPClient')
|
|
3
|
-
const
|
|
3
|
+
const { optionsMessagingAMQP } = require('./enterprise-messaging-utils/options-messaging.js')
|
|
4
4
|
const optionsManagement = require('./enterprise-messaging-utils/options-management.js')
|
|
5
5
|
const EMManagement = require('./enterprise-messaging-utils/EMManagement.js')
|
|
6
6
|
const cloudEvents = require('./enterprise-messaging-utils/cloudEvents.js')
|
|
@@ -14,7 +14,7 @@ class EnterpriseMessagingShared extends AMQPWebhookMessaging {
|
|
|
14
14
|
|
|
15
15
|
getClient() {
|
|
16
16
|
if (this.client) return this.client
|
|
17
|
-
const optionsAMQP =
|
|
17
|
+
const optionsAMQP = optionsMessagingAMQP(this.options)
|
|
18
18
|
this.client = new AMQPClient({
|
|
19
19
|
optionsAMQP,
|
|
20
20
|
prefix: { topic: 'topic:', queue: 'queue:' },
|