@sap/cds-dk 10.0.7 → 10.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +106 -0
- package/bin/add.js +7 -23
- package/bin/bind.js +14 -0
- package/bin/build.js +21 -34
- package/bin/cds.js +1 -1
- package/bin/compile/index.js +16 -41
- package/bin/completion/completionFs.js +11 -8
- package/bin/completion/index.js +603 -80
- package/bin/completion/scripts/cds.fish +620 -0
- package/bin/completion/scripts/cds.ps1 +403 -0
- package/bin/completion/scripts/cds.sh +327 -0
- package/bin/completion/scripts/cds.zsh +296 -0
- package/bin/completion/templates/cds-tmpl.fish +65 -0
- package/bin/completion/templates/cds-tmpl.ps1 +217 -0
- package/bin/completion/templates/cds-tmpl.sh +93 -0
- package/bin/completion/templates/cds-tmpl.zsh +74 -0
- package/bin/deploy/index.js +11 -1
- package/bin/deploy/options.js +25 -0
- package/{lib → bin}/deploy/to-hana/hana.js +8 -8
- package/{lib → bin}/deploy/to-hana/hdiDeployUtil.js +1 -1
- package/bin/deploy/{to-hana.js → to-hana/index.js} +1 -1
- package/{lib → bin}/deploy/to-hana/mtaUtil.js +1 -1
- package/bin/deploy/to-sql.js +0 -2
- package/bin/env.js +4 -1
- package/bin/export.js +44 -6
- package/bin/help/export.md +3 -0
- package/bin/help.js +1 -5
- package/bin/import.js +9 -0
- package/bin/init.js +6 -24
- package/bin/inspect.js +8 -0
- package/bin/lint.js +5 -3
- package/bin/login.js +26 -20
- package/bin/minify.js +6 -1
- package/bin/pull.js +19 -6
- package/bin/push.js +19 -6
- package/bin/repl.js +11 -2
- package/bin/run.js +12 -1
- package/bin/serve.js +13 -2
- package/bin/up.js +17 -11
- package/{lib → bin}/upgrade/constants.js +1 -1
- package/bin/{upgrade.js → upgrade/index.js} +2 -2
- package/{lib → bin}/upgrade/preflight/consistency.js +1 -1
- package/{lib → bin}/upgrade/preflight/index.js +1 -1
- package/{lib → bin}/upgrade/steps/analyze/index.js +1 -1
- package/{lib → bin}/upgrade/steps/install.js +1 -1
- package/{lib → bin}/upgrade/steps/openrewrite.js +1 -1
- package/{lib → bin}/upgrade/steps/removals.js +1 -1
- package/{lib → bin}/upgrade/steps/rewrite.js +1 -1
- package/{lib → bin}/upgrade/steps/verify.js +1 -1
- package/{lib/upgrade/index.js → bin/upgrade/upgrade.js} +2 -2
- package/{lib → bin}/upgrade/util/pom.js +2 -2
- package/{lib → bin}/upgrade/util/prompt.js +1 -1
- package/bin/util/containerize.js +10 -4
- package/bin/version.js +10 -1
- package/{lib → bin}/watch/hot-reload.js +1 -1
- package/bin/{watch.js → watch/index.js} +24 -9
- package/{lib → bin}/watch/livereload-connect.js +1 -1
- package/{lib → bin}/watch/vite-watch.js +1 -1
- package/{lib → bin}/watch/watched.js +2 -2
- package/lib/build/constants.js +1 -1
- package/lib/build/plugins/fiori/index.js +31 -2
- package/lib/build/plugins/internal.js +4 -2
- package/lib/build/plugins/mtx-sidecar/index.js +7 -8
- package/lib/build/plugins/nodejs/index.js +64 -7
- package/lib/build/util.js +2 -4
- package/lib/compile/to_asyncapi.js +1 -1
- package/lib/env/schema.js +16 -0
- package/lib/env/schemas/cds-rc.js +1 -76
- package/lib/import/importapi.js +2 -3
- package/lib/import/message.js +0 -2
- package/lib/init/constants.js +2 -1
- package/lib/init/index.js +2 -2
- package/lib/init/merge.js +123 -280
- package/lib/init/plugin.js +3 -1
- package/lib/init/projectReader.js +22 -6
- package/lib/init/registries/xs-app.js +3 -5
- package/lib/init/template/ai/files/mta.yaml.hbs +1 -1
- package/lib/init/template/ai/index.js +14 -2
- package/lib/init/template/ams/index.js +2 -2
- package/lib/init/template/app-frontend/files/containerize.yaml.hbs +2 -2
- package/lib/init/template/app-frontend/index.js +4 -4
- package/lib/init/template/application-logging/index.js +2 -2
- package/lib/init/template/approuter/files/package.json +1 -1
- package/lib/init/template/approuter/index.js +8 -3
- package/lib/init/template/attachments/files/package.json.hbs +1 -1
- package/lib/init/template/attachments/index.js +2 -2
- package/lib/init/template/audit-logging/index.js +2 -2
- package/lib/init/template/cloud-logging/files/package.json.hbs +4 -4
- package/lib/init/template/cloud-logging/index.js +2 -2
- package/lib/init/template/completion/completionSetup.js +36 -39
- package/lib/init/template/connectivity/index.js +2 -2
- package/lib/init/template/data/as-csv.js +15 -5
- package/lib/init/template/data/as-json.js +117 -42
- package/lib/init/template/data/index.js +16 -2
- package/lib/init/template/destination/index.js +2 -2
- package/lib/init/template/dynatrace/files/package.json.hbs +3 -3
- package/lib/init/template/dynatrace/index.js +2 -2
- package/lib/init/template/enterprise-messaging/index.js +2 -2
- package/lib/init/template/enterprise-messaging-shared/index.js +2 -2
- package/lib/init/template/extensibility/files/mta.yaml.hbs +11 -0
- package/lib/init/template/extensibility/files/xs-security.json.hbs +1 -1
- package/lib/init/template/extensibility/index.js +3 -3
- package/lib/init/template/github-actions/index.js +2 -2
- package/lib/init/template/hana/index.js +3 -2
- package/lib/init/template/hana-serverless/files/db/package.json +14 -0
- package/lib/init/template/hana-serverless/files/identity.values.yaml.hbs +10 -0
- package/lib/init/template/hana-serverless/files/mta.yaml.hbs +64 -0
- package/lib/init/template/hana-serverless/files/package.json.hbs +35 -0
- package/lib/init/template/hana-serverless/files/src/.hdiconfig +139 -0
- package/lib/init/template/hana-serverless/files/undeploy.json +7 -0
- package/lib/init/template/hana-serverless/files/values.yaml.hbs +18 -0
- package/lib/init/template/hana-serverless/index.js +184 -0
- package/lib/init/template/html5-repo/files/containerize.yaml.hbs +2 -2
- package/lib/init/template/html5-repo/files/mta.yaml.hbs +5 -0
- package/lib/init/template/html5-repo/index.js +18 -14
- package/lib/init/template/http/index.js +123 -26
- package/lib/init/template/ias/index.js +2 -2
- package/lib/init/template/kafka/index.js +2 -2
- package/lib/init/template/kyma/index.js +7 -5
- package/lib/init/template/malware-scanner/index.js +2 -2
- package/lib/init/template/mta/files/mta.yaml.hbs +1 -1
- package/lib/init/template/multitenancy/index.js +18 -3
- package/lib/init/template/notifications/index.js +2 -2
- package/lib/init/template/portal/files/mta.yaml.hbs +4 -0
- package/lib/init/template/portal/index.js +13 -8
- package/lib/init/template/postgres/index.js +2 -2
- package/lib/init/template/redis/index.js +2 -2
- package/lib/init/template/sample/files/db/currencies.cds +2 -0
- package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Authors.csv +1 -1
- package/lib/init/template/tiny-sample/files/nodejs/db/data/CatalogService.Books.csv +2 -2
- package/lib/init/template/workzone-standard/index.js +5 -5
- package/lib/init/template/xsuaa/index.js +20 -2
- package/lib/lint/eslintHelp.json +1 -1
- package/lib/mtx/auth_manager.js +103 -37
- package/lib/mtx/params.js +3 -2
- package/lib/mtx/settings_manager.js +45 -28
- package/lib/mtx/tenant_action.js +0 -1
- package/lib/mtx/util/credentials.js +62 -0
- package/node_modules/@cap-js/db-service/CHANGELOG.md +17 -0
- package/node_modules/@cap-js/db-service/lib/common/generic-pool.js +4 -7
- package/node_modules/@cap-js/db-service/lib/cqn2pql.js +1 -1
- package/node_modules/@cap-js/db-service/lib/cqn2sql.js +15 -11
- package/node_modules/@cap-js/db-service/lib/cqn4sql.js +119 -19
- package/node_modules/@cap-js/db-service/lib/infer/index.js +27 -16
- package/node_modules/@cap-js/db-service/lib/recursion-guard.js +40 -0
- package/node_modules/@cap-js/db-service/lib/search.js +1 -1
- package/node_modules/@cap-js/db-service/package.json +1 -1
- package/node_modules/@cap-js/sqlite/CHANGELOG.md +19 -0
- package/node_modules/@cap-js/sqlite/lib/SQLiteService.js +110 -14
- package/node_modules/@cap-js/sqlite/package.json +3 -3
- package/node_modules/@sap/cds/CHANGELOG.md +57 -0
- package/node_modules/@sap/cds/app/index.js +5 -4
- package/node_modules/@sap/cds/eslint.config.mjs +1 -0
- package/node_modules/@sap/cds/lib/compile/minify.js +14 -10
- package/node_modules/@sap/cds/lib/env/cds-env.js +1 -1
- package/node_modules/@sap/cds/lib/env/cds-requires.js +22 -11
- package/node_modules/@sap/cds/lib/env/defaults.js +4 -1
- package/node_modules/@sap/cds/lib/env/schemas/cds-rc.js +5 -2
- package/node_modules/@sap/cds/lib/plugins.js +9 -5
- package/node_modules/@sap/cds/lib/req/spawn.js +1 -1
- package/node_modules/@sap/cds/lib/srv/srv-dispatch.js +1 -1
- package/node_modules/@sap/cds/lib/srv/srv-models.js +1 -1
- package/node_modules/@sap/cds/lib/utils/cds-utils.js +2 -1
- package/node_modules/@sap/cds/libx/_runtime/common/generic/assert.js +2 -3
- package/node_modules/@sap/cds/libx/_runtime/common/generic/auth/restrict.js +8 -1
- package/node_modules/@sap/cds/libx/_runtime/common/generic/crud.js +18 -8
- package/node_modules/@sap/cds/libx/_runtime/fiori/lean-draft.js +25 -17
- package/node_modules/@sap/cds/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +9 -3
- package/node_modules/@sap/cds/libx/_runtime/remote/Service.js +4 -19
- package/node_modules/@sap/cds/libx/_runtime/remote/utils/LruCache.js +42 -0
- package/node_modules/@sap/cds/libx/_runtime/remote/utils/client.js +14 -4
- package/node_modules/@sap/cds/libx/_runtime/remote/utils/cloudSdkProvider.js +2 -9
- package/node_modules/@sap/cds/libx/_runtime/remote/utils/destinationClient.js +150 -0
- package/node_modules/@sap/cds/libx/_runtime/remote/utils/error.js +13 -0
- package/node_modules/@sap/cds/libx/_runtime/remote/utils/fetchClient.js +26 -18
- package/node_modules/@sap/cds/libx/_runtime/remote/utils/query.js +34 -23
- package/node_modules/@sap/cds/libx/_runtime/remote/utils/token.js +82 -0
- package/node_modules/@sap/cds/libx/_runtime/ucl/Service.js +36 -189
- package/node_modules/@sap/cds/libx/common/utils/streaming.js +16 -16
- package/node_modules/@sap/cds/libx/http/location.js +3 -3
- package/node_modules/@sap/cds/libx/odata/middleware/batch.js +16 -10
- package/node_modules/@sap/cds/libx/odata/middleware/metadata.js +9 -6
- package/node_modules/@sap/cds/libx/odata/middleware/service-document.js +1 -1
- package/node_modules/@sap/cds/libx/odata/parse/afterburner.js +19 -3
- package/node_modules/@sap/cds/libx/odata/parse/cqn2odata.js +83 -86
- package/node_modules/@sap/cds/libx/queue/SchedulingService.js +17 -2
- package/node_modules/@sap/cds/libx/queue/processing.js +1 -3
- package/node_modules/@sap/cds/libx/rest/RestAdapter.js +3 -7
- package/node_modules/@sap/cds/libx/rest/middleware/delete.js +3 -3
- package/node_modules/@sap/cds/libx/rest/middleware/parse.js +13 -8
- package/node_modules/@sap/cds/libx/rest/middleware/read.js +3 -3
- package/node_modules/@sap/cds/libx/rest/middleware/upsert.js +2 -2
- package/node_modules/@sap/cds/package.json +1 -1
- package/node_modules/@sap/cds-compiler/CHANGELOG.md +75 -8
- package/node_modules/@sap/cds-compiler/bin/cdsc.js +2 -2
- package/node_modules/@sap/cds-compiler/doc/IncompatibleChanges_v7.md +46 -19
- package/node_modules/@sap/cds-compiler/lib/api/main.js +10 -7
- package/node_modules/@sap/cds-compiler/lib/api/options.js +8 -2
- package/node_modules/@sap/cds-compiler/lib/base/csnRefs.js +5 -2
- package/node_modules/@sap/cds-compiler/lib/base/message-registry.js +4 -0
- package/node_modules/@sap/cds-compiler/lib/base/optionProcessor.js +12 -0
- package/node_modules/@sap/cds-compiler/lib/checks/enricher.js +1 -0
- package/node_modules/@sap/cds-compiler/lib/compiler/assert-consistency.js +8 -7
- package/node_modules/@sap/cds-compiler/lib/compiler/checks.js +3 -3
- package/node_modules/@sap/cds-compiler/lib/compiler/define.js +301 -75
- package/node_modules/@sap/cds-compiler/lib/compiler/dictionaries.js +2 -0
- package/node_modules/@sap/cds-compiler/lib/compiler/extend.js +40 -26
- package/node_modules/@sap/cds-compiler/lib/compiler/populate.js +45 -60
- package/node_modules/@sap/cds-compiler/lib/compiler/propagator.js +16 -7
- package/node_modules/@sap/cds-compiler/lib/compiler/resolve.js +48 -18
- package/node_modules/@sap/cds-compiler/lib/compiler/shared.js +7 -6
- package/node_modules/@sap/cds-compiler/lib/compiler/tweak-assocs.js +62 -50
- package/node_modules/@sap/cds-compiler/lib/compiler/utils.js +29 -14
- package/node_modules/@sap/cds-compiler/lib/edm/edmAnnoPreprocessor.js +6 -5
- package/node_modules/@sap/cds-compiler/lib/gen/CdlGrammar.checksum +1 -1
- package/node_modules/@sap/cds-compiler/lib/gen/CdlParser.js +1119 -1109
- package/node_modules/@sap/cds-compiler/lib/gen/Dictionary.json +19 -3
- package/node_modules/@sap/cds-compiler/lib/json/from-csn.js +10 -16
- package/node_modules/@sap/cds-compiler/lib/json/to-csn.js +58 -39
- package/node_modules/@sap/cds-compiler/lib/main.d.ts +8 -0
- package/node_modules/@sap/cds-compiler/lib/main.js +1 -0
- package/node_modules/@sap/cds-compiler/lib/model/csnUtils.js +4 -0
- package/node_modules/@sap/cds-compiler/lib/parsers/AstBuildingParser.js +2 -1
- package/node_modules/@sap/cds-compiler/lib/parsers/XprTree.js +8 -0
- package/node_modules/@sap/cds-compiler/lib/render/toCdl.js +22 -1
- package/node_modules/@sap/cds-compiler/lib/render/toSql.js +17 -2
- package/node_modules/@sap/cds-compiler/lib/render/utils/common.js +6 -1
- package/node_modules/@sap/cds-compiler/lib/render/utils/operators.js +27 -0
- package/node_modules/@sap/cds-compiler/lib/render/utils/standardDatabaseFunctions.js +125 -3
- package/node_modules/@sap/cds-compiler/lib/tool-lib/revealInternalProperties.js +2 -1
- package/node_modules/@sap/cds-compiler/lib/transform/db/applyTransformations.js +15 -0
- package/node_modules/@sap/cds-compiler/lib/transform/db/associations.js +10 -2
- package/node_modules/@sap/cds-compiler/lib/transform/db/backlinks.js +22 -6
- package/node_modules/@sap/cds-compiler/lib/transform/db/constraints.js +62 -1
- package/node_modules/@sap/cds-compiler/lib/transform/db/flattening.js +4 -3
- package/node_modules/@sap/cds-compiler/lib/transform/effective/annotations.js +40 -0
- package/node_modules/@sap/cds-compiler/lib/transform/effective/flattening.js +17 -1
- package/node_modules/@sap/cds-compiler/lib/transform/effective/main.js +20 -0
- package/node_modules/@sap/cds-compiler/lib/transform/fioriTreeViews.js +12 -1
- package/node_modules/@sap/cds-compiler/lib/transform/forRelationalDB.js +7 -2
- package/node_modules/@sap/cds-compiler/lib/transform/odata/adaptAnnotationRefs.js +11 -5
- package/node_modules/@sap/cds-compiler/lib/transform/translateAssocsToJoins.js +48 -10
- package/node_modules/@sap/cds-compiler/package.json +1 -1
- package/node_modules/@sap/cds-mtxs/CHANGELOG.md +49 -0
- package/node_modules/@sap/cds-mtxs/bin/cds-mtx-migrate.js +26 -5
- package/node_modules/@sap/cds-mtxs/bin/cds-mtx.js +37 -16
- package/node_modules/@sap/cds-mtxs/lib/utils.js +23 -7
- package/node_modules/@sap/cds-mtxs/package.json +1 -1
- package/node_modules/@sap/cds-mtxs/srv/cf/abstract-provisioning-service.js +63 -8
- package/node_modules/@sap/cds-mtxs/srv/cf/saas-provisioning-service.js +1 -1
- package/node_modules/@sap/cds-mtxs/srv/cf/sms-provisioning-service.js +23 -3
- package/node_modules/@sap/cds-mtxs/srv/extensibility/compat/update.js +15 -0
- package/node_modules/@sap/cds-mtxs/srv/extensibility/linter/annotations.js +2 -2
- package/node_modules/@sap/cds-mtxs/srv/extensibility/linter/config.js +2 -0
- package/node_modules/@sap/cds-mtxs/srv/extensibility/linter/index.js +2 -0
- package/node_modules/@sap/cds-mtxs/srv/extensibility/linter/protected-namespace.js +45 -0
- package/node_modules/@sap/cds-mtxs/srv/extensibility-service.js +30 -16
- package/node_modules/@sap/cds-mtxs/srv/jobs-service.js +49 -10
- package/node_modules/@sap/cds-mtxs/srv/model-provider.js +28 -4
- package/node_modules/@sap/cds-mtxs/srv/plugins/common.js +19 -12
- package/node_modules/@sap/cds-mtxs/srv/plugins/hana/ctnr-mgr-base.js +1 -1
- package/node_modules/@sap/cds-mtxs/srv/plugins/hana/hdi-ctnr-mgr.js +6 -3
- package/node_modules/@sap/cds-mtxs/srv/plugins/hana/serverless.js +271 -0
- package/node_modules/@sap/cds-mtxs/srv/plugins/hana.js +7 -10
- package/node_modules/@sap/cds-mtxs/srv/worker/job-worker-pool.js +212 -0
- package/node_modules/@sap/cds-mtxs/srv/worker/job-worker.js +61 -0
- package/node_modules/@sap/xsenv/CHANGELOG.md +7 -0
- package/node_modules/@sap/xsenv/package.json +10 -7
- package/node_modules/body-parser/node_modules/content-type/README.md +2 -0
- package/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/body-parser/node_modules/content-type/package.json +1 -1
- package/node_modules/hdb/cfg/VERSION +1 -1
- package/node_modules/hdb/lib/protocol/ClientInfo.js +16 -3
- package/node_modules/hdb/lib/protocol/Connection.js +1 -0
- package/node_modules/hdb/package.json +3 -2
- package/node_modules/negotiator/lib/accept.js +54 -0
- package/node_modules/negotiator/lib/charset.js +10 -34
- package/node_modules/negotiator/lib/encoding.js +9 -30
- package/node_modules/negotiator/lib/language.js +15 -36
- package/node_modules/negotiator/lib/mediaType.js +16 -134
- package/node_modules/negotiator/node_modules/content-type/LICENSE +22 -0
- package/node_modules/negotiator/node_modules/content-type/README.md +71 -0
- package/node_modules/negotiator/node_modules/content-type/dist/index.d.ts +46 -0
- package/node_modules/negotiator/node_modules/content-type/dist/index.js +176 -0
- package/node_modules/negotiator/node_modules/content-type/dist/index.js.map +1 -0
- package/node_modules/negotiator/node_modules/content-type/package.json +52 -0
- package/node_modules/negotiator/package.json +16 -10
- package/node_modules/qs/.github/THREAT_MODEL.md +3 -3
- package/node_modules/qs/CHANGELOG.md +15 -0
- package/node_modules/qs/README.md +19 -1
- package/node_modules/qs/dist/qs.js +21 -21
- package/node_modules/qs/eslint.config.mjs +1 -1
- package/node_modules/qs/lib/parse.js +3 -4
- package/node_modules/qs/lib/stringify.js +23 -8
- package/node_modules/qs/lib/utils.js +10 -3
- package/node_modules/qs/package.json +4 -4
- package/node_modules/qs/test/parse.js +192 -3
- package/node_modules/qs/test/stringify.js +317 -0
- package/node_modules/qs/test/utils.js +12 -0
- package/node_modules/type-is/node_modules/content-type/README.md +2 -0
- package/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/type-is/node_modules/content-type/package.json +1 -1
- package/node_modules/ws/lib/permessage-deflate.js +3 -1
- package/node_modules/ws/package.json +1 -1
- package/package.json +2 -2
- package/bin/completion/scripts/cds-bash.sh +0 -20
- package/bin/completion/scripts/cds-fish.fish +0 -13
- package/bin/completion/scripts/cds-ps.ps1 +0 -19
- package/bin/completion/scripts/cds-zsh.sh +0 -13
- package/lib/deploy/index.js +0 -25
- package/lib/import/asyncapi/importAsyncAPI.js +0 -33
- package/lib/import/asyncapi/index.js +0 -18
- package/lib/import/asyncapi/parserContext.js +0 -454
- package/lib/import/asyncapi/utils.js +0 -49
- package/node_modules/@sap/cds/libx/_runtime/ucl/queries.js +0 -61
- package/node_modules/negotiator/HISTORY.md +0 -114
- /package/{lib → bin}/upgrade/context.js +0 -0
- /package/{lib → bin}/upgrade/migrations/cds10/migrations.json +0 -0
- /package/{lib → bin}/upgrade/preflight/cds-version.js +0 -0
- /package/{lib → bin}/upgrade/preflight/project-type.js +0 -0
- /package/{lib → bin}/upgrade/steps/analyze/classification.js +0 -0
- /package/{lib → bin}/upgrade/steps/analyze/detector.js +0 -0
- /package/{lib → bin}/upgrade/steps/analyze/evaluator.js +0 -0
- /package/{lib → bin}/upgrade/steps/analyze/reporter.js +0 -0
- /package/{lib → bin}/upgrade/steps/analyze/setup.js +0 -0
- /package/{lib → bin}/upgrade/steps/analyze/utils/detection.js +0 -0
- /package/{lib → bin}/upgrade/steps/analyze/utils/files.js +0 -0
- /package/{lib → bin}/upgrade/steps/analyze/utils/grep.js +0 -0
- /package/{lib → bin}/upgrade/steps/analyze/utils/yaml.js +0 -0
- /package/{lib → bin}/upgrade/util/workspaces.js +0 -0
- /package/{lib → bin}/watch/esm-resolve-registration.js +0 -0
- /package/{lib → bin}/watch/livereload-server.js +0 -0
- /package/{lib → bin}/watch/node-watch.js +0 -0
- /package/{lib → bin}/watch/open.js +0 -0
- /package/{lib → bin}/watch/watcher.js +0 -0
- /package/node_modules/@sap/cds-mtxs/srv/worker/{pool.js → model-worker-pool.js} +0 -0
- /package/node_modules/@sap/cds-mtxs/srv/worker/{load.js → model-worker.js} +0 -0
|
@@ -1112,14 +1112,12 @@
|
|
|
1112
1112
|
"Type": "Core.Tag"
|
|
1113
1113
|
},
|
|
1114
1114
|
"Common.WebSocketBaseURL": {
|
|
1115
|
-
"$experimental": true,
|
|
1116
1115
|
"AppliesTo": [
|
|
1117
1116
|
"EntityContainer"
|
|
1118
1117
|
],
|
|
1119
1118
|
"Type": "Edm.String"
|
|
1120
1119
|
},
|
|
1121
1120
|
"Common.WebSocketChannel": {
|
|
1122
|
-
"$experimental": true,
|
|
1123
1121
|
"AppliesTo": [
|
|
1124
1122
|
"EntityContainer"
|
|
1125
1123
|
],
|
|
@@ -1795,6 +1793,13 @@
|
|
|
1795
1793
|
],
|
|
1796
1794
|
"Type": "UI.BadgeType"
|
|
1797
1795
|
},
|
|
1796
|
+
"UI.CardItem": {
|
|
1797
|
+
"$experimental": true,
|
|
1798
|
+
"AppliesTo": [
|
|
1799
|
+
"EntityType"
|
|
1800
|
+
],
|
|
1801
|
+
"Type": "UI.CardItemType"
|
|
1802
|
+
},
|
|
1798
1803
|
"UI.Chart": {
|
|
1799
1804
|
"AppliesTo": [
|
|
1800
1805
|
"EntityType"
|
|
@@ -1897,7 +1902,6 @@
|
|
|
1897
1902
|
"Type": "Edm.Boolean"
|
|
1898
1903
|
},
|
|
1899
1904
|
"UI.Emphasized": {
|
|
1900
|
-
"$experimental": true,
|
|
1901
1905
|
"AppliesTo": [
|
|
1902
1906
|
"Record"
|
|
1903
1907
|
],
|
|
@@ -3443,6 +3447,9 @@
|
|
|
3443
3447
|
"Properties": {
|
|
3444
3448
|
"Discretionary": "Edm.Boolean",
|
|
3445
3449
|
"SourceEntities": "Collection(Edm.NavigationPropertyPath)",
|
|
3450
|
+
"SourceEntitiesDeleted": "Collection(Edm.NavigationPropertyPath)",
|
|
3451
|
+
"SourceEntitiesInserted": "Collection(Edm.NavigationPropertyPath)",
|
|
3452
|
+
"SourceEntitiesUpdated": "Collection(Edm.NavigationPropertyPath)",
|
|
3446
3453
|
"SourceEvents": "Collection(Edm.String)",
|
|
3447
3454
|
"SourceProperties": "Collection(Edm.PropertyPath)",
|
|
3448
3455
|
"TargetEntities": "Collection(Edm.NavigationPropertyPath)",
|
|
@@ -4312,6 +4319,15 @@
|
|
|
4312
4319
|
"TypeImageUrl": "Edm.String"
|
|
4313
4320
|
}
|
|
4314
4321
|
},
|
|
4322
|
+
"UI.CardItemType": {
|
|
4323
|
+
"$experimental": true,
|
|
4324
|
+
"$kind": "ComplexType",
|
|
4325
|
+
"Properties": {
|
|
4326
|
+
"Actions": "Collection(UI.DataFieldAbstract)",
|
|
4327
|
+
"Details": "Collection(UI.Facet)",
|
|
4328
|
+
"Header": "Edm.AnnotationPath"
|
|
4329
|
+
}
|
|
4330
|
+
},
|
|
4315
4331
|
"UI.ChartAxisAutoScaleBehaviorType": {
|
|
4316
4332
|
"$kind": "ComplexType",
|
|
4317
4333
|
"Properties": {
|
|
@@ -596,6 +596,7 @@ const schema = compileSchema( {
|
|
|
596
596
|
any: { type: asQuantifier }, // probably just CSN v0.1.0
|
|
597
597
|
distinct: { type: asQuantifier },
|
|
598
598
|
all: { type: asQuantifier },
|
|
599
|
+
one: { type: boolOrNull },
|
|
599
600
|
// further query properties: -----------------------------------------------
|
|
600
601
|
excluding: {
|
|
601
602
|
inKind: [ '$column' ],
|
|
@@ -1661,16 +1662,11 @@ function args( exprs, spec ) {
|
|
|
1661
1662
|
|
|
1662
1663
|
function expr( e, spec ) {
|
|
1663
1664
|
if (Array.isArray( e )) {
|
|
1664
|
-
if (e.length > 1)
|
|
1665
|
+
if (e.length > 1) // parse CSN produced with option 'structXpr'
|
|
1666
|
+
return condition( e, spec );
|
|
1667
|
+
if (e.length === 1) { // CSN v.0.1.0 way for parentheses
|
|
1665
1668
|
const loc = location();
|
|
1666
|
-
|
|
1667
|
-
return (e.length < 3) // optimization
|
|
1668
|
-
? { op: { val: 'ixpr', location: loc }, args: xsn, location: loc }
|
|
1669
|
-
: xsnAsTree( e, xsn, loc );
|
|
1670
|
-
}
|
|
1671
|
-
else if (e.length === 1) { // CSN v.0.1.0 way for parentheses
|
|
1672
|
-
const loc = location();
|
|
1673
|
-
if (e[0] && !e[0].op) // do not complain with 'op' (for which we complain)
|
|
1669
|
+
if (e[0] && !e[0].op) // do not complain with 'op' (for which we complain)
|
|
1674
1670
|
replaceZeroValue( spec, 'zero-parens' );
|
|
1675
1671
|
++virtualLine;
|
|
1676
1672
|
const r = expr( e[0], spec );
|
|
@@ -1714,13 +1710,9 @@ function exprArgs( cond, spec ) {
|
|
|
1714
1710
|
function condition( cond, spec ) {
|
|
1715
1711
|
const loc = location();
|
|
1716
1712
|
const xsn = exprArgs( cond, spec );
|
|
1717
|
-
//
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
return { op: { val: 'xpr', location: loc }, args: tree, location: loc };
|
|
1721
|
-
// return (cond.length < 3) // optimization
|
|
1722
|
-
// ? { op: { val: 'ixpr', location: loc }, args: xsn, location: loc }
|
|
1723
|
-
// : xsnAsTree( cond, xsn, loc );
|
|
1713
|
+
return (cond.length < 3) // nothing to structurize with 1 or 2 nodes
|
|
1714
|
+
? { op: { val: 'ixpr', location: loc }, args: xsn, location: loc }
|
|
1715
|
+
: xsnAsTree( cond, xsn, loc );
|
|
1724
1716
|
}
|
|
1725
1717
|
|
|
1726
1718
|
// Queries (std signature) ---------------------------------------------------
|
|
@@ -1892,6 +1884,8 @@ function calculateKind( def, spec, xsn ) {
|
|
|
1892
1884
|
}
|
|
1893
1885
|
if (spec.prop === 'extensions') {
|
|
1894
1886
|
inExtensions = (def.extend) ? '' : 'annotate';
|
|
1887
|
+
if (def.extend && Object.keys( def ).length === 1)
|
|
1888
|
+
xsn.$syntax = 'empty'; // for Warning instead Error with undefined ref
|
|
1895
1889
|
return (def.extend) ? 'extend' : 'annotate';
|
|
1896
1890
|
}
|
|
1897
1891
|
const kind = (def.kind === 'view') ? 'entity' : def.kind; // 'view' is CSN v0.1.0
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
const { locationString } = require('../base/messages');
|
|
15
15
|
const { isBetaEnabled } = require('../base/specialOptions');
|
|
16
|
-
const { pathName, hasSpecialPathItemProp } = require('../compiler/utils');
|
|
16
|
+
const { pathName, hasSpecialPathItemProp, isLeadingQuery } = require('../compiler/utils');
|
|
17
|
+
const { dictFirst } = require('../compiler/dictionaries');
|
|
17
18
|
const { CompilerAssertion } = require('../base/error');
|
|
18
19
|
|
|
19
20
|
const compilerVersion = require('../../package.json').version;
|
|
@@ -70,6 +71,7 @@ const transformers = {
|
|
|
70
71
|
csn[q.val] = true;
|
|
71
72
|
},
|
|
72
73
|
all: ignore, // XSN TODO use quantifier
|
|
74
|
+
one: value,
|
|
73
75
|
// type properties (without 'elements') ------------------------------------
|
|
74
76
|
localized: value,
|
|
75
77
|
type,
|
|
@@ -114,6 +116,7 @@ const transformers = {
|
|
|
114
116
|
rows: expression,
|
|
115
117
|
offset: expression,
|
|
116
118
|
on: onCondition,
|
|
119
|
+
$backlink: backlink,
|
|
117
120
|
// definitions, extensions, members ----------------------------------------
|
|
118
121
|
notNull: value,
|
|
119
122
|
default: expression,
|
|
@@ -248,10 +251,10 @@ function compactModel( model, options = model.options || {} ) {
|
|
|
248
251
|
set( 'i18n', csn, model );
|
|
249
252
|
set( 'sources', csn, model );
|
|
250
253
|
// Set $location, use $extra properties of first source as resulting $extra properties
|
|
251
|
-
const
|
|
252
|
-
if (
|
|
253
|
-
const firstSource = srcDict[firstSourceName];
|
|
254
|
+
const firstSource = dictFirst( srcDict );
|
|
255
|
+
if (firstSource) {
|
|
254
256
|
const loc = firstSource.location;
|
|
257
|
+
|
|
255
258
|
if (loc && loc.file) {
|
|
256
259
|
Object.defineProperty( csn, '$location', {
|
|
257
260
|
value: { file: loc.file }, configurable: true, writable: true, enumerable: withLocations,
|
|
@@ -545,7 +548,7 @@ function enumDict( dict, csn, node ) {
|
|
|
545
548
|
}
|
|
546
549
|
|
|
547
550
|
function enumerableQueryElements( select ) {
|
|
548
|
-
return (universalCsn && select
|
|
551
|
+
return (universalCsn && !isLeadingQuery( select ));
|
|
549
552
|
}
|
|
550
553
|
|
|
551
554
|
// Should we render the elements? (and enum, items?)
|
|
@@ -688,16 +691,17 @@ function dictionary( dict, keys, prop ) {
|
|
|
688
691
|
function foreignKeys( dict, csn, node ) {
|
|
689
692
|
if (!dict || // `Association to many Target` without specified keys
|
|
690
693
|
universalCsn && dict[$inferred] === 'keys' ||
|
|
691
|
-
!target( node.target, csn, node )
|
|
694
|
+
!target( node.target, csn, node ) ||
|
|
695
|
+
gensrcFlavor && dict[$inferred])
|
|
692
696
|
return;
|
|
697
|
+
fkeys( dict, csn );
|
|
698
|
+
}
|
|
693
699
|
|
|
694
|
-
|
|
695
|
-
if (dict[$inferred])
|
|
696
|
-
return;
|
|
697
|
-
}
|
|
700
|
+
function fkeys( dict, csn = {} ) {
|
|
698
701
|
csn.keys = [];
|
|
699
702
|
for (const n in dict)
|
|
700
703
|
csn.keys.push( definition( dict[n] ) );
|
|
704
|
+
return csn;
|
|
701
705
|
}
|
|
702
706
|
|
|
703
707
|
function returns( art, csn, node, prop ) {
|
|
@@ -733,21 +737,6 @@ function definition( art, csn, _node, prop ) {
|
|
|
733
737
|
return c;
|
|
734
738
|
}
|
|
735
739
|
|
|
736
|
-
/**
|
|
737
|
-
* Create $origin specification for query/projection.
|
|
738
|
-
*/
|
|
739
|
-
function queryOrigin( xsn ) {
|
|
740
|
-
const source = xsn._from[0]._origin;
|
|
741
|
-
let $origin;
|
|
742
|
-
if (xsn.includes)
|
|
743
|
-
// includesOrigin() does originRef() on the first include.
|
|
744
|
-
// Use it to behave the same as entity includes.
|
|
745
|
-
$origin = includesOrigin( [ { _artifact: source }, ...xsn.includes ], xsn );
|
|
746
|
-
else
|
|
747
|
-
$origin = originRef( source );
|
|
748
|
-
return $origin;
|
|
749
|
-
}
|
|
750
|
-
|
|
751
740
|
/**
|
|
752
741
|
* Create $origin specification for `includes` of `art`.
|
|
753
742
|
*/
|
|
@@ -807,9 +796,16 @@ function addOrigin( csn, xsn, node ) {
|
|
|
807
796
|
csn.$source = null;
|
|
808
797
|
return;
|
|
809
798
|
}
|
|
810
|
-
if (xsn.
|
|
811
|
-
|
|
812
|
-
|
|
799
|
+
if (xsn.query) {
|
|
800
|
+
let source = xsn._origin; // table alias of leading query
|
|
801
|
+
while (source?._main) // source is still a query
|
|
802
|
+
source = source._origin;
|
|
803
|
+
if (!source)
|
|
804
|
+
return;
|
|
805
|
+
csn.$origin = (xsn.includes)
|
|
806
|
+
? includesOrigin( [ { _artifact: source }, ...xsn.includes ], xsn )
|
|
807
|
+
: originRef( source );
|
|
808
|
+
|
|
813
809
|
if (source.params && !xsn.params)
|
|
814
810
|
csn.params = null; // discontinue `params` inheritance
|
|
815
811
|
if (source.actions && !xsn.actions)
|
|
@@ -843,7 +839,7 @@ function addOrigin( csn, xsn, node ) {
|
|
|
843
839
|
// console.log( 'X:',xsn, origin, parent, parentOrigin, getParent( origin ) );
|
|
844
840
|
if (!origin) {
|
|
845
841
|
if (parent && parentOrigin &&
|
|
846
|
-
(parent.kind !== 'select' || parent
|
|
842
|
+
(parent.kind !== 'select' || isLeadingQuery( parent )) &&
|
|
847
843
|
!(parent.enum && !parent.$origin && parent.type))
|
|
848
844
|
csn.$origin = null;
|
|
849
845
|
return;
|
|
@@ -937,7 +933,7 @@ function inferredPropertiesForOrigin( csn, node ) {
|
|
|
937
933
|
function getParent( art ) {
|
|
938
934
|
const parent = art._parent;
|
|
939
935
|
const main = parent._main;
|
|
940
|
-
return (main && parent
|
|
936
|
+
return (main && isLeadingQuery( parent )) ? main : parent;
|
|
941
937
|
}
|
|
942
938
|
|
|
943
939
|
function isMember( art ) {
|
|
@@ -952,15 +948,18 @@ function isMember( art ) {
|
|
|
952
948
|
// return main;
|
|
953
949
|
// }
|
|
954
950
|
|
|
955
|
-
// XSN `_origin` is
|
|
951
|
+
// XSN `_origin` is not the same as _origin in Universal CSN...
|
|
956
952
|
// TODO: at least with expand, set it correctly (alias: keep, assoc: to entity, $builtin: no)
|
|
957
953
|
function getOrigin( art ) {
|
|
958
954
|
if (art.$noOrigin)
|
|
959
955
|
return undefined;
|
|
960
956
|
const { _origin } = art;
|
|
961
|
-
if (_origin)
|
|
962
|
-
|
|
963
|
-
|
|
957
|
+
if (_origin) { // also for query entities
|
|
958
|
+
// eslint-disable-next-line no-nested-ternary
|
|
959
|
+
return (_origin.kind === 'builtin')
|
|
960
|
+
? undefined
|
|
961
|
+
: (_origin.kind === '$tableAlias') ? _origin._origin : _origin;
|
|
962
|
+
}
|
|
964
963
|
if (hasExplicitProp( art.type, 'cast' ))
|
|
965
964
|
return art.type._artifact;
|
|
966
965
|
// must come after checking _origin, since entities can have both queries and
|
|
@@ -994,7 +993,7 @@ function originRef( art, user ) {
|
|
|
994
993
|
r.push( !nkind ? name.id : name.id ? { [nkind]: name.id } : { returns: true } );
|
|
995
994
|
parent = parent._parent;
|
|
996
995
|
}
|
|
997
|
-
if (user && parent._main && parent._main === user._main && parent
|
|
996
|
+
if (user && parent._main && parent._main === user._main && !isLeadingQuery( parent ))
|
|
998
997
|
// well, an element of an query in FROM (TODO: try with sub elem), but not the leading query
|
|
999
998
|
return false; // do not write, probably use $origin: {...}
|
|
1000
999
|
// for sub query in FROM in sub query in FROM, we could condense the info
|
|
@@ -1239,6 +1238,12 @@ function onCondition( cond ) {
|
|
|
1239
1238
|
return condition( cond );
|
|
1240
1239
|
}
|
|
1241
1240
|
|
|
1241
|
+
function backlink( back, _csn, xsn ) {
|
|
1242
|
+
if (back._redirected?.length && !gensrcFlavor && xsn?._main?.kind === 'entity')
|
|
1243
|
+
return (back.on) ? condition( back.on ) : fkeys( back.foreignKeys );
|
|
1244
|
+
return undefined;
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1242
1247
|
function condition( node ) {
|
|
1243
1248
|
const expr = exprInternal( node, 'no' );
|
|
1244
1249
|
return (Array.isArray( expr ))
|
|
@@ -1309,9 +1314,17 @@ function exprInternal( node, xprParens ) {
|
|
|
1309
1314
|
return cast( expression( node.args[0] ), node );
|
|
1310
1315
|
case 'list':
|
|
1311
1316
|
return extra( { list: node.args.map( expression ) }, node, 0 );
|
|
1317
|
+
case 'and':
|
|
1318
|
+
for (const arg of node.args) {
|
|
1319
|
+
if (arg.$parens?.length)
|
|
1320
|
+
continue;
|
|
1321
|
+
if ((arg.op?.val === 'nary' || arg.op?.val === 'ixpr') &&
|
|
1322
|
+
arg.args[1]?.val === 'or' &&
|
|
1323
|
+
arg.args[1]?.literal === 'token')
|
|
1324
|
+
arg.$parens = [ arg.location ];
|
|
1325
|
+
}
|
|
1326
|
+
// FALLTHROUGH
|
|
1312
1327
|
default: { // CSN v0 input (A2J: '='/'and'): binary (n-ary) and unary prefix
|
|
1313
|
-
if (!node.args.length)
|
|
1314
|
-
return { xpr: [] };
|
|
1315
1328
|
const nary = [];
|
|
1316
1329
|
for (const item of node.args)
|
|
1317
1330
|
nary.push( { val, literal: 'token' }, item );
|
|
@@ -1323,10 +1336,16 @@ function exprInternal( node, xprParens ) {
|
|
|
1323
1336
|
};
|
|
1324
1337
|
}
|
|
1325
1338
|
}
|
|
1339
|
+
if (!node.args?.length)
|
|
1340
|
+
return { xpr: [] };
|
|
1326
1341
|
const rargs = node.args.map( exprInternal );
|
|
1327
1342
|
if (val === 'xpr' || node.$parens)
|
|
1328
1343
|
return extra( { xpr: flattenInternalXpr( rargs, val ) }, node, (xprParens === 'no' ? 0 : 1) );
|
|
1329
|
-
|
|
1344
|
+
// An 1-item 'ixpr' or 'nary' can (in general) be replaced by that one item.
|
|
1345
|
+
// For lower *.sql diffs, not for 'xpr' in 'ixpr', produced before A2J recompilation.
|
|
1346
|
+
return rargs.length === 1 && !rargs[0].xpr
|
|
1347
|
+
? rargs[0]
|
|
1348
|
+
: flattenInternalXpr( rargs, val );
|
|
1330
1349
|
}
|
|
1331
1350
|
|
|
1332
1351
|
|
|
@@ -1391,7 +1410,7 @@ function query( node, csn, xsn, _prop, expectedParens = 0 ) {
|
|
|
1391
1410
|
const select = { SELECT: extra( standard( node ), node, expectedParens ) };
|
|
1392
1411
|
// one paren pair is not put into XSN - TODO: change that?
|
|
1393
1412
|
const elems = node.elements;
|
|
1394
|
-
if (elems && node._main && node
|
|
1413
|
+
if (elems && node._main && !isLeadingQuery( node ) && gensrcFlavor !== true) {
|
|
1395
1414
|
// Set hidden 'elements' for csnRefs.js. In select-item subqueries,
|
|
1396
1415
|
// gensrcFlavor might have been set to 'column' and must be set to the
|
|
1397
1416
|
// original value 'false' - otherwise no element appears.
|
|
@@ -345,6 +345,14 @@ declare namespace compiler {
|
|
|
345
345
|
* @default true
|
|
346
346
|
*/
|
|
347
347
|
resolveProjections?: boolean
|
|
348
|
+
/**
|
|
349
|
+
* If true, stringify annotation expression nodes as CDL-like text.
|
|
350
|
+
*
|
|
351
|
+
* Only expression-shaped nodes are stringified. Other annotation values stay unchanged.
|
|
352
|
+
*
|
|
353
|
+
* @default false
|
|
354
|
+
*/
|
|
355
|
+
stringifyAnnoXpr?: boolean
|
|
348
356
|
/**
|
|
349
357
|
* If true, remap OData annotations to ABAP annotations.
|
|
350
358
|
*
|
|
@@ -200,6 +200,7 @@ module.exports = {
|
|
|
200
200
|
compile: (...args) => compiler.compileX(...args),
|
|
201
201
|
compileSync: (...args) => compiler.compileSyncX(...args),
|
|
202
202
|
getArtifactName: art => base.getArtifactName(art),
|
|
203
|
+
getOrigin: art => (art._origin?.kind === '$tableAlias' ? art._origin._origin : art._origin),
|
|
203
204
|
traverseSemanticTokens: (xsn, options) => lsp.traverseSemanticTokens(xsn, options),
|
|
204
205
|
getSemanticTokenOrigin: obj => lsp.getSemanticTokenOrigin(obj),
|
|
205
206
|
xsnToCsn: ( xsn, options ) => toCsn.compactModel( xsn, options ),
|
|
@@ -8,6 +8,7 @@ const {
|
|
|
8
8
|
applyTransformationsOnNonDictionary,
|
|
9
9
|
applyTransformationsOnDictionary,
|
|
10
10
|
mergeTransformers,
|
|
11
|
+
isSimpleAnnoExprRef,
|
|
11
12
|
} = require('../transform/db/applyTransformations');
|
|
12
13
|
const { isBuiltinType, isAnnotationExpression, primaryExprProperties } = require('../base/builtins');
|
|
13
14
|
const { ModelError, CompilerAssertion } = require('../base/error');
|
|
@@ -926,6 +927,8 @@ function setDependencies( csn ) {
|
|
|
926
927
|
const cleanup = [];
|
|
927
928
|
|
|
928
929
|
forEachDefinition(csn, (artifact, artifactName) => {
|
|
930
|
+
if (!isPersistedOnDatabase(artifact))
|
|
931
|
+
return;
|
|
929
932
|
const queries = getNormalizedQuery(artifact).query;
|
|
930
933
|
if (queries) {
|
|
931
934
|
initDependencies(artifact);
|
|
@@ -1510,6 +1513,7 @@ module.exports = {
|
|
|
1510
1513
|
applyTransformationsOnNonDictionary,
|
|
1511
1514
|
applyTransformationsOnDictionary,
|
|
1512
1515
|
mergeTransformers,
|
|
1516
|
+
isSimpleAnnoExprRef,
|
|
1513
1517
|
setDependencies,
|
|
1514
1518
|
isPersistedOnDatabase,
|
|
1515
1519
|
isPersistedAsView,
|
|
@@ -1193,7 +1193,8 @@ class AstBuildingParser extends BaseParser {
|
|
|
1193
1193
|
// see also isAnnotationExpression()
|
|
1194
1194
|
if (!dict['=']) {
|
|
1195
1195
|
const prop = dict['#'] && '#' ||
|
|
1196
|
-
dict.xpr && Object.keys( dict ).length === 1 && 'xpr'
|
|
1196
|
+
dict.xpr && Object.keys( dict ).length === 1 && 'xpr' ||
|
|
1197
|
+
dict['...'] && Object.keys( dict ).length === 1 && '...';
|
|
1197
1198
|
if (!prop)
|
|
1198
1199
|
return;
|
|
1199
1200
|
this.error( 'syntax-invalid-anno-struct', dict[prop].name.location,
|
|
@@ -262,8 +262,16 @@ function splitClauses( tree, isCsn ) {
|
|
|
262
262
|
return (new XprTree( null, tree, !!isCsn || tree.location )).splitClauses();
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
+
// Operators that make an expression a predicate (condition) rather than a value.
|
|
266
|
+
const MAX_PREDICATE_PRECEDENCE = 13;
|
|
267
|
+
const predicateOperators = new Set( [
|
|
268
|
+
...Object.keys( binaryOperators ).filter( op => binaryOperators[op] <= MAX_PREDICATE_PRECEDENCE ),
|
|
269
|
+
'exists', 'not',
|
|
270
|
+
] );
|
|
271
|
+
|
|
265
272
|
module.exports = {
|
|
266
273
|
xsnAsTree: xprAsTree,
|
|
267
274
|
csnAsTree: nodes => xprAsTree( nodes, nodes, true ),
|
|
268
275
|
splitClauses,
|
|
276
|
+
predicateOperators,
|
|
269
277
|
};
|
|
@@ -22,6 +22,7 @@ const { normalizeTypeRef, forEachDefinition } = require('../model/csnUtils');
|
|
|
22
22
|
const enrichUniversalCsn = require('../transform/universalCsn/universalCsnEnricher');
|
|
23
23
|
const { isBetaEnabled } = require('../base/specialOptions');
|
|
24
24
|
const { ModelError, CompilerAssertion } = require('../base/error');
|
|
25
|
+
const { makeMessageFunction } = require('../base/messages');
|
|
25
26
|
const { typeParameters, specialFunctions } = require('../compiler/builtins');
|
|
26
27
|
const { isAnnotationExpression } = require('../base/builtins');
|
|
27
28
|
const { forEach } = require('../utils/objectUtils');
|
|
@@ -2032,7 +2033,7 @@ class CsnToCdl {
|
|
|
2032
2033
|
: this.quotePathIfRequired(annoValue['='], env);
|
|
2033
2034
|
}
|
|
2034
2035
|
// Ellipsis: `... up to <val>`
|
|
2035
|
-
if (annoValue['...'] !== undefined) {
|
|
2036
|
+
if (annoValue['...'] !== undefined && Object.keys( annoValue ).length === 1) {
|
|
2036
2037
|
return (annoValue['...'] === true)
|
|
2037
2038
|
? '...'
|
|
2038
2039
|
: `... up to ${ this.renderAnnotationValue(annoValue['...'], env) }`;
|
|
@@ -2714,7 +2715,10 @@ class CsnToCdl {
|
|
|
2714
2715
|
* @param {CdlRenderEnvironment} env
|
|
2715
2716
|
* @returns {string}
|
|
2716
2717
|
*/
|
|
2718
|
+
// TODO: not quite sure why we split at '.' when quoting is needed
|
|
2717
2719
|
quoteAnnotationPathIfRequired( anno, env ) {
|
|
2720
|
+
if (anno === '...')
|
|
2721
|
+
return this.quoteNonIdentifier(anno, env);
|
|
2718
2722
|
return anno.split('.').map((segment) => {
|
|
2719
2723
|
if (segment.startsWith('@'))
|
|
2720
2724
|
return `@${ this.quoteNonIdentifier(segment.slice(1), env) }`;
|
|
@@ -3075,9 +3079,26 @@ function csnToCdl( csn, options, msg ) {
|
|
|
3075
3079
|
return renderer.render();
|
|
3076
3080
|
}
|
|
3077
3081
|
|
|
3082
|
+
/**
|
|
3083
|
+
* Render a CSN expression object to CDL-like text.
|
|
3084
|
+
*
|
|
3085
|
+
* @param {object} expr CSN expression node
|
|
3086
|
+
* @param {CdlOptions} [options]
|
|
3087
|
+
* @param {object} [msg] Message functions
|
|
3088
|
+
* @returns {string}
|
|
3089
|
+
*/
|
|
3090
|
+
function expressionToCdlString( expr, options = {}, msg = null ) {
|
|
3091
|
+
const model = { $version: '2.0', definitions: Object.create(null) };
|
|
3092
|
+
const messageFunctions = msg || makeMessageFunction(model, options, 'to-cdl');
|
|
3093
|
+
const renderer = new CsnToCdl(model, options, messageFunctions);
|
|
3094
|
+
const env = createEnv({ path: [] });
|
|
3095
|
+
env.nameEnvStack.setRootScope(new DefinitionPathTree(), model);
|
|
3096
|
+
return renderer.exprRenderer.renderExpr(expr, env);
|
|
3097
|
+
}
|
|
3078
3098
|
|
|
3079
3099
|
module.exports = {
|
|
3080
3100
|
csnToCdl,
|
|
3101
|
+
expressionToCdlString,
|
|
3081
3102
|
smartId: apiSmartId,
|
|
3082
3103
|
smartFunctionId: apiSmartFunctionId,
|
|
3083
3104
|
delimitedId: apiDelimitedId,
|
|
@@ -31,7 +31,7 @@ const { manageConstraints, manageConstraint } = require('./manageConstraints');
|
|
|
31
31
|
const { renderUniqueConstraintString, renderUniqueConstraintDrop, renderUniqueConstraintAdd } = require('./utils/unique');
|
|
32
32
|
const { ModelError, CompilerAssertion } = require('../base/error');
|
|
33
33
|
const { pathId } = require('../base/csnRefs');
|
|
34
|
-
const { transformExprOperators } = require('./utils/operators');
|
|
34
|
+
const { transformExprOperators, isTopLevelPredicate } = require('./utils/operators');
|
|
35
35
|
const { exprAsTree, condAsTree } = require('../base/xprAsTree');
|
|
36
36
|
|
|
37
37
|
class SqlRenderEnvironment {
|
|
@@ -1183,7 +1183,10 @@ function toSqlDdl( csn, options, messageFunctions ) {
|
|
|
1183
1183
|
if (!col.as && col.ref?.[0] && isMagicVariable(pathId(col.ref?.[0])))
|
|
1184
1184
|
col.as = implicitAs(col.ref);
|
|
1185
1185
|
|
|
1186
|
-
|
|
1186
|
+
// HANA rejects bare predicates in the select list; wrap them in CASE … WHEN.
|
|
1187
|
+
result = env.indent + ((options.sqlDialect === 'hana' && isTopLevelPredicate(col))
|
|
1188
|
+
? wrapPredicateInCase(renderExpr({ xpr: col.xpr }, env))
|
|
1189
|
+
: renderExpr(withoutCast(col), env));
|
|
1187
1190
|
if (col.as)
|
|
1188
1191
|
result += ` AS ${ quoteSqlId(col.as) }`;
|
|
1189
1192
|
else if (col.func && !col.args) // e.g. CURRENT_TIMESTAMP
|
|
@@ -1728,6 +1731,18 @@ function toSqlDdl( csn, options, messageFunctions ) {
|
|
|
1728
1731
|
}
|
|
1729
1732
|
}
|
|
1730
1733
|
|
|
1734
|
+
/**
|
|
1735
|
+
* Wrap a rendered predicate in `CASE WHEN <p> THEN TRUE WHEN NOT (<p>) THEN FALSE
|
|
1736
|
+
* END`, as HANA requires for a predicate in the select list. The negated `WHEN`
|
|
1737
|
+
* (not an `ELSE`) keeps a NULL predicate result as NULL rather than FALSE.
|
|
1738
|
+
*
|
|
1739
|
+
* @param {string} predicate Rendered predicate SQL
|
|
1740
|
+
* @return {string}
|
|
1741
|
+
*/
|
|
1742
|
+
function wrapPredicateInCase( predicate ) {
|
|
1743
|
+
return `CASE WHEN (${ predicate }) THEN TRUE WHEN NOT (${ predicate }) THEN FALSE END`;
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1731
1746
|
/**
|
|
1732
1747
|
* Render the given string for SQL databases.
|
|
1733
1748
|
*
|
|
@@ -41,7 +41,12 @@ function renderFunc( funcName, node, renderArgs, utils ) {
|
|
|
41
41
|
if (rewriteStandardFunctions) {
|
|
42
42
|
// we check function arguments for correctness
|
|
43
43
|
const { error } = messageFunctions;
|
|
44
|
-
const that = {
|
|
44
|
+
const that = {
|
|
45
|
+
renderArgs,
|
|
46
|
+
error,
|
|
47
|
+
path,
|
|
48
|
+
vector: { embeddingDefaultModel: options.vectorEmbeddingDefaultModel ?? 'SAP_GXY.20250407', embeddingHanaDefaultRemoteSource: options.vectorEmbeddingHanaDefaultRemoteSource ?? 'AI_CORE' },
|
|
49
|
+
};
|
|
45
50
|
if (standardDatabaseFunctions[sqlDialect]?.[funcName])
|
|
46
51
|
return standardDatabaseFunctions[sqlDialect][funcName].call(that, node);
|
|
47
52
|
else if (standardDatabaseFunctions.common[funcName])
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
// Utilities to transform operators in expressions for SQL rendering.
|
|
4
4
|
|
|
5
|
+
const { csnAsTree, predicateOperators } = require('../../parsers/XprTree');
|
|
6
|
+
|
|
5
7
|
const operatorsPerDialect = {
|
|
6
8
|
__proto__: null,
|
|
7
9
|
plain: {
|
|
@@ -155,6 +157,31 @@ function transformExprOperators( xpr, options, messageFunctions, env ) {
|
|
|
155
157
|
}
|
|
156
158
|
}
|
|
157
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Whether the outermost operator of a column expression is a predicate (condition).
|
|
162
|
+
* Clones first because csnAsTree() restructures its input in place, and the column
|
|
163
|
+
* is structurized again for real when it is rendered.
|
|
164
|
+
*
|
|
165
|
+
* @param {object} col CSN column
|
|
166
|
+
* @returns {boolean}
|
|
167
|
+
*/
|
|
168
|
+
function isTopLevelPredicate( col ) {
|
|
169
|
+
if (!Array.isArray(col.xpr))
|
|
170
|
+
return false;
|
|
171
|
+
return isPredicateTree(csnAsTree(structuredClone(col.xpr)));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function isPredicateTree( tree ) {
|
|
175
|
+
const [ top ] = tree;
|
|
176
|
+
if (top && !Array.isArray(top) && top.xpr) // fully parenthesized: `( … )`
|
|
177
|
+
return isPredicateTree(csnAsTree(top.xpr));
|
|
178
|
+
if (!Array.isArray(top))
|
|
179
|
+
return false;
|
|
180
|
+
const op = typeof top[0] === 'string' ? top[0] : top[1];
|
|
181
|
+
return predicateOperators.has(op);
|
|
182
|
+
}
|
|
183
|
+
|
|
158
184
|
module.exports = {
|
|
159
185
|
transformExprOperators,
|
|
186
|
+
isTopLevelPredicate,
|
|
160
187
|
};
|