@sap/cds 8.9.3 → 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 +122 -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/classes.js +1 -0
- package/lib/core/linked-csn.js +8 -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 +2 -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 +106 -142
- 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
package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/ExpressionParser.js
DELETED
|
@@ -1,1988 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const UriHelper = require('./UriHelper')
|
|
4
|
-
const UriTokenizer = require('./UriTokenizer')
|
|
5
|
-
const TokenKind = UriTokenizer.TokenKind
|
|
6
|
-
const KeyPredicateParser = require('./KeyPredicateParser')
|
|
7
|
-
const ExpressionKind = require('./Expression').ExpressionKind
|
|
8
|
-
const AliasExpression = require('./AliasExpression')
|
|
9
|
-
const BinaryExpression = require('./BinaryExpression')
|
|
10
|
-
const BinaryOperatorKind = BinaryExpression.OperatorKind
|
|
11
|
-
const LiteralExpression = require('./LiteralExpression')
|
|
12
|
-
const MemberExpression = require('./MemberExpression')
|
|
13
|
-
const MethodExpression = require('./MethodExpression')
|
|
14
|
-
const MethodKind = MethodExpression.MethodKind
|
|
15
|
-
const TypeLiteralExpression = require('./TypeLiteralExpression')
|
|
16
|
-
const UnaryExpression = require('./UnaryExpression')
|
|
17
|
-
const UnaryOperatorKind = UnaryExpression.OperatorKind
|
|
18
|
-
const EdmTypeKind = require('../edm/EdmType').TypeKind
|
|
19
|
-
const EdmPrimitiveType = require('../edm/EdmPrimitiveType')
|
|
20
|
-
const EdmPrimitiveTypeKind = require('../edm/EdmPrimitiveTypeKind')
|
|
21
|
-
const FullQualifiedName = require('../FullQualifiedName')
|
|
22
|
-
const UriResource = require('./UriResource')
|
|
23
|
-
const ResourceKind = UriResource.ResourceKind
|
|
24
|
-
const UriParameter = require('./UriParameter')
|
|
25
|
-
const ValueValidator = require('../validator/ValueValidator')
|
|
26
|
-
const valueValidator = new ValueValidator()
|
|
27
|
-
const UriSyntaxError = require('../errors/UriSyntaxError')
|
|
28
|
-
const UriQueryOptionSemanticError = require('../errors/UriQueryOptionSemanticError')
|
|
29
|
-
const UriSemanticError = require('../errors/UriSemanticError')
|
|
30
|
-
const ErrorNames = require('../errors/AbstractError').ErrorNames
|
|
31
|
-
const FeatureSupport = require('../FeatureSupport')
|
|
32
|
-
|
|
33
|
-
const tokenToPrimitiveType = new Map([
|
|
34
|
-
// Enum and null are not present in the map. These have to be handled differently.
|
|
35
|
-
[TokenKind.BooleanValue, EdmPrimitiveTypeKind.Boolean],
|
|
36
|
-
[TokenKind.StringValue, EdmPrimitiveTypeKind.String],
|
|
37
|
-
// Very large integer values are of type Edm.Decimal but this is handled elsewhere.
|
|
38
|
-
[TokenKind.IntegerValue, EdmPrimitiveTypeKind.Int64],
|
|
39
|
-
[TokenKind.GuidValue, EdmPrimitiveTypeKind.Guid],
|
|
40
|
-
[TokenKind.DateValue, EdmPrimitiveTypeKind.Date],
|
|
41
|
-
[TokenKind.DateTimeOffsetValue, EdmPrimitiveTypeKind.DateTimeOffset],
|
|
42
|
-
[TokenKind.TimeOfDayValue, EdmPrimitiveTypeKind.TimeOfDay],
|
|
43
|
-
[TokenKind.DecimalValue, EdmPrimitiveTypeKind.Decimal],
|
|
44
|
-
[TokenKind.DoubleValue, EdmPrimitiveTypeKind.Double],
|
|
45
|
-
[TokenKind.DurationValue, EdmPrimitiveTypeKind.Duration],
|
|
46
|
-
[TokenKind.BinaryValue, EdmPrimitiveTypeKind.Binary],
|
|
47
|
-
[TokenKind.GeographyPoint, EdmPrimitiveTypeKind.GeographyPoint],
|
|
48
|
-
[TokenKind.GeometryPoint, EdmPrimitiveTypeKind.GeometryPoint],
|
|
49
|
-
[TokenKind.GeographyLineString, EdmPrimitiveTypeKind.GeographyLineString],
|
|
50
|
-
[TokenKind.GeometryLineString, EdmPrimitiveTypeKind.GeometryLineString],
|
|
51
|
-
[TokenKind.GeographyPolygon, EdmPrimitiveTypeKind.GeographyPolygon],
|
|
52
|
-
[TokenKind.GeometryPolygon, EdmPrimitiveTypeKind.GeometryPolygon],
|
|
53
|
-
[TokenKind.GeographyMultiPoint, EdmPrimitiveTypeKind.GeographyMultiPoint],
|
|
54
|
-
[TokenKind.GeometryMultiPoint, EdmPrimitiveTypeKind.GeometryMultiPoint],
|
|
55
|
-
[TokenKind.GeographyMultiLineString, EdmPrimitiveTypeKind.GeographyMultiLineString],
|
|
56
|
-
[TokenKind.GeometryMultiLineString, EdmPrimitiveTypeKind.GeometryMultiLineString],
|
|
57
|
-
[TokenKind.GeographyMultiPolygon, EdmPrimitiveTypeKind.GeographyMultiPolygon],
|
|
58
|
-
[TokenKind.GeometryMultiPolygon, EdmPrimitiveTypeKind.GeometryMultiPolygon],
|
|
59
|
-
[TokenKind.GeographyCollection, EdmPrimitiveTypeKind.GeographyCollection],
|
|
60
|
-
[TokenKind.GeometryCollection, EdmPrimitiveTypeKind.GeometryCollection]
|
|
61
|
-
])
|
|
62
|
-
|
|
63
|
-
const tokenToBinaryOperator = new Map([
|
|
64
|
-
[TokenKind.OrOperator, BinaryOperatorKind.OR],
|
|
65
|
-
[TokenKind.AndOperator, BinaryOperatorKind.AND],
|
|
66
|
-
|
|
67
|
-
[TokenKind.EqualsOperator, BinaryOperatorKind.EQ],
|
|
68
|
-
[TokenKind.NotEqualsOperator, BinaryOperatorKind.NE],
|
|
69
|
-
|
|
70
|
-
[TokenKind.GreaterThanOperator, BinaryOperatorKind.GT],
|
|
71
|
-
[TokenKind.GreaterThanOrEqualsOperator, BinaryOperatorKind.GE],
|
|
72
|
-
[TokenKind.LessThanOperator, BinaryOperatorKind.LT],
|
|
73
|
-
[TokenKind.LessThanOrEqualsOperator, BinaryOperatorKind.LE],
|
|
74
|
-
|
|
75
|
-
[TokenKind.AddOperator, BinaryOperatorKind.ADD],
|
|
76
|
-
[TokenKind.SubOperator, BinaryOperatorKind.SUB],
|
|
77
|
-
|
|
78
|
-
[TokenKind.MulOperator, BinaryOperatorKind.MUL],
|
|
79
|
-
[TokenKind.DivOperator, BinaryOperatorKind.DIV],
|
|
80
|
-
[TokenKind.ModOperator, BinaryOperatorKind.MOD]
|
|
81
|
-
])
|
|
82
|
-
|
|
83
|
-
const tokenToMethod = new Map([
|
|
84
|
-
// 'cast' and 'isof' are handled specially.
|
|
85
|
-
[TokenKind.CeilingMethod, MethodKind.CEILING],
|
|
86
|
-
[TokenKind.ConcatMethod, MethodKind.CONCAT],
|
|
87
|
-
[TokenKind.ContainsMethod, MethodKind.CONTAINS],
|
|
88
|
-
[TokenKind.DateMethod, MethodKind.DATE],
|
|
89
|
-
[TokenKind.DayMethod, MethodKind.DAY],
|
|
90
|
-
[TokenKind.EndswithMethod, MethodKind.ENDSWITH],
|
|
91
|
-
[TokenKind.FloorMethod, MethodKind.FLOOR],
|
|
92
|
-
[TokenKind.FractionalsecondsMethod, MethodKind.FRACTIONALSECONDS],
|
|
93
|
-
[TokenKind.GeoDistanceMethod, MethodKind.GEODISTANCE],
|
|
94
|
-
[TokenKind.GeoIntersectsMethod, MethodKind.GEOINTERSECTS],
|
|
95
|
-
[TokenKind.GeoLengthMethod, MethodKind.GEOLENGTH],
|
|
96
|
-
[TokenKind.HourMethod, MethodKind.HOUR],
|
|
97
|
-
[TokenKind.IndexofMethod, MethodKind.INDEXOF],
|
|
98
|
-
[TokenKind.LengthMethod, MethodKind.LENGTH],
|
|
99
|
-
[TokenKind.MaxdatetimeMethod, MethodKind.MAXDATETIME],
|
|
100
|
-
[TokenKind.MindatetimeMethod, MethodKind.MINDATETIME],
|
|
101
|
-
[TokenKind.MinuteMethod, MethodKind.MINUTE],
|
|
102
|
-
[TokenKind.MonthMethod, MethodKind.MONTH],
|
|
103
|
-
[TokenKind.NowMethod, MethodKind.NOW],
|
|
104
|
-
[TokenKind.RoundMethod, MethodKind.ROUND],
|
|
105
|
-
[TokenKind.SecondMethod, MethodKind.SECOND],
|
|
106
|
-
[TokenKind.StartswithMethod, MethodKind.STARTSWITH],
|
|
107
|
-
[TokenKind.SubstringMethod, MethodKind.SUBSTRING],
|
|
108
|
-
[TokenKind.TimeMethod, MethodKind.TIME],
|
|
109
|
-
[TokenKind.TolowerMethod, MethodKind.TOLOWER],
|
|
110
|
-
[TokenKind.TotaloffsetminutesMethod, MethodKind.TOTALOFFSETMINUTES],
|
|
111
|
-
[TokenKind.TotalsecondsMethod, MethodKind.TOTALSECONDS],
|
|
112
|
-
[TokenKind.ToupperMethod, MethodKind.TOUPPER],
|
|
113
|
-
[TokenKind.TrimMethod, MethodKind.TRIM],
|
|
114
|
-
[TokenKind.YearMethod, MethodKind.YEAR]
|
|
115
|
-
])
|
|
116
|
-
|
|
117
|
-
class ExpressionParser {
|
|
118
|
-
/**
|
|
119
|
-
* Create an expression parser.
|
|
120
|
-
* @param {Edm} edm entity data model
|
|
121
|
-
*/
|
|
122
|
-
constructor (edm) {
|
|
123
|
-
this._edm = edm
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Parse a string into an expression tree.
|
|
128
|
-
* @param {UriTokenizer} tokenizer tokenizer containing the string to be parsed
|
|
129
|
-
* @param {?EdmType} referencedType type the expression references
|
|
130
|
-
* @param {?(EdmEntitySet[])} crossjoinEntitySets entity sets in case of a $crossjoin request
|
|
131
|
-
* @param {?Object} aliases alias definitions
|
|
132
|
-
* @returns {Expression} the root of the expression tree
|
|
133
|
-
* @throws {UriSyntaxError}
|
|
134
|
-
* @throws {UriQueryOptionSemanticError}
|
|
135
|
-
*/
|
|
136
|
-
parse (tokenizer, referencedType, crossjoinEntitySets, aliases) {
|
|
137
|
-
this._tokenizer = tokenizer
|
|
138
|
-
this._referringType = referencedType
|
|
139
|
-
this._crossjoinEntitySets = crossjoinEntitySets
|
|
140
|
-
this._aliases = aliases
|
|
141
|
-
this._lambdaVariables = []
|
|
142
|
-
|
|
143
|
-
return this._parseExpression()
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Top-level parser method.
|
|
148
|
-
* @returns {Expression} the root of the expression tree
|
|
149
|
-
* @private
|
|
150
|
-
*/
|
|
151
|
-
_parseExpression () {
|
|
152
|
-
let left = this._parseAnd()
|
|
153
|
-
while (this._tokenizer.next(TokenKind.OrOperator)) {
|
|
154
|
-
this.checkType(left, EdmPrimitiveTypeKind.Boolean)
|
|
155
|
-
this.checkNoCollection(left)
|
|
156
|
-
let right = this._parseAnd()
|
|
157
|
-
this.checkType(right, EdmPrimitiveTypeKind.Boolean)
|
|
158
|
-
this.checkNoCollection(right)
|
|
159
|
-
left = new BinaryExpression(left, BinaryOperatorKind.OR, right, EdmPrimitiveTypeKind.Boolean)
|
|
160
|
-
}
|
|
161
|
-
return left
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Parse expression with zero or more 'and' operators.
|
|
166
|
-
* @returns {Expression} expression
|
|
167
|
-
* @private
|
|
168
|
-
*/
|
|
169
|
-
_parseAnd () {
|
|
170
|
-
let left = this._parseExprEquality()
|
|
171
|
-
while (this._tokenizer.next(TokenKind.AndOperator)) {
|
|
172
|
-
this.checkType(left, EdmPrimitiveTypeKind.Boolean)
|
|
173
|
-
this.checkNoCollection(left)
|
|
174
|
-
let right = this._parseExprEquality()
|
|
175
|
-
this.checkType(right, EdmPrimitiveTypeKind.Boolean)
|
|
176
|
-
this.checkNoCollection(right)
|
|
177
|
-
left = new BinaryExpression(left, BinaryOperatorKind.AND, right, EdmPrimitiveTypeKind.Boolean)
|
|
178
|
-
}
|
|
179
|
-
return left
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Parse expression with zero or more 'eq' or 'ne' operators.
|
|
184
|
-
* @returns {Expression} expression
|
|
185
|
-
* @private
|
|
186
|
-
*/
|
|
187
|
-
_parseExprEquality () {
|
|
188
|
-
let left = this._parseExprRel()
|
|
189
|
-
let operatorTokenKind = [TokenKind.EqualsOperator, TokenKind.NotEqualsOperator].find(kind =>
|
|
190
|
-
this._tokenizer.next(kind)
|
|
191
|
-
)
|
|
192
|
-
// Null for everything other than EQ or NE
|
|
193
|
-
while (operatorTokenKind) {
|
|
194
|
-
let right = this._parseExprEquality()
|
|
195
|
-
this._checkEqualityTypes(left, right)
|
|
196
|
-
left = new BinaryExpression(
|
|
197
|
-
left,
|
|
198
|
-
tokenToBinaryOperator.get(operatorTokenKind),
|
|
199
|
-
right,
|
|
200
|
-
EdmPrimitiveTypeKind.Boolean
|
|
201
|
-
)
|
|
202
|
-
operatorTokenKind = [TokenKind.EqualsOperator, TokenKind.NotEqualsOperator].find(kind =>
|
|
203
|
-
this._tokenizer.next(kind)
|
|
204
|
-
)
|
|
205
|
-
}
|
|
206
|
-
return left
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Parse expression with 'isof' method or with zero or more 'gt' or 'ge' or 'lt' or 'le' operators.
|
|
211
|
-
* @returns {Expression} expression
|
|
212
|
-
* @private
|
|
213
|
-
*/
|
|
214
|
-
_parseExprRel () {
|
|
215
|
-
if (this._tokenizer.next(TokenKind.IsofMethod)) {
|
|
216
|
-
// The isof method is a terminal. So no further operators are allowed.
|
|
217
|
-
return this._parseIsOfOrCastMethod(MethodKind.ISOF)
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
let left = this._parseExprAdd()
|
|
221
|
-
let operatorTokenKind = [
|
|
222
|
-
TokenKind.GreaterThanOperator,
|
|
223
|
-
TokenKind.GreaterThanOrEqualsOperator,
|
|
224
|
-
TokenKind.LessThanOperator,
|
|
225
|
-
TokenKind.LessThanOrEqualsOperator
|
|
226
|
-
].find(kind => this._tokenizer.next(kind))
|
|
227
|
-
|
|
228
|
-
// Null for everything other than GT or GE or LT or LE
|
|
229
|
-
while (operatorTokenKind) {
|
|
230
|
-
let right = this._parseExprAdd()
|
|
231
|
-
this._checkRelationTypes(left, right)
|
|
232
|
-
left = new BinaryExpression(
|
|
233
|
-
left,
|
|
234
|
-
tokenToBinaryOperator.get(operatorTokenKind),
|
|
235
|
-
right,
|
|
236
|
-
EdmPrimitiveTypeKind.Boolean
|
|
237
|
-
)
|
|
238
|
-
|
|
239
|
-
operatorTokenKind = [
|
|
240
|
-
TokenKind.GreaterThanOperator,
|
|
241
|
-
TokenKind.GreaterThanOrEqualsOperator,
|
|
242
|
-
TokenKind.LessThanOperator,
|
|
243
|
-
TokenKind.LessThanOrEqualsOperator
|
|
244
|
-
].find(kind => this._tokenizer.next(kind))
|
|
245
|
-
}
|
|
246
|
-
return left
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Parse expression with 'isof' or 'cast' method.
|
|
251
|
-
* @param {UriTokenizer.TokenKind} kind token kind
|
|
252
|
-
* @returns {MethodExpression} method expression
|
|
253
|
-
* @private
|
|
254
|
-
*/
|
|
255
|
-
_parseIsOfOrCastMethod (kind) {
|
|
256
|
-
// The TokenKind 'IsOfMethod' consumes also the opening parenthesis.
|
|
257
|
-
// The first parameter could be an expression or a type literal.
|
|
258
|
-
let parameters = [this._parseExpression()]
|
|
259
|
-
|
|
260
|
-
if (!(parameters[0].getKind() === ExpressionKind.TYPE_LITERAL)) {
|
|
261
|
-
// The first parameter is not a type literal, so there must be a second parameter.
|
|
262
|
-
this._tokenizer.requireNext(TokenKind.COMMA)
|
|
263
|
-
parameters.push(this._parseExpression())
|
|
264
|
-
|
|
265
|
-
// The second parameter must be a type literal.
|
|
266
|
-
if (!(parameters[1].getKind() === ExpressionKind.TYPE_LITERAL)) {
|
|
267
|
-
throw new UriQueryOptionSemanticError(
|
|
268
|
-
UriQueryOptionSemanticError.Message.TYPE_LITERAL,
|
|
269
|
-
this._tokenizer.getParseString(),
|
|
270
|
-
this._tokenizer.getPosition()
|
|
271
|
-
)
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
this._tokenizer.requireNext(TokenKind.CLOSE)
|
|
276
|
-
return new MethodExpression(kind, parameters)
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Parse expression with zero or more 'add' or 'sub' operators.
|
|
281
|
-
* @returns {Expression} expression
|
|
282
|
-
* @private
|
|
283
|
-
*/
|
|
284
|
-
_parseExprAdd () {
|
|
285
|
-
let left = this._parseExprMul()
|
|
286
|
-
let operatorTokenKind = [TokenKind.AddOperator, TokenKind.SubOperator].find(kind => this._tokenizer.next(kind))
|
|
287
|
-
|
|
288
|
-
// Null for everything other than ADD or SUB
|
|
289
|
-
while (operatorTokenKind) {
|
|
290
|
-
let right = this._parseExprMul()
|
|
291
|
-
let resultType = this._getAddSubTypeAndCheckLeftAndRight(left, right, operatorTokenKind === TokenKind.SubOperator)
|
|
292
|
-
left = new BinaryExpression(left, tokenToBinaryOperator.get(operatorTokenKind), right, resultType)
|
|
293
|
-
operatorTokenKind = [TokenKind.AddOperator, TokenKind.SubOperator].find(kind => this._tokenizer.next(kind))
|
|
294
|
-
}
|
|
295
|
-
return left
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Parse expression with zero or more 'mul' or 'div' or 'mod' operators.
|
|
300
|
-
* @returns {Expression} expression
|
|
301
|
-
* @private
|
|
302
|
-
*/
|
|
303
|
-
_parseExprMul () {
|
|
304
|
-
let left = this._parseExprUnary()
|
|
305
|
-
let operatorTokenKind = [TokenKind.MulOperator, TokenKind.DivOperator, TokenKind.ModOperator].find(kind =>
|
|
306
|
-
this._tokenizer.next(kind)
|
|
307
|
-
)
|
|
308
|
-
|
|
309
|
-
// Null for everything other than MUL or DIV or MOD
|
|
310
|
-
while (operatorTokenKind) {
|
|
311
|
-
const operatorKind = tokenToBinaryOperator.get(operatorTokenKind)
|
|
312
|
-
let right = this._parseExprUnary()
|
|
313
|
-
let resultType = this._getMulDivModTypeAndCheckLeftAndRight(left, right, operatorKind)
|
|
314
|
-
left = new BinaryExpression(left, operatorKind, right, resultType)
|
|
315
|
-
operatorTokenKind = [TokenKind.MulOperator, TokenKind.DivOperator, TokenKind.ModOperator].find(kind =>
|
|
316
|
-
this._tokenizer.next(kind)
|
|
317
|
-
)
|
|
318
|
-
}
|
|
319
|
-
return left
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Parse expression with zero or more '-' or 'not' operators.
|
|
324
|
-
* @returns {Expression} expression
|
|
325
|
-
* @private
|
|
326
|
-
*/
|
|
327
|
-
_parseExprUnary () {
|
|
328
|
-
if (this._tokenizer.next(TokenKind.MinusOperator)) {
|
|
329
|
-
let expression = this._parseExprPrimary()
|
|
330
|
-
if (this._getType(expression) !== EdmPrimitiveTypeKind.Duration) {
|
|
331
|
-
this.checkNumericType(expression)
|
|
332
|
-
}
|
|
333
|
-
return new UnaryExpression(UnaryOperatorKind.MINUS, expression)
|
|
334
|
-
} else if (this._tokenizer.next(TokenKind.NotOperator)) {
|
|
335
|
-
let expression = this._parseExprPrimary()
|
|
336
|
-
this.checkType(expression, EdmPrimitiveTypeKind.Boolean)
|
|
337
|
-
this.checkNoCollection(expression)
|
|
338
|
-
return new UnaryExpression(UnaryOperatorKind.NOT, expression)
|
|
339
|
-
} else if (this._tokenizer.next(TokenKind.CastMethod)) {
|
|
340
|
-
return this._parseIsOfOrCastMethod(MethodKind.CAST)
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
return this._parseExprPrimary()
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Parse expression with a value and optionally a 'has' operator with its right-hand value.
|
|
348
|
-
* @returns {Expression} expression
|
|
349
|
-
* @private
|
|
350
|
-
*/
|
|
351
|
-
_parseExprPrimary () {
|
|
352
|
-
const left = this._parseExprValue()
|
|
353
|
-
if (
|
|
354
|
-
this._isType(
|
|
355
|
-
this._getType(left),
|
|
356
|
-
EdmPrimitiveTypeKind.Int64,
|
|
357
|
-
EdmPrimitiveTypeKind.Int32,
|
|
358
|
-
EdmPrimitiveTypeKind.Int16,
|
|
359
|
-
EdmPrimitiveTypeKind.Byte,
|
|
360
|
-
EdmPrimitiveTypeKind.SByte
|
|
361
|
-
) &&
|
|
362
|
-
this._tokenizer.next(TokenKind.HasOperator)
|
|
363
|
-
) {
|
|
364
|
-
this._tokenizer.requireNext(TokenKind.EnumValue)
|
|
365
|
-
const right = this._parsePrimitive(TokenKind.EnumValue)
|
|
366
|
-
return new BinaryExpression(left, BinaryOperatorKind.HAS, right, EdmPrimitiveTypeKind.Boolean)
|
|
367
|
-
}
|
|
368
|
-
return left
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Parse expression with a value.
|
|
373
|
-
* @returns {Expression} expression
|
|
374
|
-
* @private
|
|
375
|
-
*/
|
|
376
|
-
_parseExprValue () {
|
|
377
|
-
if (this._tokenizer.next(TokenKind.OPEN)) {
|
|
378
|
-
this._tokenizer._nextWhitespace()
|
|
379
|
-
const expression = this._parseExpression()
|
|
380
|
-
this._tokenizer._nextWhitespace()
|
|
381
|
-
this._tokenizer.requireNext(TokenKind.CLOSE)
|
|
382
|
-
return expression
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if (this._tokenizer.next(TokenKind.ParameterAliasName)) {
|
|
386
|
-
const name = this._tokenizer.getText()
|
|
387
|
-
if (this._aliases && this._aliases[name]) {
|
|
388
|
-
return new AliasExpression(name, this.parseAlias(name, null, this._aliases))
|
|
389
|
-
}
|
|
390
|
-
throw new UriSyntaxError(UriSyntaxError.Message.ALIAS_NOT_FOUND, name)
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if (this._tokenizer.next(TokenKind.jsonArrayOrObject)) {
|
|
394
|
-
// There is no obvious way how the type could be determined from the JSON literal.
|
|
395
|
-
return new LiteralExpression(this._tokenizer.getText(), undefined)
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
let firstTokenKind = [TokenKind.ROOT, TokenKind.IT].find(kind => this._tokenizer.next(kind))
|
|
399
|
-
if (firstTokenKind) return this._parseFirstMemberExpr(firstTokenKind)
|
|
400
|
-
|
|
401
|
-
// Parse primitive values, but defer values that could be mistaken for identifiers.
|
|
402
|
-
const nextPrimitive = this._nextPrimitiveValue(this._tokenizer)
|
|
403
|
-
if (nextPrimitive) return this._parsePrimitive(nextPrimitive)
|
|
404
|
-
|
|
405
|
-
const nextMethod = Array.from(tokenToMethod.keys()).find(kind => this._tokenizer.next(kind))
|
|
406
|
-
if (nextMethod) {
|
|
407
|
-
// The method token text includes the opening parenthesis so that method calls can be recognized
|
|
408
|
-
// unambiguously. OData identifiers have to be considered after that.
|
|
409
|
-
const methodKind = tokenToMethod.get(nextMethod)
|
|
410
|
-
return new MethodExpression(methodKind, this._parseMethodParameters(methodKind))
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
if (this._tokenizer.next(TokenKind.QualifiedName)) return this._parseFirstMemberExpr(TokenKind.QualifiedName)
|
|
414
|
-
if (this._tokenizer.next(TokenKind.ODataIdentifier)) {
|
|
415
|
-
const text = this._tokenizer.getText()
|
|
416
|
-
if (text === 'null') return this._parsePrimitive(TokenKind.NULL)
|
|
417
|
-
if (text === 'true' || text === 'false') return this._parsePrimitive(TokenKind.BooleanValue)
|
|
418
|
-
if (text === 'NaN' || text === 'INF') return this._parsePrimitive(TokenKind.DoubleValue)
|
|
419
|
-
return this._parseFirstMemberExpr(TokenKind.ODataIdentifier)
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// Deferred parsing of primitive values (see above).
|
|
423
|
-
firstTokenKind = [TokenKind.DoubleValue, TokenKind.DecimalValue, TokenKind.IntegerValue].find(kind =>
|
|
424
|
-
this._tokenizer.next(kind)
|
|
425
|
-
)
|
|
426
|
-
if (firstTokenKind) return this._parsePrimitive(firstTokenKind)
|
|
427
|
-
|
|
428
|
-
throw new UriSyntaxError(
|
|
429
|
-
UriSyntaxError.Message.TOKEN_KINDS_EXPECTED,
|
|
430
|
-
[TokenKind.QualifiedName, TokenKind.ODataIdentifier].join(', '),
|
|
431
|
-
this._tokenizer.getParseString(),
|
|
432
|
-
this._tokenizer.getPosition()
|
|
433
|
-
)
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Advance the tokenizer past a primitive value.
|
|
438
|
-
* @param {UriTokenizer} tokenizer tokenizer
|
|
439
|
-
* @returns {?UriTokenizer.TokenKind} the token kind of the primitive value
|
|
440
|
-
* @private
|
|
441
|
-
*/
|
|
442
|
-
_nextPrimitiveValue (tokenizer) {
|
|
443
|
-
// Some token kinds have been removed from this list because the values could be
|
|
444
|
-
// misinterpreted as identifiers (see above).
|
|
445
|
-
const tokenKind = [
|
|
446
|
-
TokenKind.StringValue,
|
|
447
|
-
|
|
448
|
-
// The order of the next seven expressions is important in order to avoid
|
|
449
|
-
// finding partly parsed tokens (counter-intuitive as it may be, even a GUID may start with digits ...).
|
|
450
|
-
TokenKind.GuidValue,
|
|
451
|
-
TokenKind.DateTimeOffsetValue,
|
|
452
|
-
TokenKind.DateValue,
|
|
453
|
-
TokenKind.TimeOfDayValue,
|
|
454
|
-
|
|
455
|
-
TokenKind.DurationValue,
|
|
456
|
-
TokenKind.BinaryValue,
|
|
457
|
-
TokenKind.EnumValue,
|
|
458
|
-
|
|
459
|
-
// Geography and geometry literals are defined to be primitive,
|
|
460
|
-
// although they contain several parts with their own meaning.
|
|
461
|
-
TokenKind.GeographyPoint,
|
|
462
|
-
TokenKind.GeometryPoint,
|
|
463
|
-
TokenKind.GeographyLineString,
|
|
464
|
-
TokenKind.GeometryLineString,
|
|
465
|
-
TokenKind.GeographyPolygon,
|
|
466
|
-
TokenKind.GeometryPolygon,
|
|
467
|
-
TokenKind.GeographyMultiPoint,
|
|
468
|
-
TokenKind.GeometryMultiPoint,
|
|
469
|
-
TokenKind.GeographyMultiLineString,
|
|
470
|
-
TokenKind.GeometryMultiLineString,
|
|
471
|
-
TokenKind.GeographyMultiPolygon,
|
|
472
|
-
TokenKind.GeometryMultiPolygon,
|
|
473
|
-
TokenKind.GeographyCollection,
|
|
474
|
-
TokenKind.GeometryCollection
|
|
475
|
-
].find(kind => tokenizer.next(kind))
|
|
476
|
-
|
|
477
|
-
return tokenKind
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
/**
|
|
481
|
-
* Parse an alias value.
|
|
482
|
-
* @param {string} alias alias name
|
|
483
|
-
* @param {EdmType} edmType expected EDM type
|
|
484
|
-
* @param {Object} aliases alias definitions
|
|
485
|
-
* @returns {Expression} parsed expression
|
|
486
|
-
* @package
|
|
487
|
-
*/
|
|
488
|
-
parseAlias (alias, edmType, aliases) {
|
|
489
|
-
const value = aliases[alias]
|
|
490
|
-
if (!value) {
|
|
491
|
-
throw new UriSyntaxError(UriSyntaxError.Message.ALIAS_NOT_FOUND, alias)
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
let newAliases = Object.assign({}, aliases)
|
|
495
|
-
delete newAliases[alias]
|
|
496
|
-
let newTokenizer = new UriTokenizer(value)
|
|
497
|
-
let expression = null
|
|
498
|
-
try {
|
|
499
|
-
expression = new ExpressionParser(this._edm).parse(
|
|
500
|
-
newTokenizer,
|
|
501
|
-
this._referringType,
|
|
502
|
-
this._crossjoinEntitySets,
|
|
503
|
-
newAliases
|
|
504
|
-
)
|
|
505
|
-
} catch (e) {
|
|
506
|
-
throw new (e.name === ErrorNames.URI_QUERY_OPTION_SEMANTIC ? UriQueryOptionSemanticError : UriSyntaxError)(
|
|
507
|
-
UriSyntaxError.Message.WRONG_ALIAS_VALUE,
|
|
508
|
-
alias
|
|
509
|
-
).setRootCause(e)
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
const type = this._getType(expression)
|
|
513
|
-
if (!newTokenizer.next(TokenKind.EOF)) {
|
|
514
|
-
throw new UriSyntaxError(UriSyntaxError.Message.WRONG_ALIAS_VALUE, alias)
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
if (type !== null && !this.isCompatible(edmType, type)) {
|
|
518
|
-
throw new UriQueryOptionSemanticError(
|
|
519
|
-
UriSemanticError.Message.INCOMPATIBLE_TYPE,
|
|
520
|
-
type.getFullQualifiedName().toString(),
|
|
521
|
-
edmType.getFullQualifiedName().toString()
|
|
522
|
-
)
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
return expression
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
* Parse expression with a primitive literal.
|
|
530
|
-
* @param {UriTokenizer.TokenKind} primitiveTokenKind token kind
|
|
531
|
-
* @returns {LiteralExpression} literal expression
|
|
532
|
-
* @private
|
|
533
|
-
*/
|
|
534
|
-
_parsePrimitive (primitiveTokenKind) {
|
|
535
|
-
const primitiveValueLiteral = this._tokenizer.getText()
|
|
536
|
-
|
|
537
|
-
if (primitiveTokenKind === TokenKind.NULL) return new LiteralExpression(null, null)
|
|
538
|
-
|
|
539
|
-
let type = tokenToPrimitiveType.get(primitiveTokenKind)
|
|
540
|
-
if (type === EdmPrimitiveTypeKind.Int64) type = this._determineIntegerType(primitiveValueLiteral)
|
|
541
|
-
|
|
542
|
-
if (primitiveTokenKind === TokenKind.EnumValue) {
|
|
543
|
-
const typeName = primitiveValueLiteral.substring(0, primitiveValueLiteral.indexOf("'"))
|
|
544
|
-
type = this._edm.getEnumType(FullQualifiedName.createFromNameSpaceAndName(typeName))
|
|
545
|
-
if (!type) {
|
|
546
|
-
throw new UriQueryOptionSemanticError(UriQueryOptionSemanticError.Message.ENUM_TYPE_NOT_FOUND, typeName)
|
|
547
|
-
}
|
|
548
|
-
// Only pre-defined values (and their combinations, for flags) are allowed.
|
|
549
|
-
const literalValue = primitiveValueLiteral.substring(typeName.length + 1, primitiveValueLiteral.length - 1)
|
|
550
|
-
let enumValue = null
|
|
551
|
-
for (const value of literalValue.split(',')) {
|
|
552
|
-
let memberValue = null
|
|
553
|
-
for (const [name, member] of type.getMembers()) {
|
|
554
|
-
if (value === name || value === member.getValue().toString()) {
|
|
555
|
-
memberValue = member.getValue()
|
|
556
|
-
break
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
if (memberValue === null || (enumValue !== null && !type.isFlags())) {
|
|
560
|
-
throw new UriQueryOptionSemanticError(UriSemanticError.Message.WRONG_VALUE, typeName, literalValue)
|
|
561
|
-
}
|
|
562
|
-
enumValue = enumValue === null ? memberValue : enumValue | memberValue
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
return new LiteralExpression(UriHelper.fromUriLiteral(primitiveValueLiteral, type), type)
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
/**
|
|
570
|
-
* Determines the EDM type of a whole number given as string literal.
|
|
571
|
-
* @param {string} intValueAsString the number as string
|
|
572
|
-
* @returns {EdmPrimitiveType} EDM primitive type
|
|
573
|
-
* @private
|
|
574
|
-
*/
|
|
575
|
-
_determineIntegerType (intValueAsString) {
|
|
576
|
-
// To check the value range, we convert the input string to a Javascript number.
|
|
577
|
-
// For numbers with an absolute value larger than 2^53 - 1
|
|
578
|
-
// (outside the "safe" number range in Javascript),
|
|
579
|
-
// the resulting number is changed to another number in the safe range.
|
|
580
|
-
// This is not relevant here because the resulting number is still of the same OData type.
|
|
581
|
-
const value = Number(intValueAsString)
|
|
582
|
-
if (valueValidator.isSByte(value)) return EdmPrimitiveTypeKind.SByte
|
|
583
|
-
if (valueValidator.isByte(value)) return EdmPrimitiveTypeKind.Byte
|
|
584
|
-
if (valueValidator.isInt16(value)) return EdmPrimitiveTypeKind.Int16
|
|
585
|
-
if (valueValidator.isInt32(value)) return EdmPrimitiveTypeKind.Int32
|
|
586
|
-
if (valueValidator.isInt64(intValueAsString)) return EdmPrimitiveTypeKind.Int64
|
|
587
|
-
// The number cannot be formatted wrongly because the tokenizer already checked the format
|
|
588
|
-
// but it is too large for Edm.Int64.
|
|
589
|
-
return EdmPrimitiveTypeKind.Decimal
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
/**
|
|
593
|
-
* Parse method parameters.
|
|
594
|
-
* @param {MethodKind} methodKind method
|
|
595
|
-
* @returns {Expression[]} parameters
|
|
596
|
-
* @private
|
|
597
|
-
*/
|
|
598
|
-
_parseMethodParameters (methodKind) {
|
|
599
|
-
let parameters = []
|
|
600
|
-
switch (methodKind) {
|
|
601
|
-
// Must have no parameter.
|
|
602
|
-
case MethodKind.NOW:
|
|
603
|
-
case MethodKind.MAXDATETIME:
|
|
604
|
-
case MethodKind.MINDATETIME:
|
|
605
|
-
break
|
|
606
|
-
|
|
607
|
-
// Must have one parameter.
|
|
608
|
-
case MethodKind.LENGTH:
|
|
609
|
-
case MethodKind.TOLOWER:
|
|
610
|
-
case MethodKind.TOUPPER:
|
|
611
|
-
case MethodKind.TRIM:
|
|
612
|
-
{
|
|
613
|
-
const stringParameter = this._parseExpression()
|
|
614
|
-
this.checkType(stringParameter, EdmPrimitiveTypeKind.String)
|
|
615
|
-
this.checkNoCollection(stringParameter)
|
|
616
|
-
parameters.push(stringParameter)
|
|
617
|
-
}
|
|
618
|
-
break
|
|
619
|
-
case MethodKind.YEAR:
|
|
620
|
-
case MethodKind.MONTH:
|
|
621
|
-
case MethodKind.DAY:
|
|
622
|
-
{
|
|
623
|
-
const dateParameter = this._parseExpression()
|
|
624
|
-
this.checkType(dateParameter, EdmPrimitiveTypeKind.Date, EdmPrimitiveTypeKind.DateTimeOffset)
|
|
625
|
-
this.checkNoCollection(dateParameter)
|
|
626
|
-
parameters.push(dateParameter)
|
|
627
|
-
}
|
|
628
|
-
break
|
|
629
|
-
case MethodKind.HOUR:
|
|
630
|
-
case MethodKind.MINUTE:
|
|
631
|
-
case MethodKind.SECOND:
|
|
632
|
-
case MethodKind.FRACTIONALSECONDS:
|
|
633
|
-
{
|
|
634
|
-
const timeParameter = this._parseExpression()
|
|
635
|
-
this.checkType(timeParameter, EdmPrimitiveTypeKind.TimeOfDay, EdmPrimitiveTypeKind.DateTimeOffset)
|
|
636
|
-
this.checkNoCollection(timeParameter)
|
|
637
|
-
parameters.push(timeParameter)
|
|
638
|
-
}
|
|
639
|
-
break
|
|
640
|
-
case MethodKind.DATE:
|
|
641
|
-
case MethodKind.TIME:
|
|
642
|
-
case MethodKind.TOTALOFFSETMINUTES:
|
|
643
|
-
{
|
|
644
|
-
const dateTimeParameter = this._parseExpression()
|
|
645
|
-
this.checkType(dateTimeParameter, EdmPrimitiveTypeKind.DateTimeOffset)
|
|
646
|
-
this.checkNoCollection(dateTimeParameter)
|
|
647
|
-
parameters.push(dateTimeParameter)
|
|
648
|
-
}
|
|
649
|
-
break
|
|
650
|
-
case MethodKind.TOTALSECONDS:
|
|
651
|
-
{
|
|
652
|
-
const durationParameter = this._parseExpression()
|
|
653
|
-
this.checkType(durationParameter, EdmPrimitiveTypeKind.Duration)
|
|
654
|
-
this.checkNoCollection(durationParameter)
|
|
655
|
-
parameters.push(durationParameter)
|
|
656
|
-
}
|
|
657
|
-
break
|
|
658
|
-
case MethodKind.ROUND:
|
|
659
|
-
case MethodKind.FLOOR:
|
|
660
|
-
case MethodKind.CEILING:
|
|
661
|
-
{
|
|
662
|
-
const decimalParameter = this._parseExpression()
|
|
663
|
-
this.checkType(
|
|
664
|
-
decimalParameter,
|
|
665
|
-
EdmPrimitiveTypeKind.Decimal,
|
|
666
|
-
EdmPrimitiveTypeKind.Single,
|
|
667
|
-
EdmPrimitiveTypeKind.Double
|
|
668
|
-
)
|
|
669
|
-
this.checkNoCollection(decimalParameter)
|
|
670
|
-
parameters.push(decimalParameter)
|
|
671
|
-
}
|
|
672
|
-
break
|
|
673
|
-
case MethodKind.GEOLENGTH:
|
|
674
|
-
{
|
|
675
|
-
const geoParameter = this._parseExpression()
|
|
676
|
-
this.checkType(
|
|
677
|
-
geoParameter,
|
|
678
|
-
EdmPrimitiveTypeKind.GeographyLineString,
|
|
679
|
-
EdmPrimitiveTypeKind.GeometryLineString
|
|
680
|
-
)
|
|
681
|
-
this.checkNoCollection(geoParameter)
|
|
682
|
-
parameters.push(geoParameter)
|
|
683
|
-
}
|
|
684
|
-
break
|
|
685
|
-
|
|
686
|
-
// Must have two parameters.
|
|
687
|
-
case MethodKind.CONTAINS:
|
|
688
|
-
case MethodKind.ENDSWITH:
|
|
689
|
-
case MethodKind.STARTSWITH:
|
|
690
|
-
case MethodKind.INDEXOF:
|
|
691
|
-
case MethodKind.CONCAT:
|
|
692
|
-
{
|
|
693
|
-
const parameter1 = this._parseExpression()
|
|
694
|
-
this.checkType(parameter1, EdmPrimitiveTypeKind.String)
|
|
695
|
-
const isCollection = methodKind === MethodKind.CONTAINS && parameter1.getPathSegments && parameter1.getPathSegments()[parameter1.getPathSegments().length - 1].getKind() === 'PRIMITIVE.COLLECTION.PROPERTY'
|
|
696
|
-
parameters.push(parameter1)
|
|
697
|
-
this._tokenizer.requireNext(TokenKind.COMMA)
|
|
698
|
-
const parameter2 = this._parseExpression()
|
|
699
|
-
if (!isCollection) {
|
|
700
|
-
this.checkType(parameter2, EdmPrimitiveTypeKind.String)
|
|
701
|
-
this.checkNoCollection(parameter2)
|
|
702
|
-
}
|
|
703
|
-
parameters.push(parameter2)
|
|
704
|
-
}
|
|
705
|
-
break
|
|
706
|
-
case MethodKind.GEODISTANCE:
|
|
707
|
-
{
|
|
708
|
-
const geoParameter1 = this._parseExpression()
|
|
709
|
-
this.checkType(geoParameter1, EdmPrimitiveTypeKind.GeographyPoint, EdmPrimitiveTypeKind.GeometryPoint)
|
|
710
|
-
this.checkNoCollection(geoParameter1)
|
|
711
|
-
parameters.push(geoParameter1)
|
|
712
|
-
this._tokenizer.requireNext(TokenKind.COMMA)
|
|
713
|
-
const geoParameter2 = this._parseExpression()
|
|
714
|
-
this.checkType(geoParameter2, this._getType(geoParameter1))
|
|
715
|
-
this.checkNoCollection(geoParameter2)
|
|
716
|
-
parameters.push(geoParameter2)
|
|
717
|
-
}
|
|
718
|
-
break
|
|
719
|
-
case MethodKind.GEOINTERSECTS:
|
|
720
|
-
{
|
|
721
|
-
const geoPointParameter = this._parseExpression()
|
|
722
|
-
this.checkType(geoPointParameter, EdmPrimitiveTypeKind.GeographyPoint, EdmPrimitiveTypeKind.GeometryPoint)
|
|
723
|
-
this.checkNoCollection(geoPointParameter)
|
|
724
|
-
parameters.push(geoPointParameter)
|
|
725
|
-
this._tokenizer.requireNext(TokenKind.COMMA)
|
|
726
|
-
const geoPolygonParameter = this._parseExpression()
|
|
727
|
-
this.checkType(
|
|
728
|
-
geoPolygonParameter,
|
|
729
|
-
this._getType(geoPointParameter) === EdmPrimitiveTypeKind.GeographyPoint
|
|
730
|
-
? EdmPrimitiveTypeKind.GeographyPolygon
|
|
731
|
-
: EdmPrimitiveTypeKind.GeometryPolygon
|
|
732
|
-
)
|
|
733
|
-
this.checkNoCollection(geoPolygonParameter)
|
|
734
|
-
parameters.push(geoPolygonParameter)
|
|
735
|
-
}
|
|
736
|
-
break
|
|
737
|
-
|
|
738
|
-
// Can have two or three parameters.
|
|
739
|
-
case MethodKind.SUBSTRING:
|
|
740
|
-
{
|
|
741
|
-
const parameterFirst = this._parseExpression()
|
|
742
|
-
this.checkType(parameterFirst, EdmPrimitiveTypeKind.String)
|
|
743
|
-
this.checkNoCollection(parameterFirst)
|
|
744
|
-
parameters.push(parameterFirst)
|
|
745
|
-
this._tokenizer.requireNext(TokenKind.COMMA)
|
|
746
|
-
const parameterSecond = this._parseExpression()
|
|
747
|
-
this.checkIntegerType(parameterSecond)
|
|
748
|
-
parameters.push(parameterSecond)
|
|
749
|
-
if (this._tokenizer.next(TokenKind.COMMA)) {
|
|
750
|
-
const parameterThird = this._parseExpression()
|
|
751
|
-
this.checkIntegerType(parameterThird)
|
|
752
|
-
parameters.push(parameterThird)
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
break
|
|
756
|
-
|
|
757
|
-
// Can have one or two parameters. These methods are handled elsewhere.
|
|
758
|
-
case MethodKind.CAST:
|
|
759
|
-
case MethodKind.ISOF:
|
|
760
|
-
break
|
|
761
|
-
|
|
762
|
-
default:
|
|
763
|
-
break
|
|
764
|
-
}
|
|
765
|
-
this._tokenizer.requireNext(TokenKind.CLOSE)
|
|
766
|
-
return parameters
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
/**
|
|
770
|
-
* Parse member expression at start.
|
|
771
|
-
* @param {UriTokenizer.TokenKind} lastTokenKind token kind
|
|
772
|
-
* @returns {Expression} expression
|
|
773
|
-
* @private
|
|
774
|
-
*/
|
|
775
|
-
_parseFirstMemberExpr (lastTokenKind) {
|
|
776
|
-
let pathSegments = []
|
|
777
|
-
|
|
778
|
-
if (lastTokenKind === TokenKind.ROOT) {
|
|
779
|
-
this._parseDollarRoot(pathSegments)
|
|
780
|
-
} else if (lastTokenKind === TokenKind.IT) {
|
|
781
|
-
this._parseDollarIt(pathSegments, this._referringType)
|
|
782
|
-
} else if (lastTokenKind === TokenKind.QualifiedName) {
|
|
783
|
-
// Special handling for leading type casts and type literals
|
|
784
|
-
const fullQualifiedName = FullQualifiedName.createFromNameSpaceAndName(this._tokenizer.getText())
|
|
785
|
-
const castType =
|
|
786
|
-
this._edm.getEntityType(fullQualifiedName) ||
|
|
787
|
-
this._edm.getComplexType(fullQualifiedName) ||
|
|
788
|
-
this._getPrimitiveType(fullQualifiedName) ||
|
|
789
|
-
this._edm.getTypeDefinition(fullQualifiedName) ||
|
|
790
|
-
this._edm.getEnumType(fullQualifiedName)
|
|
791
|
-
|
|
792
|
-
if (castType) {
|
|
793
|
-
if (this._tokenizer.next(TokenKind.SLASH)) {
|
|
794
|
-
// Leading type cast
|
|
795
|
-
this._checkStructuredTypeCast(this._referringType, castType)
|
|
796
|
-
const castResource = new UriResource().setKind(ResourceKind.TYPE_CAST).setTypeCast(castType)
|
|
797
|
-
pathSegments.push(castResource)
|
|
798
|
-
|
|
799
|
-
const tokenKind = [TokenKind.QualifiedName, TokenKind.ODataIdentifier].find(kind =>
|
|
800
|
-
this._tokenizer.next(kind)
|
|
801
|
-
)
|
|
802
|
-
|
|
803
|
-
this._parseMemberExpression(tokenKind, pathSegments, castResource, false)
|
|
804
|
-
} else {
|
|
805
|
-
// Type literal
|
|
806
|
-
return new TypeLiteralExpression(castType)
|
|
807
|
-
}
|
|
808
|
-
} else {
|
|
809
|
-
// Must be bound or unbound function.
|
|
810
|
-
this._parseFunction(fullQualifiedName, pathSegments, this._referringType, false, true)
|
|
811
|
-
}
|
|
812
|
-
} else {
|
|
813
|
-
// Must be TokenKind.ODataIdentifier (see callers).
|
|
814
|
-
this._parseFirstMemberODataIdentifier(pathSegments)
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
return new MemberExpression(pathSegments)
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
/**
|
|
821
|
-
* Get primitive type from full-qualified name.
|
|
822
|
-
* @param {FullQualifiedName} fullQualifiedName full-qualified name
|
|
823
|
-
* @returns {?EdmPrimitiveType} primitive type or null if nothing found
|
|
824
|
-
* @private
|
|
825
|
-
*/
|
|
826
|
-
_getPrimitiveType (fullQualifiedName) {
|
|
827
|
-
return EdmPrimitiveType.EDM_NAMESPACE === fullQualifiedName.namespace
|
|
828
|
-
? EdmPrimitiveTypeKind.fromName(fullQualifiedName.name)
|
|
829
|
-
: null
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
/**
|
|
833
|
-
* Parse key predicates.
|
|
834
|
-
* @param {UriResource} resource current resource
|
|
835
|
-
* @param {EdmEntityType} type entity type for which the keys are parsed
|
|
836
|
-
* @returns {UriParameter[]} key predicates
|
|
837
|
-
* @private
|
|
838
|
-
*/
|
|
839
|
-
_parseKeyPredicates (resource, type) {
|
|
840
|
-
try {
|
|
841
|
-
return new KeyPredicateParser(this._edm, this._aliases).parse(resource, type, this._tokenizer)
|
|
842
|
-
} catch (err) {
|
|
843
|
-
throw err.name === ErrorNames.URI_SEMANTIC ? new UriQueryOptionSemanticError(err.message).setRootCause(err) : err
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
/**
|
|
848
|
-
* Parse $root expression.
|
|
849
|
-
* @param {UriResource[]} pathSegments path segments where parsed information is added
|
|
850
|
-
* @private
|
|
851
|
-
*/
|
|
852
|
-
_parseDollarRoot (pathSegments) {
|
|
853
|
-
pathSegments.push(new UriResource().setKind(ResourceKind.ROOT_EXPRESSION))
|
|
854
|
-
this._tokenizer.requireNext(TokenKind.SLASH)
|
|
855
|
-
this._tokenizer.requireNext(TokenKind.ODataIdentifier)
|
|
856
|
-
const name = this._tokenizer.getText()
|
|
857
|
-
let resource = new UriResource()
|
|
858
|
-
const entitySet = this._edm.getEntityContainer().getEntitySet(name)
|
|
859
|
-
if (entitySet) {
|
|
860
|
-
resource.setKind(ResourceKind.ENTITY).setEntitySet(entitySet)
|
|
861
|
-
this._tokenizer.requireNext(TokenKind.OPEN)
|
|
862
|
-
const keyPredicates = this._parseKeyPredicates(resource, entitySet.getEntityType())
|
|
863
|
-
this._tokenizer.requireNext(TokenKind.CLOSE)
|
|
864
|
-
resource.setKeyPredicates(keyPredicates)
|
|
865
|
-
} else {
|
|
866
|
-
const singleton = this._edm.getEntityContainer().getSingleton(name)
|
|
867
|
-
if (!singleton) {
|
|
868
|
-
throw new UriQueryOptionSemanticError(
|
|
869
|
-
UriQueryOptionSemanticError.Message.ENTITY_SET_OR_SINGLETON_NOT_FOUND,
|
|
870
|
-
name
|
|
871
|
-
)
|
|
872
|
-
}
|
|
873
|
-
resource.setKind(ResourceKind.SINGLETON).setSingleton(singleton)
|
|
874
|
-
}
|
|
875
|
-
pathSegments.push(resource)
|
|
876
|
-
this._parseSingleNavigationExpr(pathSegments, resource)
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
/**
|
|
880
|
-
* Parse $it expression.
|
|
881
|
-
* @param {UriResource[]} pathSegments path segments where parsed information is added
|
|
882
|
-
* @param {EdmType} referringType referring type
|
|
883
|
-
* @private
|
|
884
|
-
*/
|
|
885
|
-
_parseDollarIt (pathSegments, referringType) {
|
|
886
|
-
let itResource = new UriResource().setKind(ResourceKind.IT_EXPRESSION).setExpressionVariableEdmType(referringType)
|
|
887
|
-
pathSegments.push(itResource)
|
|
888
|
-
if (this._tokenizer.next(TokenKind.SLASH)) {
|
|
889
|
-
const tokenKind = [TokenKind.QualifiedName, TokenKind.ODataIdentifier].find(kind => this._tokenizer.next(kind))
|
|
890
|
-
this._parseMemberExpression(tokenKind, pathSegments, itResource, true)
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
/**
|
|
895
|
-
* Parse member expression at start with an OData identifier.
|
|
896
|
-
* @param {UriResource[]} pathSegments path segments where parsed information is added
|
|
897
|
-
* @private
|
|
898
|
-
*/
|
|
899
|
-
_parseFirstMemberODataIdentifier (pathSegments) {
|
|
900
|
-
const name = this._tokenizer.getText()
|
|
901
|
-
|
|
902
|
-
// For a crossjoin, the identifier must be an entity-set name.
|
|
903
|
-
if (this._crossjoinEntitySets && this._crossjoinEntitySets.length > 0) {
|
|
904
|
-
const crossjoinEntitySet = this._crossjoinEntitySets.find(entitySet => entitySet.getName() === name)
|
|
905
|
-
if (crossjoinEntitySet) {
|
|
906
|
-
let resource = new UriResource().setKind(ResourceKind.ENTITY_COLLECTION).setEntitySet(crossjoinEntitySet)
|
|
907
|
-
pathSegments.push(resource)
|
|
908
|
-
if (this._tokenizer.next(TokenKind.SLASH)) {
|
|
909
|
-
const tokenKind = [TokenKind.QualifiedName, TokenKind.ODataIdentifier].find(kind =>
|
|
910
|
-
this._tokenizer.next(kind)
|
|
911
|
-
)
|
|
912
|
-
this._parseMemberExpression(tokenKind, pathSegments, resource, true)
|
|
913
|
-
}
|
|
914
|
-
return
|
|
915
|
-
}
|
|
916
|
-
throw new UriQueryOptionSemanticError(UriSemanticError.Message.ENTITY_SET_NOT_FOUND, name)
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
// Check if the OData identifier is a lambda variable, otherwise it must be a property.
|
|
920
|
-
const lambdaVariable = this._lambdaVariables.find(variable => variable.getExpressionVariableName() === name)
|
|
921
|
-
if (lambdaVariable) {
|
|
922
|
-
pathSegments.push(lambdaVariable)
|
|
923
|
-
if (this._tokenizer.next(TokenKind.SLASH)) {
|
|
924
|
-
const tokenKind = [TokenKind.QualifiedName, TokenKind.ODataIdentifier].find(kind => this._tokenizer.next(kind))
|
|
925
|
-
this._parseMemberExpression(tokenKind, pathSegments, lambdaVariable, true)
|
|
926
|
-
}
|
|
927
|
-
} else {
|
|
928
|
-
// Must be a property.
|
|
929
|
-
this._parseMemberExpression(TokenKind.ODataIdentifier, pathSegments, null, true)
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
/**
|
|
934
|
-
* Parse member expression.
|
|
935
|
-
* @param {UriTokenizer.TokenKind} lastTokenKind last token kind
|
|
936
|
-
* @param {UriResource[]} pathSegments path segments where parsed information is added
|
|
937
|
-
* @param {UriResource} lastResource last resource
|
|
938
|
-
* @param {boolean} allowTypeCast whether a type cast is allowed
|
|
939
|
-
* @private
|
|
940
|
-
*/
|
|
941
|
-
_parseMemberExpression (lastTokenKind, pathSegments, lastResource, allowTypeCast) {
|
|
942
|
-
if (lastTokenKind === TokenKind.QualifiedName) {
|
|
943
|
-
// Type cast or bound function
|
|
944
|
-
const fullQualifiedName = FullQualifiedName.createFromNameSpaceAndName(this._tokenizer.getText())
|
|
945
|
-
const edmEntityType = this._edm.getEntityType(fullQualifiedName)
|
|
946
|
-
|
|
947
|
-
if (edmEntityType) {
|
|
948
|
-
if (allowTypeCast) {
|
|
949
|
-
this._checkStructuredTypeCast(lastResource.getEdmType(), edmEntityType)
|
|
950
|
-
const castResource = new UriResource()
|
|
951
|
-
.setKind(ResourceKind.TYPE_CAST)
|
|
952
|
-
.setTypeCast(edmEntityType)
|
|
953
|
-
.setIsCollection(lastResource.isCollection())
|
|
954
|
-
pathSegments.push(castResource)
|
|
955
|
-
|
|
956
|
-
if (this._tokenizer.next(TokenKind.SLASH)) {
|
|
957
|
-
if (this._tokenizer.next(TokenKind.QualifiedName)) {
|
|
958
|
-
this._parseFunction(
|
|
959
|
-
FullQualifiedName.createFromNameSpaceAndName(this._tokenizer.getText()),
|
|
960
|
-
pathSegments,
|
|
961
|
-
edmEntityType,
|
|
962
|
-
castResource.isCollection(),
|
|
963
|
-
false
|
|
964
|
-
)
|
|
965
|
-
} else if (this._tokenizer.next(TokenKind.ODataIdentifier)) {
|
|
966
|
-
this._parsePropertyPathExpr(pathSegments, castResource)
|
|
967
|
-
} else {
|
|
968
|
-
throw new UriSyntaxError(
|
|
969
|
-
UriSyntaxError.Message.TOKEN_KINDS_EXPECTED,
|
|
970
|
-
[TokenKind.QualifiedName, TokenKind.ODataIdentifier].join(', '),
|
|
971
|
-
this._tokenizer.getParseString(),
|
|
972
|
-
this._tokenizer.getPosition()
|
|
973
|
-
)
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
} else {
|
|
977
|
-
throw new UriQueryOptionSemanticError(
|
|
978
|
-
UriQueryOptionSemanticError.Message.TYPE_CAST_NOT_CHAINABLE,
|
|
979
|
-
fullQualifiedName.toString(),
|
|
980
|
-
lastResource
|
|
981
|
-
.getEdmType()
|
|
982
|
-
.getFullQualifiedName()
|
|
983
|
-
.toString()
|
|
984
|
-
)
|
|
985
|
-
}
|
|
986
|
-
} else {
|
|
987
|
-
this._parseFunction(
|
|
988
|
-
fullQualifiedName,
|
|
989
|
-
pathSegments,
|
|
990
|
-
lastResource.getEdmType(),
|
|
991
|
-
lastResource.isCollection(),
|
|
992
|
-
false
|
|
993
|
-
)
|
|
994
|
-
}
|
|
995
|
-
} else {
|
|
996
|
-
// TokenKind.ODataIdentifier
|
|
997
|
-
this._parsePropertyPathExpr(pathSegments, lastResource)
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
/**
|
|
1002
|
-
* Parse property-path expression.
|
|
1003
|
-
* @param {UriResource[]} pathSegments path segments where parsed information is added
|
|
1004
|
-
* @param {UriResource} lastResource last resource
|
|
1005
|
-
* @private
|
|
1006
|
-
*/
|
|
1007
|
-
_parsePropertyPathExpr (pathSegments, lastResource) {
|
|
1008
|
-
const identifier = this._tokenizer.getText()
|
|
1009
|
-
|
|
1010
|
-
const lastType = lastResource ? lastResource.getEdmType() : this._referringType
|
|
1011
|
-
|
|
1012
|
-
if (lastType.getKind() !== EdmTypeKind.COMPLEX && lastType.getKind() !== EdmTypeKind.ENTITY) {
|
|
1013
|
-
throw new UriQueryOptionSemanticError(
|
|
1014
|
-
UriQueryOptionSemanticError.Message.PROPERTY_MUST_FOLLOW_STRUCTURED_TYPE,
|
|
1015
|
-
identifier
|
|
1016
|
-
)
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
const property =
|
|
1020
|
-
lastType.getStructuralProperty(identifier) ||
|
|
1021
|
-
(lastType.getIgnoredProperties && lastType.getIgnoredProperties().get(identifier))
|
|
1022
|
-
if (property) {
|
|
1023
|
-
const isCollection = property.isCollection()
|
|
1024
|
-
let propertyResource = new UriResource().setProperty(property).setIsCollection(isCollection)
|
|
1025
|
-
pathSegments.push(propertyResource)
|
|
1026
|
-
if (property.getType().getKind() === EdmTypeKind.COMPLEX) {
|
|
1027
|
-
if (isCollection) {
|
|
1028
|
-
propertyResource.setKind(ResourceKind.COMPLEX_COLLECTION_PROPERTY)
|
|
1029
|
-
this._parseComplexCollectionPathExpr(pathSegments, propertyResource)
|
|
1030
|
-
} else {
|
|
1031
|
-
propertyResource.setKind(ResourceKind.COMPLEX_PROPERTY)
|
|
1032
|
-
this._parseComplexPathExpr(pathSegments, propertyResource)
|
|
1033
|
-
}
|
|
1034
|
-
} else {
|
|
1035
|
-
// Primitive or type-definition type
|
|
1036
|
-
if (isCollection) {
|
|
1037
|
-
// eslint-disable-line no-lonely-if
|
|
1038
|
-
propertyResource.setKind(ResourceKind.PRIMITIVE_COLLECTION_PROPERTY)
|
|
1039
|
-
if (this._tokenizer.next(TokenKind.SLASH)) {
|
|
1040
|
-
this._parseCollectionPathExpr(pathSegments, propertyResource)
|
|
1041
|
-
}
|
|
1042
|
-
} else {
|
|
1043
|
-
propertyResource.setKind(ResourceKind.PRIMITIVE_PROPERTY)
|
|
1044
|
-
this._parsePrimitivePathExpr(pathSegments, propertyResource)
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
} else {
|
|
1048
|
-
const navigationProperty = lastType.getNavigationProperty(identifier)
|
|
1049
|
-
if (!navigationProperty) {
|
|
1050
|
-
throw new UriQueryOptionSemanticError(
|
|
1051
|
-
UriSemanticError.Message.PROPERTY_NOT_FOUND,
|
|
1052
|
-
identifier,
|
|
1053
|
-
lastType.getFullQualifiedName().toString()
|
|
1054
|
-
)
|
|
1055
|
-
}
|
|
1056
|
-
// Navigation property; maybe a collection
|
|
1057
|
-
let navigationResource = new UriResource()
|
|
1058
|
-
.setNavigationProperty(navigationProperty)
|
|
1059
|
-
.setIsCollection(navigationProperty.isCollection())
|
|
1060
|
-
if (this._tokenizer.next(TokenKind.OPEN)) {
|
|
1061
|
-
if (navigationProperty.isCollection()) {
|
|
1062
|
-
const keyPredicates = this._parseKeyPredicates(navigationResource, navigationProperty.getEntityType())
|
|
1063
|
-
this._tokenizer.requireNext(TokenKind.CLOSE)
|
|
1064
|
-
navigationResource.setKeyPredicates(keyPredicates).setIsCollection(false)
|
|
1065
|
-
} else {
|
|
1066
|
-
throw new UriQueryOptionSemanticError(UriQueryOptionSemanticError.Message.KEY_NOT_ALLOWED)
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
pathSegments.push(navigationResource)
|
|
1070
|
-
|
|
1071
|
-
if (navigationResource.isCollection()) {
|
|
1072
|
-
navigationResource.setKind(ResourceKind.NAVIGATION_TO_MANY)
|
|
1073
|
-
this._parseCollectionNavigationExpr(pathSegments, navigationResource)
|
|
1074
|
-
} else {
|
|
1075
|
-
navigationResource.setKind(ResourceKind.NAVIGATION_TO_ONE)
|
|
1076
|
-
this._parseSingleNavigationExpr(pathSegments, navigationResource)
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
/**
|
|
1082
|
-
* Parse navigation path after a non-collection.
|
|
1083
|
-
* @param {UriResource[]} pathSegments path segments where parsed information is added
|
|
1084
|
-
* @param {UriResource} lastResource last resource
|
|
1085
|
-
* @private
|
|
1086
|
-
*/
|
|
1087
|
-
_parseSingleNavigationExpr (pathSegments, lastResource) {
|
|
1088
|
-
if (this._tokenizer.next(TokenKind.SLASH)) {
|
|
1089
|
-
const tokenKind = [TokenKind.QualifiedName, TokenKind.ODataIdentifier].find(kind => this._tokenizer.next(kind))
|
|
1090
|
-
this._parseMemberExpression(tokenKind, pathSegments, lastResource, true)
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
/**
|
|
1095
|
-
* Parse navigation path after a collection.
|
|
1096
|
-
* @param {UriResource[]} pathSegments path segments where parsed information is added
|
|
1097
|
-
* @param {UriResource} lastResourceParam last resource
|
|
1098
|
-
* @private
|
|
1099
|
-
*/
|
|
1100
|
-
_parseCollectionNavigationExpr (pathSegments, lastResourceParam) {
|
|
1101
|
-
let lastResource = lastResourceParam
|
|
1102
|
-
let hasSlash = this._tokenizer.next(TokenKind.SLASH)
|
|
1103
|
-
if (hasSlash) {
|
|
1104
|
-
if (this._tokenizer.next(TokenKind.QualifiedName)) {
|
|
1105
|
-
const qualifiedName = FullQualifiedName.createFromNameSpaceAndName(this._tokenizer.getText())
|
|
1106
|
-
const edmEntityType = this._edm.getEntityType(qualifiedName)
|
|
1107
|
-
if (edmEntityType) {
|
|
1108
|
-
this._checkStructuredTypeCast(lastResource.getEdmType(), edmEntityType)
|
|
1109
|
-
const castResource = new UriResource()
|
|
1110
|
-
.setKind(ResourceKind.TYPE_CAST)
|
|
1111
|
-
.setTypeCast(edmEntityType)
|
|
1112
|
-
.setIsCollection(lastResource.isCollection())
|
|
1113
|
-
pathSegments.push(castResource)
|
|
1114
|
-
lastResource = castResource
|
|
1115
|
-
} else {
|
|
1116
|
-
this._parseFunction(
|
|
1117
|
-
qualifiedName,
|
|
1118
|
-
pathSegments,
|
|
1119
|
-
lastResource.getEdmType(),
|
|
1120
|
-
lastResource.isCollection(),
|
|
1121
|
-
false
|
|
1122
|
-
)
|
|
1123
|
-
}
|
|
1124
|
-
hasSlash = false
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
if (!hasSlash && this._tokenizer.next(TokenKind.OPEN)) {
|
|
1129
|
-
const keyPredicates = this._parseKeyPredicates(lastResource, lastResource.getEdmType())
|
|
1130
|
-
this._tokenizer.requireNext(TokenKind.CLOSE)
|
|
1131
|
-
lastResource.setKeyPredicates(keyPredicates).setIsCollection(false)
|
|
1132
|
-
this._parseSingleNavigationExpr(pathSegments, lastResource)
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
if (hasSlash || this._tokenizer.next(TokenKind.SLASH)) {
|
|
1136
|
-
this._parseCollectionPathExpr(pathSegments, lastResource)
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
/**
|
|
1141
|
-
* Parse path after a non-collection primitive type.
|
|
1142
|
-
* @param {UriResource[]} pathSegments path segments where parsed information is added
|
|
1143
|
-
* @param {UriResource} lastResource last resource
|
|
1144
|
-
* @private
|
|
1145
|
-
*/
|
|
1146
|
-
_parsePrimitivePathExpr (pathSegments, lastResource) {
|
|
1147
|
-
if (this._tokenizer.next(TokenKind.SLASH)) {
|
|
1148
|
-
this._tokenizer.requireNext(TokenKind.QualifiedName)
|
|
1149
|
-
this._parseFunction(
|
|
1150
|
-
FullQualifiedName.createFromNameSpaceAndName(this._tokenizer.getText()),
|
|
1151
|
-
pathSegments,
|
|
1152
|
-
lastResource.getEdmType(),
|
|
1153
|
-
lastResource.isCollection(),
|
|
1154
|
-
false
|
|
1155
|
-
)
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
/**
|
|
1160
|
-
* Parse path after a non-collection complex type.
|
|
1161
|
-
* @param {UriResource[]} pathSegments path segments where parsed information is added
|
|
1162
|
-
* @param {UriResource} lastResource last resource
|
|
1163
|
-
* @private
|
|
1164
|
-
*/
|
|
1165
|
-
_parseComplexPathExpr (pathSegments, lastResource) {
|
|
1166
|
-
if (this._tokenizer.next(TokenKind.SLASH)) {
|
|
1167
|
-
if (this._tokenizer.next(TokenKind.QualifiedName)) {
|
|
1168
|
-
const fullQualifiedName = FullQualifiedName.createFromNameSpaceAndName(this._tokenizer.getText())
|
|
1169
|
-
const edmComplexType = this._edm.getComplexType(fullQualifiedName)
|
|
1170
|
-
|
|
1171
|
-
if (edmComplexType) {
|
|
1172
|
-
this._checkStructuredTypeCast(lastResource.getEdmType(), edmComplexType)
|
|
1173
|
-
const castResource = new UriResource().setKind(ResourceKind.TYPE_CAST).setTypeCast(edmComplexType)
|
|
1174
|
-
pathSegments.push(castResource)
|
|
1175
|
-
if (this._tokenizer.next(TokenKind.SLASH)) {
|
|
1176
|
-
this._parseComplexPathRestExpr(pathSegments, castResource)
|
|
1177
|
-
}
|
|
1178
|
-
} else {
|
|
1179
|
-
// Must be a bound function.
|
|
1180
|
-
this._parseFunction(
|
|
1181
|
-
fullQualifiedName,
|
|
1182
|
-
pathSegments,
|
|
1183
|
-
lastResource.getEdmType(),
|
|
1184
|
-
lastResource.isCollection(),
|
|
1185
|
-
false
|
|
1186
|
-
)
|
|
1187
|
-
}
|
|
1188
|
-
} else {
|
|
1189
|
-
this._parseComplexPathRestExpr(pathSegments, lastResource)
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
/**
|
|
1195
|
-
* Parse path after a non-collection complex path segment.
|
|
1196
|
-
* @param {UriResource[]} pathSegments path segments where parsed information is added
|
|
1197
|
-
* @param {UriResource} lastResource last resource
|
|
1198
|
-
* @private
|
|
1199
|
-
*/
|
|
1200
|
-
_parseComplexPathRestExpr (pathSegments, lastResource) {
|
|
1201
|
-
if (this._tokenizer.next(TokenKind.QualifiedName)) {
|
|
1202
|
-
const fullQualifiedName = FullQualifiedName.createFromNameSpaceAndName(this._tokenizer.getText())
|
|
1203
|
-
// Must be a bound function.
|
|
1204
|
-
this._parseFunction(
|
|
1205
|
-
fullQualifiedName,
|
|
1206
|
-
pathSegments,
|
|
1207
|
-
lastResource.getEdmType(),
|
|
1208
|
-
lastResource.isCollection(),
|
|
1209
|
-
false
|
|
1210
|
-
)
|
|
1211
|
-
} else if (this._tokenizer.next(TokenKind.ODataIdentifier)) {
|
|
1212
|
-
this._parsePropertyPathExpr(pathSegments, lastResource)
|
|
1213
|
-
} else {
|
|
1214
|
-
throw new UriSyntaxError(
|
|
1215
|
-
UriSyntaxError.Message.TOKEN_KINDS_EXPECTED,
|
|
1216
|
-
[TokenKind.QualifiedName, TokenKind.ODataIdentifier].join(', '),
|
|
1217
|
-
this._tokenizer.getParseString(),
|
|
1218
|
-
this._tokenizer.getPosition()
|
|
1219
|
-
)
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
/**
|
|
1224
|
-
* Parse path after a collection complex type.
|
|
1225
|
-
* @param {UriResource[]} pathSegments path segments where parsed information is added
|
|
1226
|
-
* @param {UriResource} lastResource last resource
|
|
1227
|
-
* @private
|
|
1228
|
-
*/
|
|
1229
|
-
_parseComplexCollectionPathExpr (pathSegments, lastResource) {
|
|
1230
|
-
if (this._tokenizer.next(TokenKind.SLASH)) {
|
|
1231
|
-
if (this._tokenizer.next(TokenKind.QualifiedName)) {
|
|
1232
|
-
const fullQualifiedName = FullQualifiedName.createFromNameSpaceAndName(this._tokenizer.getText())
|
|
1233
|
-
const edmComplexType = this._edm.getComplexType(fullQualifiedName)
|
|
1234
|
-
|
|
1235
|
-
if (edmComplexType) {
|
|
1236
|
-
this._checkStructuredTypeCast(lastResource.getEdmType(), edmComplexType)
|
|
1237
|
-
const castResource = new UriResource()
|
|
1238
|
-
.setKind(ResourceKind.TYPE_CAST)
|
|
1239
|
-
.setTypeCast(edmComplexType)
|
|
1240
|
-
.setIsCollection(lastResource.isCollection())
|
|
1241
|
-
pathSegments.push(castResource)
|
|
1242
|
-
if (this._tokenizer.next(TokenKind.SLASH)) {
|
|
1243
|
-
this._parseCollectionPathExpr(pathSegments, castResource)
|
|
1244
|
-
}
|
|
1245
|
-
} else {
|
|
1246
|
-
// Must be a bound function.
|
|
1247
|
-
this._parseFunction(
|
|
1248
|
-
fullQualifiedName,
|
|
1249
|
-
pathSegments,
|
|
1250
|
-
lastResource.getEdmType(),
|
|
1251
|
-
lastResource.isCollection(),
|
|
1252
|
-
false
|
|
1253
|
-
)
|
|
1254
|
-
}
|
|
1255
|
-
} else {
|
|
1256
|
-
this._parseCollectionPathExpr(pathSegments, lastResource)
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
/**
|
|
1262
|
-
* Parse path after a collection.
|
|
1263
|
-
* @param {UriResource[]} pathSegments path segments where parsed information is added
|
|
1264
|
-
* @param {UriResource} lastResource last resource
|
|
1265
|
-
* @private
|
|
1266
|
-
*/
|
|
1267
|
-
_parseCollectionPathExpr (pathSegments, lastResource) {
|
|
1268
|
-
// The initial slash (see grammar) must have been checked and consumed by the caller.
|
|
1269
|
-
const tokenKind = [TokenKind.COUNT, TokenKind.LAMBDA_ANY, TokenKind.LAMBDA_ALL, TokenKind.QualifiedName].find(
|
|
1270
|
-
kind => this._tokenizer.next(kind)
|
|
1271
|
-
)
|
|
1272
|
-
if (tokenKind === TokenKind.COUNT) {
|
|
1273
|
-
pathSegments.push(new UriResource().setKind(ResourceKind.COUNT))
|
|
1274
|
-
} else if (tokenKind === TokenKind.LAMBDA_ANY || tokenKind === TokenKind.LAMBDA_ALL) {
|
|
1275
|
-
pathSegments.push(this._parseLambdaRest(tokenKind === TokenKind.LAMBDA_ANY, lastResource))
|
|
1276
|
-
} else if (tokenKind === TokenKind.QualifiedName) {
|
|
1277
|
-
this._parseFunction(
|
|
1278
|
-
FullQualifiedName.createFromNameSpaceAndName(this._tokenizer.getText()),
|
|
1279
|
-
pathSegments,
|
|
1280
|
-
lastResource.getEdmType(),
|
|
1281
|
-
lastResource.isCollection(),
|
|
1282
|
-
false
|
|
1283
|
-
)
|
|
1284
|
-
} else {
|
|
1285
|
-
throw new UriSyntaxError(
|
|
1286
|
-
UriSyntaxError.Message.TOKEN_KINDS_EXPECTED,
|
|
1287
|
-
[TokenKind.COUNT, TokenKind.LAMBDA_ANY, TokenKind.LAMBDA_ALL, TokenKind.QualifiedName].join(', '),
|
|
1288
|
-
this._tokenizer.getParseString(),
|
|
1289
|
-
this._tokenizer.getPosition()
|
|
1290
|
-
)
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
/**
|
|
1295
|
-
* Parse function.
|
|
1296
|
-
* @param {FullQualifiedName} fullQualifiedName qualified name of the function
|
|
1297
|
-
* @param {UriResource[]} pathSegments path segments where parsed information is added
|
|
1298
|
-
* @param {EdmType} lastType type of last resource
|
|
1299
|
-
* @param {boolean} lastIsCollection whether the last resource is a collection
|
|
1300
|
-
* @param {boolean} withUnbound whether unbound functions are also to be considered
|
|
1301
|
-
* @private
|
|
1302
|
-
*/
|
|
1303
|
-
_parseFunction (fullQualifiedName, pathSegments, lastType, lastIsCollection, withUnbound) {
|
|
1304
|
-
let visitedParameters = new Map()
|
|
1305
|
-
this._tokenizer.requireNext(TokenKind.OPEN)
|
|
1306
|
-
if (!this._tokenizer.next(TokenKind.CLOSE)) {
|
|
1307
|
-
do {
|
|
1308
|
-
this._tokenizer.requireNext(TokenKind.ODataIdentifier)
|
|
1309
|
-
const name = this._tokenizer.getText()
|
|
1310
|
-
if (visitedParameters.has(name)) {
|
|
1311
|
-
throw new UriQueryOptionSemanticError(UriQueryOptionSemanticError.Message.DUPLICATE_PARAMETER, name)
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
this._tokenizer.requireNext(TokenKind.EQ)
|
|
1315
|
-
const expression = new ExpressionParser(this._edm).parse(
|
|
1316
|
-
this._tokenizer,
|
|
1317
|
-
this._referringType,
|
|
1318
|
-
this._crossjoinEntitySets,
|
|
1319
|
-
this._aliases
|
|
1320
|
-
)
|
|
1321
|
-
visitedParameters.set(name, expression)
|
|
1322
|
-
} while (this._tokenizer.next(TokenKind.COMMA))
|
|
1323
|
-
this._tokenizer.requireNext(TokenKind.CLOSE)
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
const names = Array.from(visitedParameters.keys())
|
|
1327
|
-
let func
|
|
1328
|
-
if (lastType) {
|
|
1329
|
-
func = this._edm.getBoundFunction(fullQualifiedName, lastType.getFullQualifiedName(), lastIsCollection, names)
|
|
1330
|
-
}
|
|
1331
|
-
if (!func && withUnbound) {
|
|
1332
|
-
func = this._edm.getUnboundFunction(fullQualifiedName, names)
|
|
1333
|
-
}
|
|
1334
|
-
if (!func) {
|
|
1335
|
-
throw new UriQueryOptionSemanticError(
|
|
1336
|
-
UriSemanticError.Message.FUNCTION_NOT_FOUND,
|
|
1337
|
-
fullQualifiedName.toString(),
|
|
1338
|
-
names.join(', ')
|
|
1339
|
-
)
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
|
-
// The parameters can only be validated after determining which of the overloaded functions we have.
|
|
1343
|
-
const parameters = this.getValidatedParameters(func, visitedParameters)
|
|
1344
|
-
|
|
1345
|
-
this._parseFunctionRest(pathSegments, func, parameters)
|
|
1346
|
-
}
|
|
1347
|
-
|
|
1348
|
-
/**
|
|
1349
|
-
* Get function parameters after validating them.
|
|
1350
|
-
* @param {EdmFunction} func EDM function
|
|
1351
|
-
* @param {Map.<string, Expression>} visitedParameters map with parameter names and values
|
|
1352
|
-
* @returns {UriParameter[]} the function parameters
|
|
1353
|
-
* @package
|
|
1354
|
-
*/
|
|
1355
|
-
getValidatedParameters (func, visitedParameters) {
|
|
1356
|
-
let parameters = []
|
|
1357
|
-
for (let name of visitedParameters.keys()) {
|
|
1358
|
-
const expression = visitedParameters.get(name)
|
|
1359
|
-
const edmParameter = func.getParameter(name)
|
|
1360
|
-
const edmType = edmParameter.getType()
|
|
1361
|
-
const type = this._getType(expression)
|
|
1362
|
-
|
|
1363
|
-
if (type === null && !edmParameter.isNullable()) {
|
|
1364
|
-
throw new UriQueryOptionSemanticError(UriQueryOptionSemanticError.Message.PARAMETER_NULL, name)
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
if (!this.isCompatible(edmType, type)) {
|
|
1368
|
-
throw new UriQueryOptionSemanticError(
|
|
1369
|
-
UriSemanticError.Message.INCOMPATIBLE_TYPE,
|
|
1370
|
-
type.getFullQualifiedName().toString(),
|
|
1371
|
-
edmType.getFullQualifiedName().toString()
|
|
1372
|
-
)
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1375
|
-
let parameter = new UriParameter().setEdmRef(edmParameter)
|
|
1376
|
-
if (expression.getKind() === ExpressionKind.LITERAL) {
|
|
1377
|
-
parameter.setText(expression.getText())
|
|
1378
|
-
} else if (expression.getKind() === ExpressionKind.ALIAS) {
|
|
1379
|
-
parameter.setAlias(expression.getAlias())
|
|
1380
|
-
const value = expression.getExpression()
|
|
1381
|
-
if (value.getKind() === ExpressionKind.LITERAL) {
|
|
1382
|
-
parameter.setAliasValue(value.getText())
|
|
1383
|
-
} else {
|
|
1384
|
-
parameter.setExpression(value)
|
|
1385
|
-
}
|
|
1386
|
-
} else {
|
|
1387
|
-
parameter.setExpression(expression)
|
|
1388
|
-
}
|
|
1389
|
-
parameters.push(parameter)
|
|
1390
|
-
}
|
|
1391
|
-
return parameters
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
/**
|
|
1395
|
-
* Parse path after a function.
|
|
1396
|
-
* @param {UriResource[]} pathSegments path segments where parsed information is added
|
|
1397
|
-
* @param {EdmFunction} func EDM function
|
|
1398
|
-
* @param {UriParameter[]} parameters function parameters
|
|
1399
|
-
* @private
|
|
1400
|
-
*/
|
|
1401
|
-
_parseFunctionRest (pathSegments, func, parameters) {
|
|
1402
|
-
const edmReturnType = func.getReturnType()
|
|
1403
|
-
const returnTypeKind = edmReturnType.getType().getKind()
|
|
1404
|
-
const isCollection = edmReturnType.isCollection()
|
|
1405
|
-
|
|
1406
|
-
let functionResource = new UriResource()
|
|
1407
|
-
.setKind(func.isBound() ? ResourceKind.BOUND_FUNCTION : ResourceKind.UNBOUND_FUNCTION)
|
|
1408
|
-
.setFunction(func)
|
|
1409
|
-
.setFunctionParameters(parameters)
|
|
1410
|
-
.setIsCollection(isCollection)
|
|
1411
|
-
pathSegments.push(functionResource)
|
|
1412
|
-
|
|
1413
|
-
if (func.isComposable()) {
|
|
1414
|
-
if (returnTypeKind === EdmTypeKind.ENTITY) {
|
|
1415
|
-
if (isCollection) {
|
|
1416
|
-
this._parseCollectionNavigationExpr(pathSegments, functionResource)
|
|
1417
|
-
} else {
|
|
1418
|
-
this._parseSingleNavigationExpr(pathSegments, functionResource)
|
|
1419
|
-
}
|
|
1420
|
-
} else if (returnTypeKind === EdmTypeKind.COMPLEX) {
|
|
1421
|
-
if (isCollection) {
|
|
1422
|
-
this._parseComplexCollectionPathExpr(pathSegments, functionResource)
|
|
1423
|
-
} else {
|
|
1424
|
-
this._parseComplexPathExpr(pathSegments, functionResource)
|
|
1425
|
-
}
|
|
1426
|
-
} else {
|
|
1427
|
-
// The only remaining alternative is that the return type is primitive.
|
|
1428
|
-
if (isCollection) {
|
|
1429
|
-
// eslint-disable-line no-lonely-if
|
|
1430
|
-
if (this._tokenizer.next(TokenKind.SLASH)) {
|
|
1431
|
-
this._parseCollectionPathExpr(pathSegments, functionResource)
|
|
1432
|
-
}
|
|
1433
|
-
} else {
|
|
1434
|
-
this._parsePrimitivePathExpr(pathSegments, functionResource)
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
} else if (this._tokenizer.next(TokenKind.SLASH)) {
|
|
1438
|
-
throw new UriQueryOptionSemanticError(UriQueryOptionSemanticError.Message.NOT_COMPOSABLE, func.getName())
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
|
-
/**
|
|
1443
|
-
* Parse a 'any' or 'all' expression.
|
|
1444
|
-
* @param {boolean} isAny whether the expression is 'all'
|
|
1445
|
-
* @param {UriResource} lastResource last resource
|
|
1446
|
-
* @returns {UriResource} parsed expression
|
|
1447
|
-
* @private
|
|
1448
|
-
*/
|
|
1449
|
-
_parseLambdaRest (isAny, lastResource) {
|
|
1450
|
-
this._tokenizer.requireNext(TokenKind.OPEN)
|
|
1451
|
-
if (isAny && this._tokenizer.next(TokenKind.CLOSE)) {
|
|
1452
|
-
return new UriResource().setKind(ResourceKind.ANY_EXPRESSION)
|
|
1453
|
-
}
|
|
1454
|
-
this._tokenizer.requireNext(TokenKind.ODataIdentifier)
|
|
1455
|
-
const lambdaVariable = this._tokenizer.getText()
|
|
1456
|
-
this._tokenizer.requireNext(TokenKind.COLON)
|
|
1457
|
-
this._lambdaVariables.unshift(
|
|
1458
|
-
new UriResource()
|
|
1459
|
-
.setKind(ResourceKind.EXPRESSION_VARIABLE)
|
|
1460
|
-
.setExpressionVariableName(lambdaVariable)
|
|
1461
|
-
.setExpressionVariableEdmType(lastResource.getEdmType())
|
|
1462
|
-
)
|
|
1463
|
-
// The ABNF suggests that the "lambaPredicateExpr" must contain at least one lambdaVariable,
|
|
1464
|
-
// so arguably this could be checked in expression parsing or later in validation.
|
|
1465
|
-
const lambdaPredicateExpr = this._parseExpression()
|
|
1466
|
-
this.checkNoCollection(lambdaPredicateExpr)
|
|
1467
|
-
this.checkType(lambdaPredicateExpr, EdmPrimitiveTypeKind.Boolean)
|
|
1468
|
-
this._lambdaVariables.shift()
|
|
1469
|
-
this._tokenizer.requireNext(TokenKind.CLOSE)
|
|
1470
|
-
return new UriResource()
|
|
1471
|
-
.setKind(isAny ? ResourceKind.ANY_EXPRESSION : ResourceKind.ALL_EXPRESSION)
|
|
1472
|
-
.setExpressionVariableName(lambdaVariable)
|
|
1473
|
-
.setExpression(lambdaPredicateExpr)
|
|
1474
|
-
}
|
|
1475
|
-
|
|
1476
|
-
/**
|
|
1477
|
-
* Get the 'real' type of an expression, i.e., the underlying type for a type definition.
|
|
1478
|
-
* @param {Expression} expression expression
|
|
1479
|
-
* @returns {EdmType} EDM type
|
|
1480
|
-
* @private
|
|
1481
|
-
*/
|
|
1482
|
-
_getType (expression) {
|
|
1483
|
-
let type = expression.getType()
|
|
1484
|
-
return type && (type.getKind() === EdmTypeKind.ENUM || type.getKind() === EdmTypeKind.DEFINITION)
|
|
1485
|
-
? type.getUnderlyingType()
|
|
1486
|
-
: type
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
/**
|
|
1490
|
-
* Determine whether a type is one of an array of given primitive types or null.
|
|
1491
|
-
* @param {EdmType} type type
|
|
1492
|
-
* @param {...EdmPrimitiveType} kinds EDM primitive types
|
|
1493
|
-
* @returns {boolean} true if the type is one of the given types or null, false otherwise
|
|
1494
|
-
* @private
|
|
1495
|
-
*/
|
|
1496
|
-
_isType (type, ...kinds) {
|
|
1497
|
-
return type === null || kinds.indexOf(type) > -1
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
|
-
/**
|
|
1501
|
-
* Check whether the type of an expression is one of an array of given primitive types or null.
|
|
1502
|
-
* @param {Expression} expression expression
|
|
1503
|
-
* @param {...EdmPrimitiveType} kinds EDM primitive types
|
|
1504
|
-
* @throws {UriQueryOptionSemanticError} if the type is not one of the given types and not null
|
|
1505
|
-
* @package
|
|
1506
|
-
*/
|
|
1507
|
-
checkType (expression, ...kinds) {
|
|
1508
|
-
const type = this._getType(expression)
|
|
1509
|
-
if (!this._isType(type, ...kinds)) {
|
|
1510
|
-
throw new UriQueryOptionSemanticError(
|
|
1511
|
-
UriSemanticError.Message.INCOMPATIBLE_TYPE,
|
|
1512
|
-
type ? type.getFullQualifiedName().toString() : '',
|
|
1513
|
-
kinds.join(', ')
|
|
1514
|
-
)
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
|
-
/**
|
|
1519
|
-
* Check that an expression is no collection.
|
|
1520
|
-
* @param {Expression} expression expression
|
|
1521
|
-
* @throws {UriQueryOptionSemanticError} if the expression is a collection
|
|
1522
|
-
* @package
|
|
1523
|
-
*/
|
|
1524
|
-
checkNoCollection (expression) {
|
|
1525
|
-
if (expression.getKind() === ExpressionKind.MEMBER && expression.isCollection()) {
|
|
1526
|
-
throw new UriQueryOptionSemanticError(UriQueryOptionSemanticError.Message.COLLECTION)
|
|
1527
|
-
}
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
/**
|
|
1531
|
-
* Check that an expression is no collection and of an integer type.
|
|
1532
|
-
* @param {Expression} expression expression
|
|
1533
|
-
* @throws {UriQueryOptionSemanticError} if the expression is a collection or of another type
|
|
1534
|
-
* @package
|
|
1535
|
-
*/
|
|
1536
|
-
checkIntegerType (expression) {
|
|
1537
|
-
this.checkNoCollection(expression)
|
|
1538
|
-
this.checkType(
|
|
1539
|
-
expression,
|
|
1540
|
-
EdmPrimitiveTypeKind.Int64,
|
|
1541
|
-
EdmPrimitiveTypeKind.Int32,
|
|
1542
|
-
EdmPrimitiveTypeKind.Int16,
|
|
1543
|
-
EdmPrimitiveTypeKind.Byte,
|
|
1544
|
-
EdmPrimitiveTypeKind.SByte
|
|
1545
|
-
)
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
/**
|
|
1549
|
-
* Check that an expression is no collection and of a numeric type.
|
|
1550
|
-
* @param {Expression} expression expression
|
|
1551
|
-
* @throws {UriQueryOptionSemanticError} if the expression is a collection or of another type
|
|
1552
|
-
* @package
|
|
1553
|
-
*/
|
|
1554
|
-
checkNumericType (expression) {
|
|
1555
|
-
this.checkNoCollection(expression)
|
|
1556
|
-
this.checkType(
|
|
1557
|
-
expression,
|
|
1558
|
-
EdmPrimitiveTypeKind.Int64,
|
|
1559
|
-
EdmPrimitiveTypeKind.Int32,
|
|
1560
|
-
EdmPrimitiveTypeKind.Int16,
|
|
1561
|
-
EdmPrimitiveTypeKind.Byte,
|
|
1562
|
-
EdmPrimitiveTypeKind.SByte,
|
|
1563
|
-
EdmPrimitiveTypeKind.Decimal,
|
|
1564
|
-
EdmPrimitiveTypeKind.Single,
|
|
1565
|
-
EdmPrimitiveTypeKind.Double
|
|
1566
|
-
)
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1569
|
-
/**
|
|
1570
|
-
* Determine whether a type is a numeric primitive type.
|
|
1571
|
-
* @param {EdmType} type type
|
|
1572
|
-
* @returns {boolean} true if the type is a numeric primitive type, false otherwise
|
|
1573
|
-
* @private
|
|
1574
|
-
*/
|
|
1575
|
-
_isNumericType (type) {
|
|
1576
|
-
return this._isType(
|
|
1577
|
-
type,
|
|
1578
|
-
EdmPrimitiveTypeKind.Int64,
|
|
1579
|
-
EdmPrimitiveTypeKind.Int32,
|
|
1580
|
-
EdmPrimitiveTypeKind.Int16,
|
|
1581
|
-
EdmPrimitiveTypeKind.Byte,
|
|
1582
|
-
EdmPrimitiveTypeKind.SByte,
|
|
1583
|
-
EdmPrimitiveTypeKind.Decimal,
|
|
1584
|
-
EdmPrimitiveTypeKind.Single,
|
|
1585
|
-
EdmPrimitiveTypeKind.Double
|
|
1586
|
-
)
|
|
1587
|
-
}
|
|
1588
|
-
|
|
1589
|
-
/**
|
|
1590
|
-
* Determine whether two types are comparable.
|
|
1591
|
-
* @param {EdmType} leftType left type
|
|
1592
|
-
* @param {EdmType} rightType right type
|
|
1593
|
-
* @returns {boolean} whether the types are comparable
|
|
1594
|
-
* @private
|
|
1595
|
-
*/
|
|
1596
|
-
_isComparable (leftType, rightType) {
|
|
1597
|
-
return leftType === rightType || (this._isNumericType(leftType) && this._isNumericType(rightType))
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
/**
|
|
1601
|
-
* Determine whether two types are assignment compatible.
|
|
1602
|
-
* @param {EdmType} leftType the type of the target of the assignment
|
|
1603
|
-
* @param {EdmType} rightType the type of the source of the assignment
|
|
1604
|
-
* @returns {boolean} whether the types are assignment compatible
|
|
1605
|
-
* @package
|
|
1606
|
-
*/
|
|
1607
|
-
isCompatible (leftType, rightType) {
|
|
1608
|
-
if (!leftType || !rightType || leftType === rightType || leftType === 'nullable') return true
|
|
1609
|
-
|
|
1610
|
-
if (leftType.getKind() !== rightType.getKind()) return false
|
|
1611
|
-
|
|
1612
|
-
if (rightType.getKind() === EdmTypeKind.ENTITY || rightType.getKind() === EdmTypeKind.COMPLEX) {
|
|
1613
|
-
return leftType.compatibleTo(rightType)
|
|
1614
|
-
}
|
|
1615
|
-
|
|
1616
|
-
switch (leftType) {
|
|
1617
|
-
case EdmPrimitiveTypeKind.Decimal:
|
|
1618
|
-
return this.isCompatible(EdmPrimitiveTypeKind.Int64, rightType)
|
|
1619
|
-
case EdmPrimitiveTypeKind.Int64:
|
|
1620
|
-
return this.isCompatible(EdmPrimitiveTypeKind.Int32, rightType)
|
|
1621
|
-
case EdmPrimitiveTypeKind.Int32:
|
|
1622
|
-
return this.isCompatible(EdmPrimitiveTypeKind.Int16, rightType)
|
|
1623
|
-
case EdmPrimitiveTypeKind.Int16:
|
|
1624
|
-
return rightType === EdmPrimitiveTypeKind.Byte || rightType === EdmPrimitiveTypeKind.SByte
|
|
1625
|
-
case EdmPrimitiveTypeKind.Double:
|
|
1626
|
-
return rightType === EdmPrimitiveTypeKind.Single
|
|
1627
|
-
default:
|
|
1628
|
-
return false
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
|
|
1632
|
-
/**
|
|
1633
|
-
* Determine whether two expressions can be compared regarding equality.
|
|
1634
|
-
* @param {Expression} left left expression
|
|
1635
|
-
* @param {Expression} right right expression
|
|
1636
|
-
* @throws {UriQueryOptionSemanticError} if the expressions are not comparable
|
|
1637
|
-
* @private
|
|
1638
|
-
*/
|
|
1639
|
-
_checkEqualityTypes (left, right) {
|
|
1640
|
-
this.checkNoCollection(left)
|
|
1641
|
-
this.checkNoCollection(right)
|
|
1642
|
-
|
|
1643
|
-
const leftType = this._getType(left)
|
|
1644
|
-
const rightType = this._getType(right)
|
|
1645
|
-
if (
|
|
1646
|
-
!leftType ||
|
|
1647
|
-
!rightType ||
|
|
1648
|
-
(leftType.getNamespace() === rightType.getNamespace() && leftType.getName() === rightType.getName())
|
|
1649
|
-
) {
|
|
1650
|
-
return
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
if (
|
|
1654
|
-
leftType.getKind() !== EdmTypeKind.PRIMITIVE ||
|
|
1655
|
-
rightType.getKind() !== EdmTypeKind.PRIMITIVE ||
|
|
1656
|
-
!this._isComparable(leftType, rightType)
|
|
1657
|
-
) {
|
|
1658
|
-
throw new UriQueryOptionSemanticError(
|
|
1659
|
-
UriSemanticError.Message.INCOMPATIBLE_TYPE,
|
|
1660
|
-
leftType.getFullQualifiedName().toString(),
|
|
1661
|
-
rightType.getFullQualifiedName().toString()
|
|
1662
|
-
)
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1665
|
-
|
|
1666
|
-
/**
|
|
1667
|
-
* Determine whether of two expressions can be determined in principle which one is greater.
|
|
1668
|
-
* @param {Expression} left left expression
|
|
1669
|
-
* @param {Expression} right right expression
|
|
1670
|
-
* @throws {UriQueryOptionSemanticError} if the expressions are not comparable
|
|
1671
|
-
* @private
|
|
1672
|
-
*/
|
|
1673
|
-
_checkRelationTypes (left, right) {
|
|
1674
|
-
this.checkNoCollection(left)
|
|
1675
|
-
this.checkNoCollection(right)
|
|
1676
|
-
const leftType = this._getType(left)
|
|
1677
|
-
const rightType = this._getType(right)
|
|
1678
|
-
this.checkType(
|
|
1679
|
-
left,
|
|
1680
|
-
EdmPrimitiveTypeKind.Int16,
|
|
1681
|
-
EdmPrimitiveTypeKind.Int32,
|
|
1682
|
-
EdmPrimitiveTypeKind.Int64,
|
|
1683
|
-
EdmPrimitiveTypeKind.Byte,
|
|
1684
|
-
EdmPrimitiveTypeKind.SByte,
|
|
1685
|
-
EdmPrimitiveTypeKind.Decimal,
|
|
1686
|
-
EdmPrimitiveTypeKind.Single,
|
|
1687
|
-
EdmPrimitiveTypeKind.Double,
|
|
1688
|
-
EdmPrimitiveTypeKind.Boolean,
|
|
1689
|
-
EdmPrimitiveTypeKind.Guid,
|
|
1690
|
-
EdmPrimitiveTypeKind.String,
|
|
1691
|
-
EdmPrimitiveTypeKind.Date,
|
|
1692
|
-
EdmPrimitiveTypeKind.TimeOfDay,
|
|
1693
|
-
EdmPrimitiveTypeKind.DateTimeOffset,
|
|
1694
|
-
EdmPrimitiveTypeKind.Duration
|
|
1695
|
-
)
|
|
1696
|
-
this.checkType(
|
|
1697
|
-
right,
|
|
1698
|
-
EdmPrimitiveTypeKind.Int16,
|
|
1699
|
-
EdmPrimitiveTypeKind.Int32,
|
|
1700
|
-
EdmPrimitiveTypeKind.Int64,
|
|
1701
|
-
EdmPrimitiveTypeKind.Byte,
|
|
1702
|
-
EdmPrimitiveTypeKind.SByte,
|
|
1703
|
-
EdmPrimitiveTypeKind.Decimal,
|
|
1704
|
-
EdmPrimitiveTypeKind.Single,
|
|
1705
|
-
EdmPrimitiveTypeKind.Double,
|
|
1706
|
-
EdmPrimitiveTypeKind.Boolean,
|
|
1707
|
-
EdmPrimitiveTypeKind.Guid,
|
|
1708
|
-
EdmPrimitiveTypeKind.String,
|
|
1709
|
-
EdmPrimitiveTypeKind.Date,
|
|
1710
|
-
EdmPrimitiveTypeKind.TimeOfDay,
|
|
1711
|
-
EdmPrimitiveTypeKind.DateTimeOffset,
|
|
1712
|
-
EdmPrimitiveTypeKind.Duration
|
|
1713
|
-
)
|
|
1714
|
-
if (!leftType || !rightType) return
|
|
1715
|
-
if (!this._isComparable(leftType, rightType)) {
|
|
1716
|
-
throw new UriQueryOptionSemanticError(
|
|
1717
|
-
UriSemanticError.Message.INCOMPATIBLE_TYPE,
|
|
1718
|
-
leftType.getFullQualifiedName().toString(),
|
|
1719
|
-
rightType.getFullQualifiedName().toString()
|
|
1720
|
-
)
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
|
|
1724
|
-
/**
|
|
1725
|
-
* Determine the EDM type of the sum or difference of two expressions.
|
|
1726
|
-
* @param {Expression} left left expression
|
|
1727
|
-
* @param {Expression} right right expression
|
|
1728
|
-
* @param {boolean} isSub whether the operation is a subtraction
|
|
1729
|
-
* @returns {EdmType} EDM type
|
|
1730
|
-
* @throws {UriQueryOptionSemanticError} if the expressions are not compatible
|
|
1731
|
-
* @private
|
|
1732
|
-
*/
|
|
1733
|
-
_getAddSubTypeAndCheckLeftAndRight (left, right, isSub) {
|
|
1734
|
-
this.checkNoCollection(left)
|
|
1735
|
-
this.checkNoCollection(right)
|
|
1736
|
-
const leftType = this._getType(left)
|
|
1737
|
-
const rightType = this._getType(right)
|
|
1738
|
-
if (this._isNumericType(leftType) && this._isNumericType(rightType)) {
|
|
1739
|
-
// The result type must be able to handle the overflow.
|
|
1740
|
-
if (
|
|
1741
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Double, EdmPrimitiveTypeKind.Single) ||
|
|
1742
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Double, EdmPrimitiveTypeKind.Single)
|
|
1743
|
-
) {
|
|
1744
|
-
return EdmPrimitiveTypeKind.Double
|
|
1745
|
-
} else if (
|
|
1746
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Decimal) ||
|
|
1747
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Decimal)
|
|
1748
|
-
) {
|
|
1749
|
-
return EdmPrimitiveTypeKind.Decimal
|
|
1750
|
-
} else if (
|
|
1751
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Int64) ||
|
|
1752
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Int64)
|
|
1753
|
-
) {
|
|
1754
|
-
return EdmPrimitiveTypeKind.Decimal
|
|
1755
|
-
} else if (
|
|
1756
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Int32) ||
|
|
1757
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Int32)
|
|
1758
|
-
) {
|
|
1759
|
-
return EdmPrimitiveTypeKind.Int64
|
|
1760
|
-
} else if (
|
|
1761
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Int16) ||
|
|
1762
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Int16)
|
|
1763
|
-
) {
|
|
1764
|
-
return EdmPrimitiveTypeKind.Int32
|
|
1765
|
-
}
|
|
1766
|
-
return EdmPrimitiveTypeKind.Int16
|
|
1767
|
-
}
|
|
1768
|
-
|
|
1769
|
-
if (
|
|
1770
|
-
this._isType(
|
|
1771
|
-
leftType,
|
|
1772
|
-
EdmPrimitiveTypeKind.DateTimeOffset,
|
|
1773
|
-
EdmPrimitiveTypeKind.Date,
|
|
1774
|
-
EdmPrimitiveTypeKind.Duration
|
|
1775
|
-
) &&
|
|
1776
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Duration)
|
|
1777
|
-
) {
|
|
1778
|
-
return leftType
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1781
|
-
if (
|
|
1782
|
-
isSub &&
|
|
1783
|
-
((this._isType(leftType, EdmPrimitiveTypeKind.DateTimeOffset) &&
|
|
1784
|
-
this._isType(rightType, EdmPrimitiveTypeKind.DateTimeOffset)) ||
|
|
1785
|
-
(this._isType(leftType, EdmPrimitiveTypeKind.Date) && this._isType(rightType, EdmPrimitiveTypeKind.Date)))
|
|
1786
|
-
) {
|
|
1787
|
-
return EdmPrimitiveTypeKind.Duration
|
|
1788
|
-
}
|
|
1789
|
-
|
|
1790
|
-
throw new UriQueryOptionSemanticError(
|
|
1791
|
-
UriSemanticError.Message.INCOMPATIBLE_TYPE,
|
|
1792
|
-
leftType.getFullQualifiedName().toString(),
|
|
1793
|
-
rightType.getFullQualifiedName().toString()
|
|
1794
|
-
)
|
|
1795
|
-
}
|
|
1796
|
-
|
|
1797
|
-
/**
|
|
1798
|
-
* Determine the resulting EDM type for 'mul', 'div', or 'mod' of two expressions.
|
|
1799
|
-
* @param {Expression} left left expression
|
|
1800
|
-
* @param {Expression} right right expression
|
|
1801
|
-
* @param {BinaryOperatorKind} operatorKind operator kind
|
|
1802
|
-
* @returns {EdmType} EDM type
|
|
1803
|
-
* @throws {UriQueryOptionSemanticError} if the expressions are not compatible
|
|
1804
|
-
* @private
|
|
1805
|
-
*/
|
|
1806
|
-
_getMulDivModTypeAndCheckLeftAndRight (left, right, operatorKind) {
|
|
1807
|
-
this.checkNoCollection(left)
|
|
1808
|
-
this.checkNoCollection(right)
|
|
1809
|
-
const leftType = this._getType(left)
|
|
1810
|
-
const rightType = this._getType(right)
|
|
1811
|
-
if (this._isNumericType(leftType) && this._isNumericType(rightType)) {
|
|
1812
|
-
if (operatorKind === BinaryOperatorKind.MUL) {
|
|
1813
|
-
return this._getMulNumericResultType(leftType, rightType)
|
|
1814
|
-
} else if (operatorKind === BinaryOperatorKind.DIV) {
|
|
1815
|
-
return this._getDivNumericResultType(leftType, rightType)
|
|
1816
|
-
}
|
|
1817
|
-
|
|
1818
|
-
// BinaryOperatorKind.MOD
|
|
1819
|
-
return this._getModResultType(leftType, rightType)
|
|
1820
|
-
} else if (
|
|
1821
|
-
(operatorKind === BinaryOperatorKind.MUL || operatorKind === BinaryOperatorKind.DIV) &&
|
|
1822
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Duration) &&
|
|
1823
|
-
this._isNumericType(rightType)
|
|
1824
|
-
) {
|
|
1825
|
-
return leftType
|
|
1826
|
-
}
|
|
1827
|
-
throw new UriQueryOptionSemanticError(
|
|
1828
|
-
UriSemanticError.Message.INCOMPATIBLE_TYPE,
|
|
1829
|
-
leftType.getFullQualifiedName().toString(),
|
|
1830
|
-
rightType.getFullQualifiedName().toString()
|
|
1831
|
-
)
|
|
1832
|
-
}
|
|
1833
|
-
|
|
1834
|
-
/**
|
|
1835
|
-
* Determine the resulting EDM type for multiplying instances of two types.
|
|
1836
|
-
* @param {EdmPrimitiveType} leftType left type
|
|
1837
|
-
* @param {EdmPrimitiveType} rightType right type
|
|
1838
|
-
* @returns {EdmPrimitiveType} EDM type
|
|
1839
|
-
* @private
|
|
1840
|
-
*/
|
|
1841
|
-
_getMulNumericResultType (leftType, rightType) {
|
|
1842
|
-
// The result type must be able to handle the overflow of the multiplication.
|
|
1843
|
-
if (
|
|
1844
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Double, EdmPrimitiveTypeKind.Single) ||
|
|
1845
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Double, EdmPrimitiveTypeKind.Single)
|
|
1846
|
-
) {
|
|
1847
|
-
return EdmPrimitiveTypeKind.Double
|
|
1848
|
-
} else if (
|
|
1849
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Decimal) ||
|
|
1850
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Decimal)
|
|
1851
|
-
) {
|
|
1852
|
-
return EdmPrimitiveTypeKind.Decimal
|
|
1853
|
-
} else if (
|
|
1854
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Int64) ||
|
|
1855
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Int64)
|
|
1856
|
-
) {
|
|
1857
|
-
return EdmPrimitiveTypeKind.Decimal
|
|
1858
|
-
} else if (
|
|
1859
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Int32) ||
|
|
1860
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Int32)
|
|
1861
|
-
) {
|
|
1862
|
-
return EdmPrimitiveTypeKind.Int64
|
|
1863
|
-
} else if (
|
|
1864
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Int16) ||
|
|
1865
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Int16)
|
|
1866
|
-
) {
|
|
1867
|
-
return EdmPrimitiveTypeKind.Int32
|
|
1868
|
-
} else if (
|
|
1869
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Byte) &&
|
|
1870
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Byte)
|
|
1871
|
-
) {
|
|
1872
|
-
return EdmPrimitiveTypeKind.Int32
|
|
1873
|
-
}
|
|
1874
|
-
return EdmPrimitiveTypeKind.Int16
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
/**
|
|
1878
|
-
* Determine the resulting EDM type for dividing instances of two types.
|
|
1879
|
-
* @param {EdmPrimitiveType} leftType left type
|
|
1880
|
-
* @param {EdmPrimitiveType} rightType right type
|
|
1881
|
-
* @returns {EdmPrimitiveType} EDM type
|
|
1882
|
-
* @private
|
|
1883
|
-
*/
|
|
1884
|
-
_getDivNumericResultType (leftType, rightType) {
|
|
1885
|
-
// For integral divisions, the allowed range must be extended.
|
|
1886
|
-
// Example: -32768 div -1 results in 32768 which is no longer an Int16 but an Int32.
|
|
1887
|
-
if (
|
|
1888
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Double, EdmPrimitiveTypeKind.Single) ||
|
|
1889
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Double, EdmPrimitiveTypeKind.Single)
|
|
1890
|
-
) {
|
|
1891
|
-
return EdmPrimitiveTypeKind.Double
|
|
1892
|
-
} else if (
|
|
1893
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Decimal) ||
|
|
1894
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Decimal)
|
|
1895
|
-
) {
|
|
1896
|
-
return EdmPrimitiveTypeKind.Decimal
|
|
1897
|
-
} else if (this._isType(leftType, EdmPrimitiveTypeKind.Int64)) {
|
|
1898
|
-
return EdmPrimitiveTypeKind.Decimal
|
|
1899
|
-
} else if (this._isType(leftType, EdmPrimitiveTypeKind.Int32)) {
|
|
1900
|
-
return EdmPrimitiveTypeKind.Int64
|
|
1901
|
-
} else if (this._isType(leftType, EdmPrimitiveTypeKind.Int16)) {
|
|
1902
|
-
return EdmPrimitiveTypeKind.Int32
|
|
1903
|
-
} else if (
|
|
1904
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Byte) &&
|
|
1905
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Byte)
|
|
1906
|
-
) {
|
|
1907
|
-
return EdmPrimitiveTypeKind.Byte
|
|
1908
|
-
}
|
|
1909
|
-
return EdmPrimitiveTypeKind.Int16
|
|
1910
|
-
}
|
|
1911
|
-
|
|
1912
|
-
/**
|
|
1913
|
-
* Determine the resulting EDM type for calculating the remainder of dividing one instance of a type by another.
|
|
1914
|
-
* @param {EdmPrimitiveType} leftType left type
|
|
1915
|
-
* @param {EdmPrimitiveType} rightType right type
|
|
1916
|
-
* @returns {EdmPrimitiveType} EDM type
|
|
1917
|
-
* @private
|
|
1918
|
-
*/
|
|
1919
|
-
_getModResultType (leftType, rightType) {
|
|
1920
|
-
// The remainder of a modulo operation can be at most the maximal value of the smaller operand
|
|
1921
|
-
// because it's the rest of a division.
|
|
1922
|
-
// The OData specification says
|
|
1923
|
-
// If the right operand is negative, the sign of the result is the same
|
|
1924
|
-
// as the sign of the left operand.
|
|
1925
|
-
// so we don't have to worry too much about the sign.
|
|
1926
|
-
if (this._isType(leftType, EdmPrimitiveTypeKind.SByte) || this._isType(rightType, EdmPrimitiveTypeKind.SByte)) {
|
|
1927
|
-
return EdmPrimitiveTypeKind.SByte
|
|
1928
|
-
} else if (
|
|
1929
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Byte) ||
|
|
1930
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Byte)
|
|
1931
|
-
) {
|
|
1932
|
-
return this._isType(leftType, EdmPrimitiveTypeKind.Byte) && this._isType(rightType, EdmPrimitiveTypeKind.Byte)
|
|
1933
|
-
? EdmPrimitiveTypeKind.Byte
|
|
1934
|
-
: EdmPrimitiveTypeKind.Int16
|
|
1935
|
-
} else if (
|
|
1936
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Int16) ||
|
|
1937
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Int16)
|
|
1938
|
-
) {
|
|
1939
|
-
return EdmPrimitiveTypeKind.Int16
|
|
1940
|
-
} else if (
|
|
1941
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Int32) ||
|
|
1942
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Int32)
|
|
1943
|
-
) {
|
|
1944
|
-
return EdmPrimitiveTypeKind.Int32
|
|
1945
|
-
} else if (
|
|
1946
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Int64) ||
|
|
1947
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Int64)
|
|
1948
|
-
) {
|
|
1949
|
-
return EdmPrimitiveTypeKind.Int64
|
|
1950
|
-
} else if (
|
|
1951
|
-
this._isType(leftType, EdmPrimitiveTypeKind.Decimal) ||
|
|
1952
|
-
this._isType(rightType, EdmPrimitiveTypeKind.Decimal)
|
|
1953
|
-
) {
|
|
1954
|
-
return EdmPrimitiveTypeKind.Decimal
|
|
1955
|
-
} else if (this._isType(rightType, EdmPrimitiveTypeKind.Single)) {
|
|
1956
|
-
return rightType
|
|
1957
|
-
}
|
|
1958
|
-
return leftType
|
|
1959
|
-
}
|
|
1960
|
-
|
|
1961
|
-
/**
|
|
1962
|
-
* Determine whether one EDM type can be used as type cast for the other EDM type.
|
|
1963
|
-
* @param {EdmType} type type
|
|
1964
|
-
* @param {EdmType} castType cast type
|
|
1965
|
-
* @throws {UriQueryOptionSemanticError} if the types are not compatible
|
|
1966
|
-
* @private
|
|
1967
|
-
*/
|
|
1968
|
-
_checkStructuredTypeCast (type, castType) {
|
|
1969
|
-
// Type casts are explicitly not supported (although the expression parser can parse them)
|
|
1970
|
-
FeatureSupport.failUnsupported(
|
|
1971
|
-
FeatureSupport.features.TypeCast,
|
|
1972
|
-
castType.getFullQualifiedName().toString(),
|
|
1973
|
-
this._tokenizer.getPosition()
|
|
1974
|
-
)
|
|
1975
|
-
|
|
1976
|
-
const isCorrectKind = castType.getKind() === EdmTypeKind.ENTITY || castType.getKind() === EdmTypeKind.COMPLEX
|
|
1977
|
-
|
|
1978
|
-
if (!isCorrectKind || !castType.compatibleTo(type)) {
|
|
1979
|
-
throw new UriQueryOptionSemanticError(
|
|
1980
|
-
UriSemanticError.Message.INCOMPATIBLE_TYPE,
|
|
1981
|
-
castType.getFullQualifiedName().toString(),
|
|
1982
|
-
type.getFullQualifiedName().toString()
|
|
1983
|
-
)
|
|
1984
|
-
}
|
|
1985
|
-
}
|
|
1986
|
-
}
|
|
1987
|
-
|
|
1988
|
-
module.exports = ExpressionParser
|