@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
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/bin/zsh
|
|
2
|
-
|
|
3
|
-
# compinit is required but added to ~/.zshrc so user can remove it if it is already loaded
|
|
4
|
-
# autoload -Uz compinit && compinit
|
|
5
|
-
|
|
6
|
-
CDS_COMMAND="cds"
|
|
7
|
-
|
|
8
|
-
_completeCds() {
|
|
9
|
-
# double quoting needed to avoid word 'h' to be recognized as command shortcut 'help'
|
|
10
|
-
compadd -S '' -V 'force no sort' -- `${CDS_COMMAND} completion --shell zsh --prev "'${words[CURRENT-1]}'" --curr "'${words[CURRENT]}'" --line "'${words}'"`
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
compdef _completeCds ${CDS_COMMAND}
|
package/lib/deploy/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
options: /** @type{const} */([
|
|
3
|
-
'--to',
|
|
4
|
-
'--for',
|
|
5
|
-
'--out',
|
|
6
|
-
'--on',
|
|
7
|
-
'--tunnel-address',
|
|
8
|
-
'--vcap-file',
|
|
9
|
-
'--delta-from'
|
|
10
|
-
]),
|
|
11
|
-
flags: /** @type{const} */([
|
|
12
|
-
'--resolve-bindings',
|
|
13
|
-
'--no-save',
|
|
14
|
-
'--auto-undeploy',
|
|
15
|
-
'--dry',
|
|
16
|
-
'--xdry',
|
|
17
|
-
'--with-mocks',
|
|
18
|
-
'--store-credentials',
|
|
19
|
-
'--no-build',
|
|
20
|
-
'--model-only',
|
|
21
|
-
'--script',
|
|
22
|
-
'--with-auto-schema-evolution'
|
|
23
|
-
]),
|
|
24
|
-
shortcuts: ['-2', '-4', '-o', '-n', '', '', '', '-b']
|
|
25
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const ParserContext = require("./parserContext");
|
|
2
|
-
const cdsDkVersion = require("../../../package.json").version;
|
|
3
|
-
|
|
4
|
-
function importAsyncAPI(input) {
|
|
5
|
-
const context = new ParserContext(input);
|
|
6
|
-
return convertToCSN(context);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function convertToCSN(context) {
|
|
10
|
-
const csn = {
|
|
11
|
-
meta: {
|
|
12
|
-
creator: `cds-dk ${cdsDkVersion}`
|
|
13
|
-
},
|
|
14
|
-
$version: '2.0',
|
|
15
|
-
definitions: {}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
Object.entries(context.services).forEach(([key, value]) => {
|
|
19
|
-
const events = value.events;
|
|
20
|
-
const types = value.types;
|
|
21
|
-
delete value.events;
|
|
22
|
-
delete value.types;
|
|
23
|
-
|
|
24
|
-
csn.definitions[key] = value;
|
|
25
|
-
Object.assign(csn.definitions, events, types);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
return csn;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
module.exports = {
|
|
32
|
-
importAsyncAPI
|
|
33
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const { importAsyncAPI } = require("./importAsyncAPI");
|
|
2
|
-
const { validateAsyncAPI } = require('./utils');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The starting function for conversion of AsyncAPI document to csn
|
|
6
|
-
* @returns AsyncAPI document
|
|
7
|
-
*/
|
|
8
|
-
function asyncapi2csn(source) {
|
|
9
|
-
// validate asyncapi document
|
|
10
|
-
const content = JSON.parse(source);
|
|
11
|
-
validateAsyncAPI(content);
|
|
12
|
-
|
|
13
|
-
return importAsyncAPI(content);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
module.exports = {
|
|
17
|
-
asyncapi2csn
|
|
18
|
-
}
|
|
@@ -1,454 +0,0 @@
|
|
|
1
|
-
const { getRegExpGroups } = require('./utils');
|
|
2
|
-
const messages = require("../message").getMessages();
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {{ type?: string|string[], format?: string, properties?: Record<string, AsyncApiSchema>, items?: AsyncApiSchema, allOf?: AsyncApiSchema[], '$ref'?: string, required?: string[], additionalProperties?: boolean|AsyncApiSchema, enum?: Array<*>, default?: *, nullable?: boolean, [key: string]: * }} AsyncApiSchema
|
|
6
|
-
* @typedef {{ components: { messages: Record<string, AsyncApiMessage>, schemas: Record<string, AsyncApiSchema> }, info?: object, [key: string]: * }} AsyncApiDocument
|
|
7
|
-
* @typedef {{ name: string, payload?: AsyncApiSchema, [key: string]: * }} AsyncApiMessage
|
|
8
|
-
* @typedef {{ type?: string|{'ref':string[]}, kind?: string, elements?: Record<string, CsnElement>, items?: CsnElement, '@cds.external'?: string, '@mandatory'?: boolean, precision?: number, scale?: number, default?: *, enum?: object, [key: string]: * }} CsnElement
|
|
9
|
-
* @typedef {Record<string, *>} Annotations
|
|
10
|
-
* @typedef {Record<string, CsnElement | null>} CsnTypeMap
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
module.exports = class ParserContext {
|
|
14
|
-
/**
|
|
15
|
-
* @param {AsyncApiDocument} content
|
|
16
|
-
*/
|
|
17
|
-
constructor(content) {
|
|
18
|
-
this.services = this.getServicesFromContent(content);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @param {string} eventName
|
|
23
|
-
*/
|
|
24
|
-
getTopicName(eventName) {
|
|
25
|
-
return eventName.startsWith('ce/') ? eventName.substring(3) : eventName;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @param {string} messageRefString
|
|
30
|
-
*/
|
|
31
|
-
getEventName(messageRefString) {
|
|
32
|
-
const lastSlashIndex = messageRefString.lastIndexOf('/');
|
|
33
|
-
return lastSlashIndex == -1 ? '' : messageRefString.substring(lastSlashIndex + 1);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Returns services from the asyncapi json object along with the events and annotations.
|
|
38
|
-
* @param {AsyncApiDocument} content - root AsyncAPI document
|
|
39
|
-
*/
|
|
40
|
-
getServicesFromContent(content) {
|
|
41
|
-
/** @type {Record<string, *>} */
|
|
42
|
-
const services = {};
|
|
43
|
-
const serviceAnnotations = this.getServiceAnnotations(content);
|
|
44
|
-
|
|
45
|
-
Object.entries(content.components.messages).forEach(([, value]) => {
|
|
46
|
-
let eventName;
|
|
47
|
-
// Message name should be used to capture the event name
|
|
48
|
-
if (value.name) {
|
|
49
|
-
eventName = value.name;
|
|
50
|
-
} else {
|
|
51
|
-
throw new Error(messages.INVALID_ASYNCAPI_FILE);
|
|
52
|
-
}
|
|
53
|
-
// uses regex to break event name in different components
|
|
54
|
-
const regExpGroups = getRegExpGroups(eventName);
|
|
55
|
-
const service = regExpGroups[1] + "." + regExpGroups[2];
|
|
56
|
-
const event = regExpGroups[0];
|
|
57
|
-
|
|
58
|
-
// add service to services entry if not present
|
|
59
|
-
if (!(service in services)) {
|
|
60
|
-
services[service] = { 'kind': 'service', '@cds.external': 'true', ...serviceAnnotations, 'events': {}, 'types': {} };
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// add event entry to service
|
|
64
|
-
const eventAnnotations = this.getEventAnnotations(value);
|
|
65
|
-
|
|
66
|
-
// add topic annotation
|
|
67
|
-
eventAnnotations['@topic'] = this.getTopicName(eventName);
|
|
68
|
-
/** @type {Record<string, CsnElement>} */
|
|
69
|
-
let properties = {};
|
|
70
|
-
/** @type {CsnTypeMap} */
|
|
71
|
-
let types = {};
|
|
72
|
-
|
|
73
|
-
if (value.payload) {
|
|
74
|
-
// gets the schema being referred to in the event
|
|
75
|
-
const eventSchema = this.resolveRef(content, value.payload);
|
|
76
|
-
[properties, types] = this.getPropertiesAndTypes(event, eventSchema, content);
|
|
77
|
-
}
|
|
78
|
-
services[service].types = { ...services[service].types, ...types };
|
|
79
|
-
services[service].events[event] = { 'kind': 'event', '@cds.external': 'true', ...eventAnnotations, elements: properties };
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
return services;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Returns annotations of a particular service.
|
|
87
|
-
* @param {AsyncApiDocument} content - root AsyncAPI document
|
|
88
|
-
*/
|
|
89
|
-
getServiceAnnotations(content) {
|
|
90
|
-
const serviceAnnotationsMapping = {
|
|
91
|
-
'x-sap-stateInfo': 'StateInfo', // expected: object
|
|
92
|
-
'x-sap-shortText': 'ShortText' // expected: string
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const infoAnnotationsMapping = {
|
|
96
|
-
'title': 'Title', // expected: string
|
|
97
|
-
'version': 'SchemaVersion', // expected: string
|
|
98
|
-
'description': 'Description' // expected: string
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const annotations = this.getAnnotations(content, serviceAnnotationsMapping);
|
|
102
|
-
|
|
103
|
-
if (content.info) {
|
|
104
|
-
for (const [key, value] of Object.entries(infoAnnotationsMapping)) {
|
|
105
|
-
/** @type {Record<string, *>} */ const info = content.info;
|
|
106
|
-
if (info[key] && !(info[key] instanceof Object)) {
|
|
107
|
-
// info values will always be in string format
|
|
108
|
-
annotations['@AsyncAPI.' + value] = info[key];
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return annotations;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Returns annotations of a particular event.
|
|
118
|
-
* @param {AsyncApiMessage} content - message object from components.messages
|
|
119
|
-
*/
|
|
120
|
-
getEventAnnotations(content) {
|
|
121
|
-
const eventLevelAnnotationsMapping = {
|
|
122
|
-
'x-sap-event-spec-version': 'EventSpecVersion', // expected: string
|
|
123
|
-
'x-sap-event-source': 'EventSource', // expected: string
|
|
124
|
-
'x-sap-event-version': 'EventSchemaVersion', // expected: string
|
|
125
|
-
'x-sap-event-source-parameters': 'EventSourceParams', // expected: object
|
|
126
|
-
'x-sap-event-characteristics': 'EventCharacteristics', // expected: object
|
|
127
|
-
'x-sap-stateInfo': 'EventStateInfo' // expected: object
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const annotations = this.getAnnotations(content, eventLevelAnnotationsMapping);
|
|
131
|
-
|
|
132
|
-
return annotations;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* @param {string} annotation - annotation name (without @AsyncAPI. prefix)
|
|
137
|
-
* @param {*} value
|
|
138
|
-
*/
|
|
139
|
-
isValidAnnotationValue(annotation, value) {
|
|
140
|
-
const objectTypeAnnotations = ['StateInfo', 'EventSourceParams', 'EventCharacteristics', 'EventStateInfo'];
|
|
141
|
-
// if the value is an array or null
|
|
142
|
-
if (Array.isArray(value) || value === null) return false;
|
|
143
|
-
|
|
144
|
-
if (objectTypeAnnotations.includes(annotation) && (value instanceof Object)) {
|
|
145
|
-
return true;
|
|
146
|
-
} else if ((!objectTypeAnnotations.includes(annotation)) && (typeof value === 'string')) {
|
|
147
|
-
return true;
|
|
148
|
-
} else {
|
|
149
|
-
console.warn(`WARNING: Annotations which are not following the expected type are omitted.`);
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Returns annotations for an event/service.
|
|
156
|
-
* @param {object} content - event or service object
|
|
157
|
-
* @param {Record<string, string>} annotationsMapping - map of AsyncAPI extension key to CDS annotation suffix
|
|
158
|
-
*/
|
|
159
|
-
getAnnotations(content, annotationsMapping) {
|
|
160
|
-
/** @type {Annotations} */
|
|
161
|
-
const annotations = {};
|
|
162
|
-
|
|
163
|
-
for (const [key, value] of Object.entries(content)) {
|
|
164
|
-
// case: known annotation
|
|
165
|
-
if (annotationsMapping[key] && this.isValidAnnotationValue(annotationsMapping[key], value)) {
|
|
166
|
-
annotations['@AsyncAPI.' + annotationsMapping[key]] = value;
|
|
167
|
-
}
|
|
168
|
-
// case: unkown annotation
|
|
169
|
-
else if (key.startsWith('x-')) {
|
|
170
|
-
if (!annotations['@AsyncAPI.Extensions']) {
|
|
171
|
-
annotations['@AsyncAPI.Extensions'] = {};
|
|
172
|
-
}
|
|
173
|
-
// removes x- from the element
|
|
174
|
-
annotations['@AsyncAPI.Extensions'][key.substring(2)] = value;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return annotations;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Merges allOf entries into a single schema object with combined properties.
|
|
183
|
-
* Resolves any $ref entries within the allOf array using the provided document.
|
|
184
|
-
* @param {AsyncApiSchema} schema - AsyncAPI schema object, possibly containing allOf
|
|
185
|
-
* @param {AsyncApiDocument} docContent - root AsyncAPI document, used to resolve $ref entries
|
|
186
|
-
*/
|
|
187
|
-
flattenAllOf(schema, docContent) {
|
|
188
|
-
if (!schema.allOf) return schema;
|
|
189
|
-
/** @type {AsyncApiSchema} */
|
|
190
|
-
const merged = { type: 'object', properties: {} };
|
|
191
|
-
const required = [];
|
|
192
|
-
for (const entry of schema.allOf) {
|
|
193
|
-
const resolved = entry['$ref'] ? this.resolveRef(docContent, entry) : entry;
|
|
194
|
-
const flat = this.flattenAllOf(resolved, docContent);
|
|
195
|
-
Object.assign(merged.properties ?? {}, flat.properties || {});
|
|
196
|
-
if (flat.required) required.push(...flat.required);
|
|
197
|
-
}
|
|
198
|
-
if (required.length) merged.required = required;
|
|
199
|
-
return merged;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Returns the referred schema.
|
|
204
|
-
* @param {AsyncApiDocument} content - root AsyncAPI document
|
|
205
|
-
* @param {AsyncApiSchema | {'$ref': string}} payloadObject - either a $ref object or an inline schema
|
|
206
|
-
*/
|
|
207
|
-
resolveRef(content, payloadObject) {
|
|
208
|
-
/** @type {AsyncApiSchema} */
|
|
209
|
-
let schema = {};
|
|
210
|
-
|
|
211
|
-
if (payloadObject['$ref']) {
|
|
212
|
-
const pathArray = payloadObject['$ref'].split('/');
|
|
213
|
-
pathArray.forEach((value) => {
|
|
214
|
-
if (value === '#') schema = content;
|
|
215
|
-
else if (schema[value]) schema = schema[value];
|
|
216
|
-
// in case path doesn't exist in the file
|
|
217
|
-
else schema = {};
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
if (!Object.keys(schema).length) {
|
|
221
|
-
console.warn(`WARNING: Unable to resolve ref path: ` + payloadObject['$ref']);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
else if (payloadObject instanceof Object) {
|
|
225
|
-
// in case ref is not there and schema object is there
|
|
226
|
-
schema = payloadObject;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return schema;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Returns the properties and types generated, related to an event.
|
|
234
|
-
* @param {string} eventName
|
|
235
|
-
* @param {AsyncApiSchema} content - resolved AsyncAPI schema object for the event payload
|
|
236
|
-
* @param {AsyncApiDocument} docContent - root AsyncAPI document, used to resolve $ref entries
|
|
237
|
-
* @returns {[Record<string, CsnElement>, CsnTypeMap]}
|
|
238
|
-
*/
|
|
239
|
-
getPropertiesAndTypes(eventName, content, docContent) {
|
|
240
|
-
/** @type {Record<string, CsnElement>} */
|
|
241
|
-
const properties = {};
|
|
242
|
-
/** @type {CsnTypeMap} */
|
|
243
|
-
const types = {};
|
|
244
|
-
|
|
245
|
-
if (content.properties) {
|
|
246
|
-
for (const [key, value] of Object.entries(content.properties)) {
|
|
247
|
-
let isRequired = false;
|
|
248
|
-
if (content['required']?.includes(key)) isRequired = true;
|
|
249
|
-
properties[key] = this.parseProperty(eventName, key, value, isRequired, docContent, types);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return [properties, types];
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Returns the processed CSN element object for a property.
|
|
257
|
-
* @param {string} eventName
|
|
258
|
-
* @param {string} propertyName
|
|
259
|
-
* @param {AsyncApiSchema} propertyContent - AsyncAPI schema for this property
|
|
260
|
-
* @param {boolean} isRequired
|
|
261
|
-
* @param {AsyncApiDocument} docContent - root AsyncAPI document, used to resolve $ref entries
|
|
262
|
-
* @param {CsnTypeMap} types - accumulator for generated CDS type definitions
|
|
263
|
-
*/
|
|
264
|
-
parseProperty(eventName, propertyName, propertyContent, isRequired, docContent, types) {
|
|
265
|
-
let property = {};
|
|
266
|
-
let propertyAttributes = {};
|
|
267
|
-
|
|
268
|
-
if (isRequired === true) {
|
|
269
|
-
property['@mandatory'] = true;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
let type = this.getTypeFromArray(propertyContent.type);
|
|
273
|
-
if (!type && propertyContent.allOf) type = 'object';
|
|
274
|
-
|
|
275
|
-
// case where type is defined
|
|
276
|
-
if (type && (type === 'object' || type === 'array')) {
|
|
277
|
-
// for generation of type: event name + property name
|
|
278
|
-
propertyName = propertyName[0].toUpperCase() + propertyName.substring(1);
|
|
279
|
-
let typeName = eventName + "." + propertyName;
|
|
280
|
-
// generate object for the introduced type
|
|
281
|
-
const elements = this.getTypeElements(propertyContent, docContent, types);
|
|
282
|
-
types[typeName] = { 'kind': 'type', '@cds.external': 'true', ...elements };
|
|
283
|
-
// referring to the generated type from the property
|
|
284
|
-
propertyAttributes = { 'type': typeName };
|
|
285
|
-
} else {
|
|
286
|
-
propertyAttributes = this.getPropertyObject(propertyContent, docContent, types);
|
|
287
|
-
}
|
|
288
|
-
property = { ...property, ...propertyAttributes };
|
|
289
|
-
|
|
290
|
-
return property;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Returns the CSN structure for a complex (object/array) schema element.
|
|
295
|
-
* @param {AsyncApiSchema} propertyContent - AsyncAPI schema for this property
|
|
296
|
-
* @param {AsyncApiDocument} docContent - root AsyncAPI document, used to resolve $ref entries
|
|
297
|
-
* @param {CsnTypeMap} types - accumulator for generated CDS type definitions
|
|
298
|
-
* @returns {CsnElement}
|
|
299
|
-
*/
|
|
300
|
-
getTypeElements(propertyContent, docContent, types) {
|
|
301
|
-
/** @type {CsnElement} */
|
|
302
|
-
let properties = {};
|
|
303
|
-
const schema = propertyContent.allOf ? this.flattenAllOf(propertyContent, docContent) : propertyContent;
|
|
304
|
-
let type = this.getTypeFromArray(schema.type);
|
|
305
|
-
|
|
306
|
-
// for nested object
|
|
307
|
-
if (type === 'object') {
|
|
308
|
-
if (!schema.properties) return {};
|
|
309
|
-
for (const [key, value] of Object.entries(schema.properties)) {
|
|
310
|
-
properties[key] = this.getTypeElements(value, docContent, types);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
// for nested array
|
|
314
|
-
else if (type === 'array') {
|
|
315
|
-
if (!schema.items || (!schema.items.type && !schema.items['$ref'] && !schema.items.allOf)) return {};
|
|
316
|
-
properties.items = this.getTypeElements(schema.items, docContent, types);
|
|
317
|
-
return properties;
|
|
318
|
-
}
|
|
319
|
-
// base data type mapping
|
|
320
|
-
else {
|
|
321
|
-
return this.getPropertyObject(schema, docContent, types);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
return { elements: properties };
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Unwraps nullable array type representations to a single type string.
|
|
329
|
-
* @param {string | string[] | undefined} typeValue
|
|
330
|
-
*/
|
|
331
|
-
getTypeFromArray(typeValue) {
|
|
332
|
-
let type;
|
|
333
|
-
// if type is an array
|
|
334
|
-
if (Array.isArray(typeValue)) {
|
|
335
|
-
// one of the value will be null
|
|
336
|
-
type = typeValue[0] === 'null' ? typeValue[1] : typeValue[0];
|
|
337
|
-
} else {
|
|
338
|
-
type = typeValue;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
return type;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Returns the CSN element object for a scalar or $ref property.
|
|
346
|
-
* @param {AsyncApiSchema} propertyContent - AsyncAPI schema for this property
|
|
347
|
-
* @param {AsyncApiDocument} docContent - root AsyncAPI document, used to resolve $ref entries
|
|
348
|
-
* @param {CsnTypeMap} types - accumulator for generated CDS type definitions
|
|
349
|
-
*/
|
|
350
|
-
getPropertyObject(propertyContent, docContent, types) {
|
|
351
|
-
/** @type {CsnElement} */
|
|
352
|
-
const property = {};
|
|
353
|
-
if ('$ref' in propertyContent) {
|
|
354
|
-
const refPathParts = (propertyContent['$ref'] ?? '').split('/');
|
|
355
|
-
const schemaName = refPathParts[3] ?? '';
|
|
356
|
-
const isWholeSchemaRef = () => refPathParts.length === 4 && refPathParts[1] === 'components' && refPathParts[2] === 'schemas';
|
|
357
|
-
|
|
358
|
-
if (isWholeSchemaRef()) {
|
|
359
|
-
// $ref to a whole top-level schema — resolve it and emit as a CDS type
|
|
360
|
-
if (!types[schemaName]) {
|
|
361
|
-
types[schemaName] = null; // placeholder to guard against circular refs
|
|
362
|
-
const resolvedSchema = this.resolveRef(docContent, propertyContent);
|
|
363
|
-
const flatSchema = resolvedSchema.allOf ? this.flattenAllOf(resolvedSchema, docContent) : resolvedSchema;
|
|
364
|
-
const elements = this.getTypeElements(flatSchema, docContent, types);
|
|
365
|
-
// only emit a named type if it has structure; otherwise fall back to LargeString
|
|
366
|
-
if (Object.keys(elements).length > 0) {
|
|
367
|
-
types[schemaName] = { 'kind': 'type', '@cds.external': 'true', ...elements };
|
|
368
|
-
} else {
|
|
369
|
-
delete types[schemaName];
|
|
370
|
-
property['type'] = 'cds.LargeString';
|
|
371
|
-
return property;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
property['type'] = schemaName;
|
|
375
|
-
} else {
|
|
376
|
-
// $ref to a specific property within a schema (e.g. /properties/propName)
|
|
377
|
-
const propertyName = refPathParts[refPathParts.length - 1];
|
|
378
|
-
property['type'] = { 'ref': [schemaName, propertyName] };
|
|
379
|
-
}
|
|
380
|
-
return property;
|
|
381
|
-
}
|
|
382
|
-
const inputType = this.getTypeFromArray(propertyContent.type);
|
|
383
|
-
const cdsType = this.getDataType(inputType, propertyContent.format);
|
|
384
|
-
|
|
385
|
-
property['type'] = cdsType;
|
|
386
|
-
|
|
387
|
-
// case: cds type is decimal
|
|
388
|
-
if (cdsType === 'cds.Decimal') {
|
|
389
|
-
if (propertyContent['x-sap-precision']) property.precision = propertyContent['x-sap-precision'];
|
|
390
|
-
if (propertyContent['x-sap-scale']) property.scale = propertyContent['x-sap-scale'];
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if (propertyContent['default']) {
|
|
394
|
-
property['default'] = { 'val': propertyContent['default'] };
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
if (propertyContent['enum']) {
|
|
398
|
-
property['enum'] = this.getEnumObject(propertyContent['enum']);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
return property;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* @param {Array<*>} enumArray
|
|
406
|
-
*/
|
|
407
|
-
getEnumObject(enumArray) {
|
|
408
|
-
/** @type {Record<string, {}>} */
|
|
409
|
-
const enumProperty = {};
|
|
410
|
-
|
|
411
|
-
enumArray.forEach(val => {
|
|
412
|
-
enumProperty[String(val)] = {};
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
return enumProperty;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* @param {string | undefined} type - AsyncAPI primitive type
|
|
420
|
-
* @param {string | null} format - AsyncAPI format string
|
|
421
|
-
*/
|
|
422
|
-
getDataType(type, format = null) {
|
|
423
|
-
if (!type) throw new Error(messages.UNRESOLVED_TYPE + `'${type}'`);
|
|
424
|
-
/** @type {Record<string, string>} */
|
|
425
|
-
const asyncapiToCdsMapping = {
|
|
426
|
-
'number': 'cds.Double',
|
|
427
|
-
'boolean': 'cds.Boolean',
|
|
428
|
-
'integer': 'cds.Integer'
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
if (type === 'string') {
|
|
432
|
-
switch (format) {
|
|
433
|
-
case 'int64':
|
|
434
|
-
return 'cds.Integer64';
|
|
435
|
-
case 'decimal':
|
|
436
|
-
return 'cds.Decimal';
|
|
437
|
-
case 'uuid':
|
|
438
|
-
return 'cds.UUID';
|
|
439
|
-
case 'date':
|
|
440
|
-
return 'cds.Date';
|
|
441
|
-
case 'partial-time':
|
|
442
|
-
return 'cds.Time';
|
|
443
|
-
case 'date-time':
|
|
444
|
-
return 'cds.Timestamp';
|
|
445
|
-
default:
|
|
446
|
-
return 'cds.LargeString';
|
|
447
|
-
}
|
|
448
|
-
} else if (asyncapiToCdsMapping[type]) {
|
|
449
|
-
return asyncapiToCdsMapping[type];
|
|
450
|
-
} else {
|
|
451
|
-
throw new Error(messages.UNRESOLVED_TYPE + `'${type}'`);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const messages = require("../message").getMessages();
|
|
2
|
-
|
|
3
|
-
function validateAsyncAPI(content) {
|
|
4
|
-
if ('channels' in content && 'components' in content && 'messages' in content.components) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
throw new Error(messages.INVALID_ASYNCAPI_FILE);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Accepted scenarios:
|
|
13
|
-
* * with version info : <namespace>.<businessObject>.<operation>.<version>
|
|
14
|
-
* * without version info : <namespace>.<businessObject>.<operation>
|
|
15
|
-
*
|
|
16
|
-
* ? Is it mandatory for <namespace> to always follow small case notation?
|
|
17
|
-
* ? Is it mandatory for <businessObject> to follow Camel Case or Upper Came Case notation?
|
|
18
|
-
*
|
|
19
|
-
* ToDo: Can we support `-` in operations?
|
|
20
|
-
*/
|
|
21
|
-
const regExp = new RegExp(
|
|
22
|
-
'^(?<namespace>(?:[a-z][a-z0-9]*)(?:[.][a-z][a-z0-9]*)+)[.](?<businessObject>[a-zA-Z0-9]+)[.](?<operation>[a-zA-Z0-9]+)[.]?(?<version>v(?:[0-9]|[1-9][0-9]*))?$'
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Validates the messages' `key` with the regExp and returns the regEx groups.
|
|
27
|
-
* @returns regexGroups
|
|
28
|
-
*/
|
|
29
|
-
function getRegExpGroups(key) {
|
|
30
|
-
/**
|
|
31
|
-
* Result format:
|
|
32
|
-
* index 0: key
|
|
33
|
-
* index 1: <namespace> value
|
|
34
|
-
* index 2: <businessObject> value
|
|
35
|
-
* index 3: <operation> value
|
|
36
|
-
* index 4: <version> value; undefined if <version> is optional
|
|
37
|
-
*/
|
|
38
|
-
const regExpGroups = regExp.exec(key);
|
|
39
|
-
|
|
40
|
-
if (regExpGroups == null) {
|
|
41
|
-
throw new Error(messages.INVALID_MESSAGE_NAME);
|
|
42
|
-
}
|
|
43
|
-
return regExpGroups;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
module.exports = {
|
|
47
|
-
validateAsyncAPI,
|
|
48
|
-
getRegExpGroups
|
|
49
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const READ_QUERY = /* GraphQL */ `
|
|
2
|
-
query ($key: String!, $value: String!) {
|
|
3
|
-
applicationTemplates(filter: { key: $key, query: $value }) {
|
|
4
|
-
data {
|
|
5
|
-
id
|
|
6
|
-
name
|
|
7
|
-
description
|
|
8
|
-
placeholders {
|
|
9
|
-
name
|
|
10
|
-
description
|
|
11
|
-
}
|
|
12
|
-
applicationInput
|
|
13
|
-
labels
|
|
14
|
-
webhooks {
|
|
15
|
-
type
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
`
|
|
21
|
-
|
|
22
|
-
const CREATE_MUTATION = /* GraphQL */ `
|
|
23
|
-
mutation ($input: ApplicationTemplateInput!) {
|
|
24
|
-
result: createApplicationTemplate(in: $input) {
|
|
25
|
-
id
|
|
26
|
-
name
|
|
27
|
-
labels
|
|
28
|
-
applicationInput
|
|
29
|
-
applicationNamespace
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
`
|
|
33
|
-
|
|
34
|
-
const UPDATE_MUTATION = /* GraphQL */ `
|
|
35
|
-
mutation ($id: ID!, $input: ApplicationTemplateUpdateInput!) {
|
|
36
|
-
result: updateApplicationTemplate(id: $id, in: $input) {
|
|
37
|
-
id
|
|
38
|
-
name
|
|
39
|
-
labels
|
|
40
|
-
description
|
|
41
|
-
applicationInput
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
`
|
|
45
|
-
|
|
46
|
-
const DELETE_MUTATION = /* GraphQL */ `
|
|
47
|
-
mutation ($id: ID!) {
|
|
48
|
-
result: deleteApplicationTemplate(id: $id) {
|
|
49
|
-
id
|
|
50
|
-
name
|
|
51
|
-
description
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
`
|
|
55
|
-
|
|
56
|
-
module.exports = {
|
|
57
|
-
READ_QUERY,
|
|
58
|
-
CREATE_MUTATION,
|
|
59
|
-
UPDATE_MUTATION,
|
|
60
|
-
DELETE_MUTATION
|
|
61
|
-
}
|