@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
|
@@ -127,6 +127,7 @@ const {
|
|
|
127
127
|
dictAdd, dictAddArray, dictForEach, pushToDict,
|
|
128
128
|
} = require('./dictionaries');
|
|
129
129
|
const { kindProperties } = require('./base');
|
|
130
|
+
const { CompilerAssertion } = require('../base/error');
|
|
130
131
|
const {
|
|
131
132
|
setLink,
|
|
132
133
|
initItemsLinks,
|
|
@@ -277,6 +278,18 @@ function define( model ) {
|
|
|
277
278
|
}
|
|
278
279
|
}
|
|
279
280
|
|
|
281
|
+
/**
|
|
282
|
+
* Calculate the absolute name of a main artifact (created via CDL or CSN parser).
|
|
283
|
+
* Detect reserved-namespace violations (name starts with `cds.`).
|
|
284
|
+
* Add artifact to `model.definitions` if the name does not start with `localized.`.
|
|
285
|
+
*
|
|
286
|
+
* Set `_block` links for the artifact and annotations with expression value
|
|
287
|
+
* (also set `kind` to `$annotation` for those).
|
|
288
|
+
*
|
|
289
|
+
* @param {XSN.Artifact} art
|
|
290
|
+
* @param {XSN.SourceAst|XSN.Artifact} block Enclosing block (source or context/service)
|
|
291
|
+
* @param {string} prefix Dot-terminated absolute name prefix, e.g. `A.B.`, or ``
|
|
292
|
+
*/
|
|
280
293
|
function addMainArtifact( art, block, prefix ) {
|
|
281
294
|
setLink( art, '_block', block );
|
|
282
295
|
initExprAnnoBlock( art, block, error ); // TODO: why also here?
|
|
@@ -303,7 +316,39 @@ function define( model ) {
|
|
|
303
316
|
dictAdd( model.definitions, absolute, art );
|
|
304
317
|
}
|
|
305
318
|
|
|
306
|
-
|
|
319
|
+
/**
|
|
320
|
+
* Add a main artifact to the model, like `addMainArtifact` does.
|
|
321
|
+
* Additionally, add all main artifacts in `art.artifacts` to the model, and
|
|
322
|
+
* all extensions in `art.extensions`.
|
|
323
|
+
*
|
|
324
|
+
* @param {XSN.Artifact} art
|
|
325
|
+
* @param {XSN.SourceAst|XSN.Artifact} block Enclosing block (source or context/service)
|
|
326
|
+
* @param {string} prefix Dot-terminated absolute name prefix, e.g. `A.B.`, or ``
|
|
327
|
+
*/
|
|
328
|
+
function addBlockArtifact( art, block, prefix ) {
|
|
329
|
+
if (art.kind === 'using')
|
|
330
|
+
return;
|
|
331
|
+
addMainArtifact( art, block, prefix );
|
|
332
|
+
if (art.artifacts) {
|
|
333
|
+
const p = `${ art.name.id }.`;
|
|
334
|
+
// path prefixes (usings) must be added before extensions in artifacts:
|
|
335
|
+
addPathPrefixes( art.artifacts, p );
|
|
336
|
+
dictForEach( art.artifacts, a => addBlockArtifact( a, art, p ) );
|
|
337
|
+
}
|
|
338
|
+
if (art.extensions) { // requires using to be known!
|
|
339
|
+
art.extensions.forEach( e => e.name && addExtension( e, art ) );
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Ensure that every dotted top-level name in `artifacts` has a synthetic `using`
|
|
345
|
+
* proxy for its first path component so that name resolution can find it.
|
|
346
|
+
* E.g. if `artifacts` contains an artifact with block-relative name `B.C`,
|
|
347
|
+
* a `using`-like entry for `B` is inserted (unless one already exists).
|
|
348
|
+
*
|
|
349
|
+
* @param {Object} artifacts Dictionary of artifact definitions keyed by relative name
|
|
350
|
+
* @param {string} prefix Absolute name prefix of the enclosing block, e.g. `"A."`
|
|
351
|
+
*/
|
|
307
352
|
function addPathPrefixes( artifacts, prefix ) {
|
|
308
353
|
for (const name in artifacts) {
|
|
309
354
|
const d = artifacts[name];
|
|
@@ -331,10 +376,9 @@ function define( model ) {
|
|
|
331
376
|
|
|
332
377
|
/**
|
|
333
378
|
* Add the names of a USING declaration to the top-level search environment
|
|
334
|
-
* of the source, and set the absolute name referred by the USING
|
|
335
|
-
* declaration.
|
|
379
|
+
* of the source, and set the absolute name referred by the USING declaration.
|
|
336
380
|
*
|
|
337
|
-
* @param {XSN.Using} decl
|
|
381
|
+
* @param {XSN.Using} decl USING declaration to be expanded and added to `src`
|
|
338
382
|
* @param {XSN.SourceAst} src
|
|
339
383
|
*/
|
|
340
384
|
function addUsing( decl, src ) {
|
|
@@ -360,7 +404,14 @@ function define( model ) {
|
|
|
360
404
|
dictAddArray( src.artifacts, name, decl );
|
|
361
405
|
}
|
|
362
406
|
|
|
363
|
-
|
|
407
|
+
/**
|
|
408
|
+
* Use the namespace declaration as USING declaration if the local name
|
|
409
|
+
* is not already defined in the source (that is why all `addUsing`s must
|
|
410
|
+
* have been called before).
|
|
411
|
+
*
|
|
412
|
+
* @param {XSN.Namespace} namespace Namespace declaration of `src`
|
|
413
|
+
* @param {XSN.SourceAst} src
|
|
414
|
+
*/
|
|
364
415
|
function addNamespace( namespace, src ) {
|
|
365
416
|
// create using for own namespace:
|
|
366
417
|
// TODO: should we really do that (in v6)? See also initNamespaceAndUsing().
|
|
@@ -377,29 +428,40 @@ function define( model ) {
|
|
|
377
428
|
$inferred: 'namespace',
|
|
378
429
|
};
|
|
379
430
|
}
|
|
380
|
-
function addBlockArtifact( art, block, prefix ) {
|
|
381
|
-
if (art.kind === 'using')
|
|
382
|
-
return;
|
|
383
|
-
addMainArtifact( art, block, prefix );
|
|
384
|
-
if (art.artifacts) {
|
|
385
|
-
const p = `${ art.name.id }.`;
|
|
386
|
-
// path prefixes (usings) must be added before extensions in artifacts:
|
|
387
|
-
addPathPrefixes( art.artifacts, p );
|
|
388
|
-
dictForEach( art.artifacts, a => addBlockArtifact( a, art, p ) );
|
|
389
|
-
}
|
|
390
|
-
if (art.extensions) { // requires using to be known!
|
|
391
|
-
art.extensions.forEach( e => e.name && addExtension( e, art ) );
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
431
|
|
|
432
|
+
/**
|
|
433
|
+
* Register an extension block in `model.$collectedExtensions` so it can be
|
|
434
|
+
* applied during the extend phase. For context/service extensions that carry
|
|
435
|
+
* nested `artifacts`, those artifacts are registered in `model.definitions` as
|
|
436
|
+
* well (delegating to `addBlockArtifact`).
|
|
437
|
+
*
|
|
438
|
+
* @param {XSN.Extension} ext The `extend`/`annotate` node from the source AST
|
|
439
|
+
* @param {XSN.SourceAst|XSN.Artifact} block Enclosing block that provides scope
|
|
440
|
+
*/
|
|
395
441
|
function addExtension( ext, block ) {
|
|
396
442
|
setLink( ext, '_block', block );
|
|
397
443
|
initExprAnnoBlock( ext, block, error );
|
|
398
444
|
const absolute = ext.name && resolveUncheckedPath( ext.name, '_uncheckedExtension', ext );
|
|
399
445
|
if (!absolute) // broken path
|
|
400
446
|
return;
|
|
401
|
-
|
|
447
|
+
|
|
448
|
+
if (ext.artifacts) {
|
|
449
|
+
// Directly add the artifacts of context and service extension:
|
|
450
|
+
if (!model.$blocks)
|
|
451
|
+
model.$blocks = Object.create( null );
|
|
452
|
+
// Set block number for debugging (--raw-output):
|
|
453
|
+
// eslint-disable-next-line no-multi-assign
|
|
454
|
+
ext.$effectiveSeqNo = model.$blocks[absolute] = (model.$blocks[absolute] || 0) + 1;
|
|
455
|
+
const prefix = `${ absolute }.`;
|
|
456
|
+
dictForEach( ext.artifacts, a => addBlockArtifact( a, ext, prefix ) );
|
|
457
|
+
|
|
458
|
+
if (!ext.expectedKind && !ext.doc &&
|
|
459
|
+
!Object.keys( ext ).some( prop => prop.startsWith( '@' ) ))
|
|
460
|
+
return; // not part of extensions if just nested definitions
|
|
461
|
+
}
|
|
402
462
|
ext.name.id = absolute; // definition might not be there yet, no _artifact link
|
|
463
|
+
delete ext.name.path[0]._artifact; // might point to wrong JS object in phase 1 - TODO: still?
|
|
464
|
+
|
|
403
465
|
const location = { file: '' }; // stupid required location
|
|
404
466
|
const late = model.$collectedExtensions[absolute] ||
|
|
405
467
|
(model.$collectedExtensions[absolute] = {
|
|
@@ -409,19 +471,15 @@ function define( model ) {
|
|
|
409
471
|
location,
|
|
410
472
|
});
|
|
411
473
|
pushToDict( late, '_extensions', ext );
|
|
412
|
-
if (!ext.artifacts)
|
|
413
|
-
return;
|
|
414
|
-
|
|
415
|
-
// Directly add the artifacts of context and service extension:
|
|
416
|
-
if (!model.$blocks)
|
|
417
|
-
model.$blocks = Object.create( null );
|
|
418
|
-
// Set block number for debugging (--raw-output):
|
|
419
|
-
// eslint-disable-next-line no-multi-assign
|
|
420
|
-
ext.$effectiveSeqNo = model.$blocks[absolute] = (model.$blocks[absolute] || 0) + 1;
|
|
421
|
-
const prefix = `${ absolute }.`;
|
|
422
|
-
dictForEach( ext.artifacts, a => addBlockArtifact( a, ext, prefix ) );
|
|
423
474
|
}
|
|
424
475
|
|
|
476
|
+
/**
|
|
477
|
+
* Register a vocabulary artifact in `model.vocabularies` under its absolute name.
|
|
478
|
+
*
|
|
479
|
+
* @param {XSN.Artifact} vocab
|
|
480
|
+
* @param {XSN.SourceAst} block
|
|
481
|
+
* @param {string} prefix Dot-terminated absolute name prefix, or `""`
|
|
482
|
+
*/
|
|
425
483
|
function addVocabulary( vocab, block, prefix ) {
|
|
426
484
|
setLink( vocab, '_block', block );
|
|
427
485
|
const { name } = vocab;
|
|
@@ -480,6 +538,14 @@ function define( model ) {
|
|
|
480
538
|
// Functions called from top-level: initNamespaceAndUsing(), initMainArtifact(),
|
|
481
539
|
// initVocabulary(), initExtension()
|
|
482
540
|
|
|
541
|
+
/**
|
|
542
|
+
* Initialise for a single CDL source: register the "namespace artifact" in
|
|
543
|
+
* `model.definitions` if no real artifact with that name exists,
|
|
544
|
+
* warn when the namespace's last component shadows a builtin name, and
|
|
545
|
+
* report duplicate top-level `using` names introduced by `using` declarations.
|
|
546
|
+
*
|
|
547
|
+
* @param {XSN.SourceAst} src
|
|
548
|
+
*/
|
|
483
549
|
function initNamespaceAndUsing( src ) {
|
|
484
550
|
if (src.$frontend && src.$frontend !== 'cdl')
|
|
485
551
|
return;
|
|
@@ -518,6 +584,16 @@ function define( model ) {
|
|
|
518
584
|
}
|
|
519
585
|
}
|
|
520
586
|
|
|
587
|
+
/**
|
|
588
|
+
* Initialise for a top-level artifact: sets `_parent`/`_subArtifacts` links,
|
|
589
|
+
* check for duplicate definitions, initialise `$self`/`$parameters` aliases,
|
|
590
|
+
* recurse into members, and drive query initialisation for entities/views.
|
|
591
|
+
* Pass `reInit = true` for auto-exposed entities to skip the `_parent` step
|
|
592
|
+
* (their parent link is already set up during auto-exposure).
|
|
593
|
+
*
|
|
594
|
+
* @param {XSN.Artifact} art
|
|
595
|
+
* @param {boolean} [reInit]
|
|
596
|
+
*/
|
|
521
597
|
function initMainArtifact( art, reInit = false ) {
|
|
522
598
|
if (!reInit) // not for auto-exposed entity
|
|
523
599
|
initArtifactParentLink( art, model.definitions );
|
|
@@ -533,6 +609,13 @@ function define( model ) {
|
|
|
533
609
|
}
|
|
534
610
|
}
|
|
535
611
|
|
|
612
|
+
/**
|
|
613
|
+
* Initialise for a vocabulary artifact: sets `_parent`/`_subArtifacts` links,
|
|
614
|
+
* checks for duplicates, recurses into members, and rejects query-based vocabulary
|
|
615
|
+
* definitions (projections on annotation definitions are unsupported).
|
|
616
|
+
*
|
|
617
|
+
* @param {XSN.Artifact} art
|
|
618
|
+
*/
|
|
536
619
|
function initVocabulary( art ) {
|
|
537
620
|
initArtifactParentLink( art, model.vocabularies );
|
|
538
621
|
checkRedefinition( art );
|
|
@@ -545,10 +628,16 @@ function define( model ) {
|
|
|
545
628
|
}
|
|
546
629
|
}
|
|
547
630
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
631
|
+
/**
|
|
632
|
+
* Initialise for an `extend`/`annotate` node: recurse into its members
|
|
633
|
+
* and, for `extend … with columns`, initialises the column list in extension context.
|
|
634
|
+
*
|
|
635
|
+
* @param {XSN.Extension} ext The collected super-extension node
|
|
636
|
+
*/
|
|
637
|
+
function initExtension( ext ) {
|
|
638
|
+
initMembers( ext );
|
|
639
|
+
if (ext.columns)
|
|
640
|
+
initSelectItems( ext, ext.columns, ext, true );
|
|
552
641
|
// there are no sub queries in extensions yet
|
|
553
642
|
// Remark: sub queries not yet allowed in `extend … with columns`
|
|
554
643
|
}
|
|
@@ -588,6 +677,11 @@ function define( model ) {
|
|
|
588
677
|
parent._subArtifacts[id.substring( dot + 1 )] = art; // not dictAdd()
|
|
589
678
|
}
|
|
590
679
|
|
|
680
|
+
/**
|
|
681
|
+
* Report a duplicate-definition error for `art` if it was flagged as a redefinition
|
|
682
|
+
* during phase 1. Extensions (`extend`/`annotate`) are silently skipped because
|
|
683
|
+
* they are merged and only kept as `$duplicates` for LSP purposes.
|
|
684
|
+
*/
|
|
591
685
|
// TODO: message ids
|
|
592
686
|
// Called by initMainArtifact() and initVocabulary() and for members
|
|
593
687
|
function checkRedefinition( art ) {
|
|
@@ -660,24 +754,53 @@ function define( model ) {
|
|
|
660
754
|
}
|
|
661
755
|
}
|
|
662
756
|
|
|
757
|
+
/**
|
|
758
|
+
* Initialise all queries of a query-bearing artifact and store them in `$queries`.
|
|
759
|
+
*
|
|
760
|
+
* Also create helper artifacts like for `$projection` and set various links
|
|
761
|
+
* (`_parent`, `_$next`, `_origin`) for the name resolution in queries.
|
|
762
|
+
*
|
|
763
|
+
* Also moves pre-existing `elements` (for basic "specified elements" support)
|
|
764
|
+
* aside into `elements$` so the populate phase can merge them later.
|
|
765
|
+
*
|
|
766
|
+
* @param {XSN.Artifact} art An entity, view, type, or event with a `query` property
|
|
767
|
+
*/
|
|
663
768
|
function initArtifactQuery( art ) {
|
|
664
769
|
art.$queries = [];
|
|
665
|
-
|
|
666
|
-
if (!
|
|
667
|
-
return;
|
|
668
|
-
|
|
669
|
-
|
|
770
|
+
const leading = initQueryExpression( art.query, art );
|
|
771
|
+
if (!leading)
|
|
772
|
+
return;
|
|
773
|
+
if (leading !== art.$queries[0])
|
|
774
|
+
throw new CompilerAssertion( `Invalid leading query of ${ art.name.id }` );
|
|
775
|
+
|
|
776
|
+
setLink( art, '_origin', leading._origin );
|
|
777
|
+
// Remark: setting _origin to `leading` would break `extend … with columns`
|
|
778
|
+
setLink( leading, '_$next', art );
|
|
670
779
|
if (art.elements) { // specified element via compilation of client-style CSN
|
|
671
|
-
// TODO: consider this part of
|
|
780
|
+
// TODO: consider this part of the normal 'extend' functionality
|
|
672
781
|
setLink( art, 'elements$', art.elements );
|
|
673
782
|
delete art.elements;
|
|
674
783
|
}
|
|
675
784
|
}
|
|
676
785
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
786
|
+
/**
|
|
787
|
+
* Recursively initialise a query expression node — either a `SELECT` or a set
|
|
788
|
+
* operation (`UNION`/`INTERSECT`/…). For `SELECT`, drives `initQuery`,
|
|
789
|
+
* `initTableExpression`, `initMixins`, and the implicit `$self`/`$projection`
|
|
790
|
+
* table-alias registration. For set operations, delegates to each operand and
|
|
791
|
+
* propagates `ORDER BY`/`LIMIT` clauses onto the leading query.
|
|
792
|
+
* Returns the leading query node (the innermost leftmost `SELECT`), or `undefined`
|
|
793
|
+
* on parse error.
|
|
794
|
+
*
|
|
795
|
+
* `art` is:
|
|
796
|
+
* - entity/event/type for top-level queries (including UNION args)
|
|
797
|
+
* - $tableAlias for sub query in FROM - TODO: what about UNION there?
|
|
798
|
+
* - $query for real sub query (in columns, WHERE, ...) - what about UNION there?
|
|
799
|
+
*
|
|
800
|
+
* @param {XSN.Query|null} query
|
|
801
|
+
* @param {XSN.Artifact|XSN.Query} art Owning artifact or parent alias
|
|
802
|
+
* @returns {XSN.Query|undefined}
|
|
803
|
+
*/
|
|
681
804
|
function initQueryExpression( query, art ) {
|
|
682
805
|
if (!query) // parse error
|
|
683
806
|
return query;
|
|
@@ -705,38 +828,49 @@ function define( model ) {
|
|
|
705
828
|
query.$tableAliases.$projection = projection;
|
|
706
829
|
}
|
|
707
830
|
initSubQuery( query ); // check for SELECT clauses after from / mixin
|
|
831
|
+
return query;
|
|
708
832
|
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
for (const q of query.args
|
|
712
|
-
initQueryExpression( q, art );
|
|
713
|
-
|
|
714
|
-
if (leading) {
|
|
715
|
-
if (query.orderBy) {
|
|
716
|
-
leading.$orderBy ??= [ ];
|
|
717
|
-
leading.$orderBy.push( ...query.orderBy );
|
|
718
|
-
}
|
|
719
|
-
if (query.limit) {
|
|
720
|
-
leading.$limit ??= [ ];
|
|
721
|
-
leading.$limit.push( query.limit );
|
|
722
|
-
}
|
|
833
|
+
if (query.args) { // UNION, INTERSECT, ...
|
|
834
|
+
let leading = null; // first SELECT
|
|
835
|
+
for (const q of query.args) {
|
|
836
|
+
const sub = initQueryExpression( q, art );
|
|
837
|
+
leading ??= sub;
|
|
723
838
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
//
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
839
|
+
setLink( query, '_origin', leading?._origin ?? false );
|
|
840
|
+
if (!leading)
|
|
841
|
+
return false; // potentially with parse error, false not overwritten by `??=`
|
|
842
|
+
// ORDER BY and LIMIT to be evaluated according to elements of first SELECT:
|
|
843
|
+
if (query.orderBy) {
|
|
844
|
+
leading.$orderBy ??= [ ];
|
|
845
|
+
leading.$orderBy.push( ...query.orderBy );
|
|
846
|
+
}
|
|
847
|
+
if (query.limit) {
|
|
848
|
+
leading.$limit ??= [ ];
|
|
849
|
+
leading.$limit.push( query.limit );
|
|
850
|
+
}
|
|
851
|
+
return leading;
|
|
731
852
|
}
|
|
732
|
-
|
|
853
|
+
// with parse error (`select from <EOF>`, `select from E { *, ( select }`)
|
|
854
|
+
// TODO: call initQuery() anyway to avoid Error[expr-no-subquery] also for
|
|
855
|
+
// UNIONs (test3/Queries/DollarSelf/CorruptedSource.err.cds), see also
|
|
856
|
+
// resolveExprNode()
|
|
857
|
+
return undefined;
|
|
733
858
|
}
|
|
734
859
|
|
|
860
|
+
/**
|
|
861
|
+
* Assign `kind: 'select'` and a numeric name to `query`, register it in
|
|
862
|
+
* `main.$queries`, and set up `_block`, `_$next`, `_parent`, `$tableAliases`,
|
|
863
|
+
* and `dependsOn` links needed by the populate and resolve phase.
|
|
864
|
+
*
|
|
865
|
+
* @param {XSN.Query} query
|
|
866
|
+
* @param {XSN.Artifact|XSN.TableAlias} art Owning artifact or enclosing table alias
|
|
867
|
+
*/
|
|
735
868
|
function initQuery( query, art ) {
|
|
736
869
|
setLink( query, '_block', art._block );
|
|
737
870
|
const main = art._main || art;
|
|
738
871
|
setLink( query, '_$next',
|
|
739
872
|
(art.kind === '$tableAlias' ? art._parent._$next : art ) );
|
|
873
|
+
setLink( query, '_origin', null ); // set later in initTableExpression → addAsAlias
|
|
740
874
|
query.kind = 'select';
|
|
741
875
|
query.name = { location: query.location, id: main.$queries.length + 1 };
|
|
742
876
|
setMemberParent( query, null, main );
|
|
@@ -747,6 +881,17 @@ function define( model ) {
|
|
|
747
881
|
dependsOnSilent( main, query );
|
|
748
882
|
}
|
|
749
883
|
|
|
884
|
+
/**
|
|
885
|
+
* Initialise a table expression in a FROM clause: path references, sub-selects,
|
|
886
|
+
* and JOIN trees. Path references and sub-selects become `$tableAlias` nodes
|
|
887
|
+
* registered in `query.$tableAliases`. JOIN trees are traversed recursively;
|
|
888
|
+
* each arm with an ON clause becomes a `$join` node whose aliases are also
|
|
889
|
+
* propagated upward via `joinParents` for restriction checking.
|
|
890
|
+
*
|
|
891
|
+
* @param {XSN.TableExpr|null} table
|
|
892
|
+
* @param {XSN.Query} query
|
|
893
|
+
* @param {XSN.JoinNode[]} joinParents Stack of enclosing JOIN nodes with ON clauses
|
|
894
|
+
*/
|
|
750
895
|
// table is table expression in FROM, becomes an alias
|
|
751
896
|
function initTableExpression( table, query, joinParents ) {
|
|
752
897
|
if (!table) // parse error
|
|
@@ -764,9 +909,6 @@ function define( model ) {
|
|
|
764
909
|
}
|
|
765
910
|
addAsAlias( table, query, joinParents );
|
|
766
911
|
// _origin is set when we resolve the ref
|
|
767
|
-
if (query._parent.kind !== 'select')
|
|
768
|
-
query._main._from.push( table ); // store tabref if outside "real" subquery
|
|
769
|
-
// (tab refs on the right of union are unnecessary)
|
|
770
912
|
}
|
|
771
913
|
else if (table.query) {
|
|
772
914
|
if (!table.name?.id) {
|
|
@@ -816,10 +958,22 @@ function define( model ) {
|
|
|
816
958
|
}
|
|
817
959
|
}
|
|
818
960
|
|
|
961
|
+
/**
|
|
962
|
+
* Register `table` as a `$tableAlias` in `query.$tableAliases` and, for JOIN
|
|
963
|
+
* contexts, in each enclosing JOIN node's `$tableAliases` (for alias restriction
|
|
964
|
+
* checks). Report duplicate alias names and warn when a user-written alias
|
|
965
|
+
* starts with `$`.
|
|
966
|
+
*
|
|
967
|
+
* @param {XSN.TableAlias} table
|
|
968
|
+
* @param {XSN.Query} query
|
|
969
|
+
* @param {XSN.JoinNode[]} joinParents
|
|
970
|
+
*/
|
|
819
971
|
function addAsAlias( table, query, joinParents ) {
|
|
820
972
|
table.kind = '$tableAlias';
|
|
821
973
|
setLink( table, '_block', query._block );
|
|
822
974
|
setMemberParent( table, table.name.id, query );
|
|
975
|
+
if (!query._origin)
|
|
976
|
+
setLink( query, '_origin', table );
|
|
823
977
|
dictAdd( query.$tableAliases, table.name.id, table, ( name, loc, tableAlias ) => {
|
|
824
978
|
if (tableAlias.name.$inferred === '$internal') {
|
|
825
979
|
const semanticLoc = tableAlias.query?.name ? tableAlias.query : tableAlias;
|
|
@@ -847,6 +1001,12 @@ function define( model ) {
|
|
|
847
1001
|
}
|
|
848
1002
|
}
|
|
849
1003
|
|
|
1004
|
+
/**
|
|
1005
|
+
* Walk sub-query nodes embedded inside a SELECT's ON, WHERE, HAVING, column list,
|
|
1006
|
+
* and members, and drive `initQueryExpression` for each.
|
|
1007
|
+
*
|
|
1008
|
+
* @param {XSN.Query|XSN.JoinNode} query
|
|
1009
|
+
*/
|
|
850
1010
|
function initSubQuery( query ) {
|
|
851
1011
|
if (query.on)
|
|
852
1012
|
initExprForQuery( query.on, query );
|
|
@@ -859,6 +1019,14 @@ function define( model ) {
|
|
|
859
1019
|
initMembers( query );
|
|
860
1020
|
}
|
|
861
1021
|
|
|
1022
|
+
/**
|
|
1023
|
+
* Recursively find and initialise sub-query nodes embedded inside an expression
|
|
1024
|
+
* (WHERE, HAVING, ON, column values). Descend into `args` arrays and named
|
|
1025
|
+
* argument objects; calls `initQueryExpression` for any `expr.query` encountered.
|
|
1026
|
+
*
|
|
1027
|
+
* @param {XSN.Expr|XSN.Expr[]|null} expr
|
|
1028
|
+
* @param {XSN.Query} query Enclosing query that owns the expression
|
|
1029
|
+
*/
|
|
862
1030
|
function initExprForQuery( expr, query ) {
|
|
863
1031
|
// TODO: use traverseExpr()
|
|
864
1032
|
if (Array.isArray( expr )) { // TODO: old-style $parens ?
|
|
@@ -876,6 +1044,14 @@ function define( model ) {
|
|
|
876
1044
|
}
|
|
877
1045
|
}
|
|
878
1046
|
|
|
1047
|
+
/**
|
|
1048
|
+
* Initialise all MIXIN definitions of `query`: set parent/block links, check for
|
|
1049
|
+
* duplicates, register each mixin as a `$tableAlias` in `query.$tableAliases`,
|
|
1050
|
+
* and warn when a mixin name starts with `$`.
|
|
1051
|
+
*
|
|
1052
|
+
* @param {XSN.Query} query
|
|
1053
|
+
* @param {XSN.Artifact} art Main artifact owning the query (provides `_block`)
|
|
1054
|
+
*/
|
|
879
1055
|
function initMixins( query, art ) {
|
|
880
1056
|
forEachInOrder( query, 'mixin', initMixin );
|
|
881
1057
|
|
|
@@ -898,6 +1074,20 @@ function define( model ) {
|
|
|
898
1074
|
}
|
|
899
1075
|
}
|
|
900
1076
|
|
|
1077
|
+
/**
|
|
1078
|
+
* Initialise the select-item list of a query or expand/inline column. Iterates
|
|
1079
|
+
* over `columns` (or `parent.expand`/`parent.inline`) and for each item:
|
|
1080
|
+
* - tracks the first wildcard (`*`) and rejects subsequent ones;
|
|
1081
|
+
* reports a warning when `excluding` is used without a wildcard
|
|
1082
|
+
* - assigns `kind: 'element'`, sets parent/block links, infers a column alias
|
|
1083
|
+
* via `ensureColumnName`, recurses into nested expand/inline, and calls
|
|
1084
|
+
* `initExprForQuery` for sub-queries in column values.
|
|
1085
|
+
*
|
|
1086
|
+
* @param {XSN.Query|XSN.Column} parent Node that owns the column list
|
|
1087
|
+
* @param {XSN.Column[]|null} columns Explicit column array, or `null` to use expand/inline
|
|
1088
|
+
* @param {XSN.Query} user Enclosing query (for semantic location in messages)
|
|
1089
|
+
* @param {boolean} [inExtension] `true` when processing `extend … with columns`
|
|
1090
|
+
*/
|
|
901
1091
|
function initSelectItems( parent, columns, user, inExtension = false ) {
|
|
902
1092
|
let wildcard = !!inExtension; // no `extend … with columns { * }`
|
|
903
1093
|
// TODO: forbid expand/inline in ref-where, outside queries (CSN), ...
|
|
@@ -1023,10 +1213,16 @@ function define( model ) {
|
|
|
1023
1213
|
return col.name.id;
|
|
1024
1214
|
}
|
|
1025
1215
|
|
|
1216
|
+
/**
|
|
1217
|
+
* Report a CDL-style type cast to an anonymous structure or an expand with an
|
|
1218
|
+
* explicit type as a syntax error. Called for every column during select-item
|
|
1219
|
+
* initialisation. Rejection happens here (rather than in `checks.js`) so that
|
|
1220
|
+
* it is also enforced during `parseCdl`.
|
|
1221
|
+
*
|
|
1222
|
+
* @param {XSN.Column} col
|
|
1223
|
+
*/
|
|
1026
1224
|
function checkCdlTypeCast( col ) { // with #13933:
|
|
1027
|
-
//
|
|
1028
|
-
// and not in checks.js to ensure that it's rejected in parseCdl.
|
|
1029
|
-
// TODO: via <guard> in CdlGrammar.g4
|
|
1225
|
+
// TODO: do via <guard> in CdlGrammar.g4 ?
|
|
1030
1226
|
if (col.elements) {
|
|
1031
1227
|
error( 'type-invalid-cast', [ (col.elements[$location] ?? col.location), col ],
|
|
1032
1228
|
{ '#': 'to-inline-structure' } );
|
|
@@ -1042,8 +1238,13 @@ function define( model ) {
|
|
|
1042
1238
|
// Members (elements, enum, actions, params): ---------------------------------
|
|
1043
1239
|
|
|
1044
1240
|
/**
|
|
1045
|
-
*
|
|
1046
|
-
*
|
|
1241
|
+
* Initialise for all members of `parent`: resolves the concrete member container
|
|
1242
|
+
* (following `items`/`many` wrappers via `initItemsLinks`), reports a scale-without-
|
|
1243
|
+
* precision error on type extensions, detects inline aspects on managed compositions
|
|
1244
|
+
* (delegating to `initAnonymousAspect`), and then calls `initArtifact` for every
|
|
1245
|
+
* element, enum value, foreign key, action, param, and RETURNS declaration.
|
|
1246
|
+
*
|
|
1247
|
+
* @param {XSN.Artifact|XSN.Element|XSN.Query|XSN.Extension} parent
|
|
1047
1248
|
*/
|
|
1048
1249
|
function initMembers( parent ) {
|
|
1049
1250
|
// TODO: combine with initMembers() - better structuring
|
|
@@ -1084,6 +1285,18 @@ function define( model ) {
|
|
|
1084
1285
|
}
|
|
1085
1286
|
}
|
|
1086
1287
|
|
|
1288
|
+
/**
|
|
1289
|
+
* Initialise the inline aspect that appears as the `targetAspect` of a managed
|
|
1290
|
+
* composition element. Sets up `_outer`, `_parent`, `_block`, `_main`, and
|
|
1291
|
+
* `$self` links on `targetAspect`, promotes its kind to `'aspect'`, and injects
|
|
1292
|
+
* a synthetic `up_` `$navElement` when the composition is directly inside an
|
|
1293
|
+
* entity (so that references to `up_` inside the aspect resolve correctly).
|
|
1294
|
+
*
|
|
1295
|
+
* @param {XSN.Element} parent The composition element that owns the inline aspect
|
|
1296
|
+
* @param {XSN.Element} obj The resolved composition element (may differ via `items`)
|
|
1297
|
+
* @param {XSN.InlineAspect} targetAspect The inline aspect node to initialise
|
|
1298
|
+
* @returns {XSN.InlineAspect}
|
|
1299
|
+
*/
|
|
1087
1300
|
function initAnonymousAspect( parent, obj, targetAspect ) {
|
|
1088
1301
|
// TODO: main?
|
|
1089
1302
|
const inEntity = parent._main?.kind === 'entity';
|
|
@@ -1118,6 +1331,19 @@ function define( model ) {
|
|
|
1118
1331
|
return targetAspect;
|
|
1119
1332
|
}
|
|
1120
1333
|
|
|
1334
|
+
/**
|
|
1335
|
+
* Initialise for a single member (element, enum value, foreign key, action,
|
|
1336
|
+
* function, or parameter). Infers a missing name from the last path component
|
|
1337
|
+
* of `targetElement`/`value`, sets `_block`/`_parent`/`_main` links, checks for
|
|
1338
|
+
* duplicates, recurses into sub-members, and — for action/function params —
|
|
1339
|
+
* sets up the bound `$self` parameter. Also promotes elements with a `value`
|
|
1340
|
+
* expression to calculated elements (`$syntax: 'calc'`) and creates the
|
|
1341
|
+
* companion `$calcDepElement`.
|
|
1342
|
+
*
|
|
1343
|
+
* @param {XSN.Artifact|XSN.Element|XSN.Query} parent Enclosing node
|
|
1344
|
+
* @param {XSN.Element} elem
|
|
1345
|
+
* @param {string} name Relative member name (empty string `''` for RETURNS)
|
|
1346
|
+
*/
|
|
1121
1347
|
// TODO: combine with initMembers()
|
|
1122
1348
|
function initArtifact( parent, elem, name ) {
|
|
1123
1349
|
if (!elem.name && !elem._outer) {
|
|
@@ -86,6 +86,8 @@ function dictAddArray( dict, name, entry, messageCallback ) {
|
|
|
86
86
|
function dictFirst( dict ) {
|
|
87
87
|
if (!dict)
|
|
88
88
|
return dict;
|
|
89
|
+
// Remark: previously, we had a loop and returned directly there.
|
|
90
|
+
// Earlier tests showed that this is faster, but SonarQube did not like it.
|
|
89
91
|
const names = Object.keys( dict );
|
|
90
92
|
return names.length ? dict[names[0]] : null;
|
|
91
93
|
}
|