@sap/cds-dk 7.9.6 → 8.0.3
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 +2136 -0
- package/bin/add.js +18 -52
- package/bin/bind.js +2 -2
- package/bin/build.js +29 -4
- package/bin/cds.js +31 -14
- package/bin/compile/index.js +7 -6
- package/bin/completion/index.js +70 -46
- package/bin/completion/scripts/cds-bash.sh +4 -1
- package/bin/completion/scripts/cds-fish.fish +13 -0
- package/bin/completion/scripts/cds-ps.ps1 +2 -1
- package/bin/completion/scripts/cds-zsh.sh +2 -1
- package/bin/deploy/index.js +6 -5
- package/bin/deploy/to-sqlite.js +2 -2
- package/bin/extend.js +19 -50
- package/bin/help.js +2 -2
- package/bin/init.js +10 -77
- package/bin/login.js +13 -5
- package/bin/migrate.js +1 -1
- package/bin/pull.js +11 -0
- package/bin/repl.js +3 -0
- package/bin/test.js +5 -0
- package/bin/version.js +7 -7
- package/bin/watch.js +13 -14
- package/lib/bind/KubernetesApiAccessor.js +10 -9
- package/lib/build/buildTaskEngine.js +11 -7
- package/lib/build/buildTaskFactory.js +15 -43
- package/lib/build/buildTaskProviderFactory.js +16 -44
- package/lib/build/constants.js +4 -3
- package/lib/build/index.js +2 -2
- package/lib/build/{buildPlugin.js → plugin.js} +65 -46
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/Chart.yaml +1 -1
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/values.yaml +1 -1
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/Chart.yaml +1 -1
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/templates/_helpers.tpl +7 -0
- package/lib/build/plugins/helm/files/subcharts/service-instance/templates/servicebinding.yaml +32 -0
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/templates/serviceinstance.yaml +3 -0
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/values.schema.json +63 -0
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/values.yaml +23 -1
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/Chart.yaml +1 -1
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/deployment.yaml +2 -0
- package/lib/build/plugins/helm/files/subcharts/web-application/templates/hpa.yaml +22 -0
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/pod-disruption-budget.yaml +1 -0
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/values.schema.json +49 -0
- package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/values.yaml +8 -2
- package/lib/{init/template/helm/files/chart → build/plugins/helm/files}/templates/_deployment_helpers.tpl +5 -0
- package/lib/build/plugins/helm/files/templates/_helpers.tpl +13 -0
- package/lib/build/plugins/helm/index.js +81 -0
- package/lib/build/plugins.js +12 -15
- package/lib/build/provider/featureToggleBuildPlugin.js +7 -39
- package/lib/build/provider/hana/2migration.js +168 -124
- package/lib/build/provider/hana/index.js +69 -56
- package/lib/build/provider/hana/template/package.json +4 -3
- package/lib/build/provider/internalBuildPlugin.js +32 -97
- package/lib/build/provider/internalBuildTaskProvider.js +12 -48
- package/lib/build/provider/java/index.js +2 -3
- package/lib/build/provider/mtx/index.js +5 -4
- package/lib/build/provider/mtx-extension/index.js +5 -2
- package/lib/build/provider/mtx-sidecar/index.js +2 -2
- package/lib/build/provider/nodejs/index.js +4 -3
- package/lib/build/util.js +83 -12
- package/lib/compile/to-mermaid.js +108 -0
- package/lib/compile/to_asyncapi.js +7 -0
- package/lib/compile/to_openapi.js +7 -0
- package/lib/deploy/to-hana/hana.js +37 -34
- package/lib/deploy/to-hana/hdiDeployUtil.js +8 -6
- package/lib/env/schemas/cds-rc.js +1 -1
- package/lib/import/common.js +2 -2
- package/lib/import/odata/metadataconverter/MetadataConverter.js +4 -4
- package/lib/import/odata/v2parser.js +83 -197
- package/lib/import/odata/v4parser.js +1 -38
- package/lib/import/openapi/importOpenAPI.js +164 -42
- package/lib/index.js +10 -12
- package/lib/init/bas.js +91 -0
- package/lib/init/constants.js +21 -11
- package/lib/init/index.js +72 -150
- package/lib/init/merge.js +12 -20
- package/lib/init/mvn.js +103 -150
- package/lib/init/plugin.js +11 -7
- package/lib/init/projectReader.js +53 -20
- package/lib/init/registries/mta.js +51 -6
- package/lib/init/template/application-logging/files/package.json.hbs +7 -0
- package/lib/init/template/application-logging/index.js +13 -1
- package/lib/init/template/approuter/files/containerize.yaml.hbs +10 -0
- package/lib/init/template/approuter/files/mta.yaml.hbs +1 -2
- package/lib/init/template/approuter/files/values.yaml.hbs +19 -4
- package/lib/init/template/approuter/files/xs-app.json.hbs +12 -3
- package/lib/init/template/approuter/index.js +29 -25
- package/lib/init/template/attachments/files/mta.yaml.hbs +14 -0
- package/lib/init/template/attachments/files/package.json.hbs +5 -0
- package/lib/init/template/attachments/files/values.yaml +7 -0
- package/lib/init/template/attachments/index.js +53 -0
- package/lib/init/template/{redis-messaging → audit-logging}/files/mta.yaml.hbs +4 -4
- package/lib/init/template/audit-logging/files/package.json.hbs +7 -0
- package/lib/init/template/audit-logging/index.js +66 -0
- package/lib/init/template/cf-manifest/index.js +4 -0
- package/lib/init/template/completion/completionSetup.js +54 -33
- package/lib/init/template/completion/index.js +7 -1
- package/lib/init/template/connectivity/index.js +4 -4
- package/lib/init/template/containerize/files/containerize.yaml.hbs +26 -0
- package/lib/init/template/containerize/index.js +24 -0
- package/lib/init/template/data/index.js +4 -0
- package/lib/init/template/destination/files/mta.yaml.hbs +31 -1
- package/lib/init/template/destination/files/package.sidecar.json +7 -0
- package/lib/init/template/destination/index.js +22 -2
- package/lib/init/template/enterprise-messaging/index.js +6 -3
- package/lib/init/template/enterprise-messaging-shared/index.js +5 -1
- package/lib/init/template/extensibility/files/package.json.hbs +1 -1
- package/lib/init/template/extensibility/files/xs-security.json.hbs +2 -8
- package/lib/init/template/extensibility/index.js +3 -1
- package/lib/init/template/file-based-messaging/index.js +4 -0
- package/lib/init/template/h2/index.js +4 -0
- package/lib/init/template/hana/files/containerize.yaml.hbs +10 -0
- package/lib/init/template/hana/files/db/package.json +3 -2
- package/lib/init/template/hana/files/package.json.hbs +4 -7
- package/lib/init/template/hana/files/values.yaml.hbs +1 -2
- package/lib/init/template/hana/index.js +15 -7
- package/lib/init/template/helm/files/Chart.yaml.hbs +2 -3
- package/lib/init/template/helm/files/values.schema.json +2173 -0
- package/lib/init/template/helm/files/values.yaml.hbs +11 -6
- package/lib/init/template/helm/index.js +77 -18
- package/lib/init/template/helm-unified-runtime/index.js +19 -56
- package/lib/init/template/html5-repo/files/app-package.json.hbs +11 -7
- package/lib/init/template/html5-repo/files/manifest.json +13 -0
- package/lib/init/template/html5-repo/files/mta.yaml.hbs +14 -33
- package/lib/init/template/html5-repo/files/package.sidecar.json +7 -0
- package/lib/init/template/html5-repo/files/ui5-deploy.yaml.hbs +21 -0
- package/lib/init/template/html5-repo/files/ui5.yaml.hbs +2 -29
- package/lib/init/template/html5-repo/files/values.yaml.hbs +6 -2
- package/lib/init/template/html5-repo/files/xs-app.json.hbs +6 -7
- package/lib/init/template/html5-repo/index.js +41 -35
- package/lib/init/template/http/index.js +36 -12
- package/lib/init/template/java/index.js +18 -12
- package/lib/init/template/kafka/index.js +4 -0
- package/lib/init/template/lint/index.js +7 -2
- package/lib/init/template/liquibase/index.js +4 -0
- package/lib/init/template/local-messaging/index.js +4 -0
- package/lib/init/template/malware-scanner/files/mta.yaml.hbs +14 -0
- package/lib/init/template/malware-scanner/files/package.json.hbs +17 -0
- package/lib/init/template/malware-scanner/files/values.yaml +7 -0
- package/lib/init/template/malware-scanner/index.js +47 -0
- package/lib/init/template/mta/files/mta.yaml.hbs +3 -3
- package/lib/init/template/mta/files/package.json +1 -1
- package/lib/init/template/mta/index.js +4 -0
- package/lib/init/template/mtx/index.js +4 -0
- package/lib/init/template/multitenancy/files/containerize.yaml.hbs +10 -0
- package/lib/init/template/multitenancy/files/mta.yaml.hbs +0 -1
- package/lib/init/template/multitenancy/files/package.json.hbs +1 -1
- package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +6 -5
- package/lib/init/template/multitenancy/files/values.yaml.hbs +14 -24
- package/lib/init/template/multitenancy/index.js +50 -28
- package/lib/init/template/nodejs/files/eslint.config.mjs +2 -0
- package/lib/init/template/nodejs/files/package.json.hbs +2 -3
- package/lib/init/template/nodejs/index.js +4 -0
- package/lib/init/template/notifications/files/mta.yaml.hbs +2 -2
- package/lib/init/template/notifications/index.js +4 -0
- package/lib/init/template/pipeline/files/.pipeline/config.yml +1 -1
- package/lib/init/template/pipeline/files/Jenkinsfile +1 -1
- package/lib/init/template/pipeline/index.js +4 -0
- package/lib/init/template/portal/files/mta.yaml.hbs +52 -0
- package/lib/init/template/portal/files/package.json.hbs +11 -0
- package/lib/init/template/portal/files/package.sidecar.json +7 -0
- package/lib/init/template/portal/files/portal-site/CommonDataModel.json.hbs +97 -0
- package/lib/init/template/portal/files/portal-site/i18n/catalog.properties +1 -0
- package/lib/init/template/portal/files/portal-site/i18n/catalog_de.properties +1 -0
- package/lib/init/template/portal/files/portal-site/i18n/group.properties +1 -0
- package/lib/init/template/portal/files/portal-site/i18n/group_de.properties +1 -0
- package/lib/init/template/portal/index.js +84 -0
- package/lib/init/template/postgres/index.js +5 -1
- package/lib/init/template/redis/files/mta.yaml.hbs +25 -0
- package/lib/init/template/redis/files/package.json.hbs +5 -0
- package/lib/init/template/redis/index.js +44 -0
- package/lib/init/template/redis-messaging/files/package.json.hbs +0 -3
- package/lib/init/template/redis-messaging/index.js +8 -18
- package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n_de.properties +3 -0
- package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n_en.properties +3 -0
- package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +13 -1
- package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n.properties +2 -2
- package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n_de.properties +3 -0
- package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n_en.properties +4 -0
- package/lib/init/template/sample/files/app/browse/webapp/manifest.json +3 -3
- package/lib/init/template/sample/files/app/index.html +1 -1
- package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Authors.csv +5 -5
- package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Books.csv +6 -6
- package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Books_texts.csv +5 -5
- package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Genres.csv +16 -16
- package/lib/init/template/sample/files/nodejs/cat-service.js +2 -2
- package/lib/init/template/sample/files/package.json.hbs +3 -0
- package/lib/init/template/sample/index.js +16 -9
- package/lib/init/template/sqlite/index.js +4 -0
- package/lib/init/template/tiny-sample/files/nodejs/db/data/my.bookshop-Books.csv +3 -3
- package/lib/init/template/tiny-sample/files/nodejs/srv/cat-service.cds.hbs +1 -1
- package/lib/init/template/tiny-sample/index.js +4 -0
- package/lib/init/template/toggles/files/package.json.hbs +1 -1
- package/lib/init/template/toggles/index.js +4 -0
- package/lib/init/template/typer/index.js +4 -0
- package/lib/init/template/typescript/files/package.json +12 -0
- package/lib/init/template/typescript/files/tsconfig.json +13 -0
- package/lib/init/template/typescript/index.js +39 -0
- package/lib/init/template/workzone/index.js +9 -0
- package/lib/init/template/workzone-standard/files/manifest.json.hbs +6 -0
- package/lib/init/template/workzone-standard/files/mta.yaml.hbs +59 -0
- package/lib/init/template/workzone-standard/index.js +46 -0
- package/lib/init/template/xsuaa/files/package.json.hbs +1 -1
- package/lib/init/template/xsuaa/files/values.yaml.hbs +3 -2
- package/lib/init/template/xsuaa/index.js +11 -7
- package/lib/init/validate.js +27 -0
- package/lib/lint/generators.js +1 -1
- package/lib/lint/io.js +25 -7
- package/lib/mtx/auth_manager.js +64 -30
- package/lib/mtx/download_legacy.js +2 -2
- package/lib/mtx/index.js +0 -4
- package/lib/mtx/params.js +32 -38
- package/lib/mtx/pull.js +151 -43
- package/lib/mtx/push.js +3 -3
- package/lib/mtx/settings_manager.js +75 -35
- package/lib/mtx/tenant_action.js +1 -1
- package/lib/mtx/util/cf.js +1 -1
- package/lib/mtx/util/fs.js +26 -1
- package/lib/mtx/util/logging.js +7 -3
- package/lib/util/command.js +0 -2
- package/lib/util/fs.js +2 -3
- package/lib/util/question.js +28 -0
- package/lib/util/term.js +5 -3
- package/npm-shrinkwrap.json +225 -1083
- package/package.json +13 -8
- package/bin/activate.js +0 -77
- package/lib/compile/asyncapi/channels.js +0 -22
- package/lib/compile/asyncapi/components/messageTraits/index.js +0 -89
- package/lib/compile/asyncapi/components/messages/index.js +0 -173
- package/lib/compile/asyncapi/components/schemas/annotations.js +0 -33
- package/lib/compile/asyncapi/components/schemas/array.js +0 -8
- package/lib/compile/asyncapi/components/schemas/cache.js +0 -14
- package/lib/compile/asyncapi/components/schemas/definition.js +0 -187
- package/lib/compile/asyncapi/components/schemas/enum.js +0 -16
- package/lib/compile/asyncapi/components/schemas/examples.js +0 -10
- package/lib/compile/asyncapi/components/schemas/index.js +0 -14
- package/lib/compile/asyncapi/components/schemas/localized.js +0 -29
- package/lib/compile/asyncapi/components/schemas/primitiveElement.js +0 -41
- package/lib/compile/asyncapi/components/schemas/ref.js +0 -45
- package/lib/compile/asyncapi/components/schemas/utils.js +0 -108
- package/lib/compile/asyncapi/index.js +0 -247
- package/lib/compile/asyncapi/message.js +0 -13
- package/lib/compile/asyncapi/utils.js +0 -27
- package/lib/compile/openapi/csdl2openapi.js +0 -2448
- package/lib/compile/openapi/index.js +0 -68
- package/lib/init/template/helm/files/chart/templates/NOTES.txt +0 -14
- package/lib/init/template/helm/files/chart/templates/_helpers.tpl +0 -28
- package/lib/init/template/helm/files/chart/values.root.schema.json +0 -61
- package/lib/init/template/helm/files/chart/values.schema.json +0 -366
- package/lib/init/template/helm-unified-runtime/files/Chart.yaml.hbs +0 -10
- package/lib/init/template/helm-unified-runtime/files/templates/_deployment_helpers.tpl +0 -90
- package/lib/init/template/helm-unified-runtime/files/templates/_helpers.tpl +0 -28
- package/lib/init/template/helm-unified-runtime/files/values.root.schema.json +0 -61
- package/lib/init/template/helm-unified-runtime/files/values.schema.json +0 -366
- package/lib/init/template/helm-unified-runtime/files/values.yaml.hbs +0 -26
- package/lib/init/template/helm-unified-runtime/package.json +0 -4
- package/lib/init/template/multitenancy/files/mtxs-configmap-java-approuter.yaml +0 -20
- package/lib/init/template/multitenancy/files/mtxs-configmap-java.yaml +0 -18
- package/lib/init/template/multitenancy/files/mtxs-configmap-nodejs-approuter.yaml +0 -12
- package/lib/init/template/multitenancy/files/mtxs-configmap-nodejs.yaml +0 -12
- package/lib/init/template/multitenancy/files/saas-registry-secret.yaml +0 -9
- package/lib/init/template/nodejs/files/eslint.config.js +0 -13
- package/lib/init/template/notebook/index.js +0 -11
- package/lib/init/template/samples/index.js +0 -9
- package/lib/mtx/activate.js +0 -238
- package/lib/mtx/extend.js +0 -173
- package/lib/util/exec.d.ts +0 -54
- package/lib/util/exec.js +0 -211
- /package/lib/{init/template/approuter/files → build/plugins/helm/files/plugins/approuter}/approuter-configmap.yaml +0 -0
- /package/lib/{init/template/connectivity/files → build/plugins/helm/files/plugins/connectivity}/connectivity-proxy-info.yaml +0 -0
- /package/lib/{init/template/html5-repo/files → build/plugins/helm/files/plugins/html5-repo}/html5-apps-deployer-configmap.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/_helpers.tpl +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/job.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/secret.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/service-account.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/service-binding.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/values.schema.json +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/NOTES.txt +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/_api.tpl +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/_helpers.tpl +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/api-rule.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/network-policy.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/rbac.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/secret.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/service-account.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/service-binding.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/service.yaml +0 -0
- /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/virtual-service.yaml +0 -0
- /package/lib/{init/template/helm-unified-runtime → build/plugins/helm}/files/templates/NOTES.txt +0 -0
- /package/lib/init/template/{nodejs/files → java}/.cdsrc.json +0 -0
- /package/lib/init/template/tiny-sample/files/nodejs/db/{data-model.cds → schema.cds} +0 -0
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const { definitionToSchema } = require('./definition');
|
|
2
|
-
const { getEventName } = require('../../utils');
|
|
3
|
-
|
|
4
|
-
module.exports = function csnToJSONSchema(definitions, events) {
|
|
5
|
-
let schemaCache = {};
|
|
6
|
-
let schema = {};
|
|
7
|
-
|
|
8
|
-
events.forEach(event => {
|
|
9
|
-
const eventName = getEventName(event, definitions[event]);
|
|
10
|
-
schema[eventName] = definitionToSchema(event, definitions, schemaCache);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
return schema;
|
|
14
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const primitiveElementToSchema = require('./primitiveElement');
|
|
2
|
-
const { getBaseTypeStructure } = require('./utils');
|
|
3
|
-
|
|
4
|
-
function getPatternStructure(pattern, example) {
|
|
5
|
-
var schema = getBaseTypeStructure('string');
|
|
6
|
-
schema.pattern = pattern;
|
|
7
|
-
if (example) {
|
|
8
|
-
schema.examples = [example];
|
|
9
|
-
}
|
|
10
|
-
return schema;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function toLocalizedArray(localizedElement) {
|
|
14
|
-
return {
|
|
15
|
-
type: "array",
|
|
16
|
-
items: {
|
|
17
|
-
type: "object",
|
|
18
|
-
properties: {
|
|
19
|
-
lang: getPatternStructure('^[a-z]{2}(?:-[A-z]{2})?$'),
|
|
20
|
-
content: primitiveElementToSchema(localizedElement)
|
|
21
|
-
},
|
|
22
|
-
required: ['lang', 'content']
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
module.exports = {
|
|
28
|
-
toLocalizedArray
|
|
29
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const Examples = require('./examples');
|
|
2
|
-
const { getBaseTypeStructure, getFormatStructure, toString } = require('./utils');
|
|
3
|
-
|
|
4
|
-
module.exports = function primitiveElementToSchema(entry) {
|
|
5
|
-
switch(entry.type) {
|
|
6
|
-
case 'cds.Boolean':
|
|
7
|
-
return getBaseTypeStructure("boolean");
|
|
8
|
-
case 'cds.Integer':
|
|
9
|
-
return getBaseTypeStructure("integer");
|
|
10
|
-
case 'cds.Double':
|
|
11
|
-
return getBaseTypeStructure("number");
|
|
12
|
-
case 'cds.UUID':
|
|
13
|
-
return getFormatStructure("uuid", Examples.UUID_EXAMPLE);
|
|
14
|
-
case 'cds.Integer64':
|
|
15
|
-
return getFormatStructure("int64", Examples.INT_64_EXAMPLE);
|
|
16
|
-
case 'cds.Decimal': {
|
|
17
|
-
let schema = getFormatStructure("decimal", Examples.DECIMAL_EXAMPLE);
|
|
18
|
-
if (entry.precision) {
|
|
19
|
-
schema['x-sap-precision'] = entry.precision;
|
|
20
|
-
}
|
|
21
|
-
if (entry.scale) {
|
|
22
|
-
schema['x-sap-scale'] = entry.scale;
|
|
23
|
-
}
|
|
24
|
-
return schema;
|
|
25
|
-
}
|
|
26
|
-
case 'cds.Date':
|
|
27
|
-
return getFormatStructure("date", Examples.DATE_EXAMPLE);
|
|
28
|
-
case 'cds.Time':
|
|
29
|
-
return getFormatStructure("partial-time", Examples.PARTIAL_TIME_EXAMPLE);
|
|
30
|
-
case 'cds.DateTime':
|
|
31
|
-
case 'cds.Timestamp':
|
|
32
|
-
return getFormatStructure("date-time", Examples.DATE_TIME_EXAMPLE);
|
|
33
|
-
case 'cds.String':
|
|
34
|
-
case 'cds.LargeString':
|
|
35
|
-
case 'cds.Binary':
|
|
36
|
-
case 'cds.LargeBinary':
|
|
37
|
-
return toString(entry);
|
|
38
|
-
default:
|
|
39
|
-
throw new Error(`Unsupported type ${entry.type}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const { isElements, isRefEntry } = require('./utils');
|
|
2
|
-
|
|
3
|
-
function followRefRecursive(definitions, ref) {
|
|
4
|
-
const element = followRef(definitions, ref);
|
|
5
|
-
|
|
6
|
-
if (isRefEntry(element)) {
|
|
7
|
-
return followRefRecursive(definitions, element.type);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return element;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function followRef(definitions, { ref }) {
|
|
14
|
-
const definition = definitions[ref[0]];
|
|
15
|
-
|
|
16
|
-
if (!definition) {
|
|
17
|
-
throw new Error(`Cannot find definition '${ref[0]}'`);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (!isElements(definition.elements)) {
|
|
21
|
-
throw new Error(`'${ref[0]}' is not a structured type`);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
let pointer = definition.elements;
|
|
25
|
-
let element;
|
|
26
|
-
|
|
27
|
-
// Navigate down to the last elements section
|
|
28
|
-
for (let elementIndex = 1; elementIndex < ref.length; elementIndex++) {
|
|
29
|
-
element = pointer[ref[elementIndex]];
|
|
30
|
-
|
|
31
|
-
if (element && isElements(element.elements)) {
|
|
32
|
-
pointer = element.elements;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (!element) {
|
|
37
|
-
throw new Error(`Cannot resolve reference '${ref.join(':')}'`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return element;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
module.exports = {
|
|
44
|
-
followRefRecursive
|
|
45
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
function toString(element) {
|
|
3
|
-
let schema = getBaseTypeStructure("string");
|
|
4
|
-
|
|
5
|
-
if ('length' in element && typeof element.length === 'number') {
|
|
6
|
-
schema.maxLength = element.length;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
return schema;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getBaseTypeStructure(type) {
|
|
13
|
-
return { type: type };
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function getFormatStructure(format, example) {
|
|
17
|
-
let schema = getBaseTypeStructure("string");
|
|
18
|
-
|
|
19
|
-
schema.format = format;
|
|
20
|
-
if (example) {
|
|
21
|
-
schema.example = [example];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return schema;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function isAssociation(entry) {
|
|
28
|
-
return !!entry && entry.type === 'cds.Association';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function isComposition(entry) {
|
|
32
|
-
return !!entry && entry.type === 'cds.Composition';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function isStructured(entry) {
|
|
36
|
-
return !!entry && typeof entry === 'object' && 'elements' in entry && isElements(entry.elements);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function isToMany(entry) {
|
|
40
|
-
return entry.cardinality?.max === '*' || (typeof entry.cardinality?.max === 'number' && entry.cardinality?.max > 1);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function isDefault(entry) {
|
|
44
|
-
return "default" in entry;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function isEnum(entry) {
|
|
48
|
-
return "enum" in entry;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function addDefaultValue(entry, schema) {
|
|
52
|
-
schema.default = entry.default.val;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function isVal(value) {
|
|
56
|
-
return typeof value === 'object' && !!value && 'val' in value && Object.keys(value).length === 1;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function isElements(value) {
|
|
60
|
-
return typeof value === 'object' && !!value && !Array.isArray(value) && !('=' in value) && !isVal(value);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function isManyEntry(entry) {
|
|
64
|
-
return (
|
|
65
|
-
'items' in entry &&
|
|
66
|
-
typeof entry.items === 'object' &&
|
|
67
|
-
!!entry.items &&
|
|
68
|
-
(('type' in entry.items && typeof entry.items.type === 'string') ||
|
|
69
|
-
('elements' in entry.items && isElements(entry.items.elements)))
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function isLocalizedElement(name, element) {
|
|
74
|
-
return (((name === 'texts' && isComposition(element)) || (name === 'localized' && isAssociation(element))) &&
|
|
75
|
-
element.target.endsWith('.texts'));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function isToManyAssociation(entry) {
|
|
79
|
-
return isAssociation(entry) && isToMany(entry);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function elementIsRelevant(name, element) {
|
|
83
|
-
return !isLocalizedElement(name, element);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function isRefEntry(entry) {
|
|
87
|
-
let type = entry.type;
|
|
88
|
-
return typeof type === 'object' && !!type && 'ref' in type && Array.isArray(type.ref);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
module.exports = {
|
|
92
|
-
toString,
|
|
93
|
-
getBaseTypeStructure,
|
|
94
|
-
getFormatStructure,
|
|
95
|
-
isAssociation,
|
|
96
|
-
isComposition,
|
|
97
|
-
isStructured,
|
|
98
|
-
isToMany,
|
|
99
|
-
isDefault,
|
|
100
|
-
addDefaultValue,
|
|
101
|
-
isEnum,
|
|
102
|
-
isVal,
|
|
103
|
-
elementIsRelevant,
|
|
104
|
-
isManyEntry,
|
|
105
|
-
isElements,
|
|
106
|
-
isRefEntry,
|
|
107
|
-
isToManyAssociation
|
|
108
|
-
}
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
const csnToJSONSchema = require('./components/schemas');
|
|
2
|
-
const getMessageTraits = require('./components/messageTraits');
|
|
3
|
-
const { definitionsToMessages, nestedAnnotation } = require('./components/messages');
|
|
4
|
-
const getChannels = require('./channels');
|
|
5
|
-
const cds = require('../../cds');
|
|
6
|
-
const messages = require("./message");
|
|
7
|
-
const presetMapping = {
|
|
8
|
-
'event_spec_version': 'x-sap-event-spec-version',
|
|
9
|
-
'event_source': 'x-sap-event-source',
|
|
10
|
-
'event_source_params': 'x-sap-event-source-parameters',
|
|
11
|
-
'event_characteristics': 'x-sap-event-characteristics'
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
module.exports = function processor(csn, options = {}) {
|
|
15
|
-
|
|
16
|
-
const envConf = cds.env.export?.asyncapi;
|
|
17
|
-
_serviceErrorHandling(csn, options);
|
|
18
|
-
|
|
19
|
-
const applicationNamespace = envConf?.application_namespace;
|
|
20
|
-
|
|
21
|
-
if (!applicationNamespace) {
|
|
22
|
-
throw new Error(messages.APPLICATION_NAMESPACE);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const presets = getPresets(envConf);
|
|
26
|
-
|
|
27
|
-
if (options.service === 'all') {
|
|
28
|
-
if (options["asyncapi:merged"]) {
|
|
29
|
-
if (!envConf?.merged?.title || !envConf.merged?.version ) {
|
|
30
|
-
throw new Error(messages.TITLE_VERSION_MERGED);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const infoObject = getInfoObject({}, envConf.merged);
|
|
34
|
-
// verify version follows the required pattern
|
|
35
|
-
isVersionValid(infoObject.version);
|
|
36
|
-
const shortTextObj = getShortText({}, envConf.merged.short_text);
|
|
37
|
-
|
|
38
|
-
const events = getEvents(csn.definitions);
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
asyncapi: '2.0.0',
|
|
42
|
-
'x-sap-catalog-spec-version': '1.2',
|
|
43
|
-
'x-sap-application-namespace': applicationNamespace,
|
|
44
|
-
...Object.keys(shortTextObj).length && { 'x-sap-shortText': shortTextObj },
|
|
45
|
-
info: infoObject,
|
|
46
|
-
defaultContentType: 'application/json',
|
|
47
|
-
channels: getChannels(csn.definitions, events),
|
|
48
|
-
components: getComponents(csn.definitions, events, presets)
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
const services = getServicesWithEvents(csn.definitions);
|
|
52
|
-
return _iterate(services, csn, applicationNamespace, presets);
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
const events = getEvents(csn.definitions, options.service);
|
|
56
|
-
|
|
57
|
-
if (events.length === 0) {
|
|
58
|
-
throw new Error(messages.NO_EVENTS);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return _getAsyncApi(csn, events, options.service, applicationNamespace, presets);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function getPresets(envConf) {
|
|
66
|
-
let projectPresets = {};
|
|
67
|
-
for (const [key, value] of Object.entries(envConf)) {
|
|
68
|
-
if (presetMapping[key]) projectPresets[presetMapping[key]] = value;
|
|
69
|
-
}
|
|
70
|
-
return projectPresets;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function _getAsyncApi(csn, events, serviceName, applicationNamespace, presets) {
|
|
74
|
-
|
|
75
|
-
const infoObject = getInfoObject(csn.definitions[serviceName]);
|
|
76
|
-
const stateObj = getStateInfo(csn.definitions[serviceName]);
|
|
77
|
-
const shortTextObj = getShortText(csn.definitions[serviceName]);
|
|
78
|
-
const extensionAnnotationObj = getExtensions(csn.definitions[serviceName], shortTextObj, stateObj);
|
|
79
|
-
return {
|
|
80
|
-
asyncapi: '2.0.0',
|
|
81
|
-
'x-sap-catalog-spec-version': '1.2',
|
|
82
|
-
'x-sap-application-namespace': applicationNamespace,
|
|
83
|
-
...Object.keys(stateObj).length && { 'x-sap-stateInfo': stateObj },
|
|
84
|
-
...Object.keys(shortTextObj).length && { 'x-sap-shortText': shortTextObj },
|
|
85
|
-
...Object.keys(extensionAnnotationObj).length && extensionAnnotationObj,
|
|
86
|
-
info: infoObject,
|
|
87
|
-
defaultContentType: 'application/json',
|
|
88
|
-
channels: getChannels(csn.definitions, events),
|
|
89
|
-
components: getComponents(csn.definitions, events, presets)
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function getExtensions(serviceCsn, shortTextObj, stateObj) {
|
|
94
|
-
let extensionObj = {};
|
|
95
|
-
for (const [key, value] of Object.entries(serviceCsn)) {
|
|
96
|
-
if (key.startsWith('@AsyncAPI.Extensions')) {
|
|
97
|
-
const annotationProperties = key.split('@AsyncAPI.Extensions.')[1];
|
|
98
|
-
const keys = annotationProperties.split('.');
|
|
99
|
-
keys[0] = "x-" + keys[0];
|
|
100
|
-
if ((keys[0] === 'x-sap-shortText' && Object.keys(shortTextObj).length > 0) ||
|
|
101
|
-
(keys[0] === 'x-sap-stateInfo' && Object.keys(stateObj).length > 0)
|
|
102
|
-
) continue;
|
|
103
|
-
if (keys.length === 1) {
|
|
104
|
-
extensionObj[keys[0]] = value;
|
|
105
|
-
} else {
|
|
106
|
-
nestedAnnotation(extensionObj, keys[0], keys, value);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return extensionObj;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function getShortText(serviceCsn, presetValue = undefined) {
|
|
114
|
-
let shortTextValue = presetValue || serviceCsn["@AsyncAPI.ShortText"];
|
|
115
|
-
if (shortTextValue) {
|
|
116
|
-
return shortTextValue;
|
|
117
|
-
}
|
|
118
|
-
return {};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function getStateInfo(serviceCsn) {
|
|
122
|
-
const stateProperties = ['state', 'deprecationDate', 'decomissionedDate', 'link'];
|
|
123
|
-
const stateObj = {};
|
|
124
|
-
|
|
125
|
-
stateProperties.forEach(function (item) {
|
|
126
|
-
if (serviceCsn['@AsyncAPI.StateInfo.' + item]) {
|
|
127
|
-
stateObj[item] = serviceCsn['@AsyncAPI.StateInfo.' + item];
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
return stateObj;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function getInfoObject(serviceCsn, mergedPresetObject = undefined) {
|
|
135
|
-
const info = {};
|
|
136
|
-
|
|
137
|
-
if (mergedPresetObject) {
|
|
138
|
-
Object.keys(mergedPresetObject).forEach(key => {
|
|
139
|
-
if (key !== "short_text") info[key] = mergedPresetObject[key];
|
|
140
|
-
});
|
|
141
|
-
return info;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (!serviceCsn['@AsyncAPI.SchemaVersion'] || !serviceCsn['@AsyncAPI.Title']) {
|
|
145
|
-
throw new Error(messages.TITLE_VERSION_ANNOTATIONS);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
isVersionValid(serviceCsn['@AsyncAPI.SchemaVersion']);
|
|
149
|
-
|
|
150
|
-
info.version = serviceCsn['@AsyncAPI.SchemaVersion'];
|
|
151
|
-
info.title = serviceCsn['@AsyncAPI.Title'];
|
|
152
|
-
|
|
153
|
-
if (serviceCsn['@AsyncAPI.Description']) {
|
|
154
|
-
info.description = serviceCsn['@AsyncAPI.Description'];
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return info;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function isVersionValid(version) {
|
|
161
|
-
version.split('.').forEach(element => {
|
|
162
|
-
if (isNaN(element)) {
|
|
163
|
-
throw new Error(messages.UNSUPPORTED_VERSION);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
return true;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function getEvents(definitions, service = '') {
|
|
170
|
-
let events = [];
|
|
171
|
-
for (const [key, value] of Object.entries(definitions)) {
|
|
172
|
-
if (value.kind === 'event' && value._service !== undefined) {
|
|
173
|
-
if (service === '' || value._service.name === service) {
|
|
174
|
-
events.push(key);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return events;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function getServicesWithEvents(definitions) {
|
|
182
|
-
const services = {};
|
|
183
|
-
|
|
184
|
-
// traverse the definitions list and extract services
|
|
185
|
-
for (const [key, value] of Object.entries(definitions)) {
|
|
186
|
-
if (value.kind === 'service') {
|
|
187
|
-
services[key] = {
|
|
188
|
-
events: []
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// traverse the definitions list and map events to services
|
|
194
|
-
for (const [key, value] of Object.entries(definitions)) {
|
|
195
|
-
if (value.kind === 'event' && value._service) {
|
|
196
|
-
services[value._service.name].events.push(key);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// traverse the services list and remove service with no events
|
|
201
|
-
for (const [key, value] of Object.entries(services)) {
|
|
202
|
-
if (value.events.length === 0) {
|
|
203
|
-
delete services[key];
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return services;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function getComponents(definitions, events, presets) {
|
|
211
|
-
|
|
212
|
-
return {
|
|
213
|
-
messageTraits: getMessageTraits(),
|
|
214
|
-
messages: definitionsToMessages(definitions, events, presets),
|
|
215
|
-
schemas: csnToJSONSchema(definitions, events)
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function _serviceErrorHandling(csn, options) {
|
|
220
|
-
const services = cds.linked(csn).services;
|
|
221
|
-
|
|
222
|
-
if (services.length < 1) throw new Error(messages.NO_SERVICES);
|
|
223
|
-
|
|
224
|
-
if (!options.service && services.length > 1) throw new Error(`\n
|
|
225
|
-
Found multiple service definitions in given model(s).
|
|
226
|
-
Please choose by adding one of... \n
|
|
227
|
-
-s all ${services.map(s => `\n -s ${s.name}`).join('')}
|
|
228
|
-
`);
|
|
229
|
-
|
|
230
|
-
if (!options.service) {
|
|
231
|
-
options.service = services[0].name;
|
|
232
|
-
} else if (options.service !== 'all') {
|
|
233
|
-
const srv = services.find(s => s.name === options.service);
|
|
234
|
-
if (!srv) throw new Error(`Service definition with given ${options.service} not found in the model(s).`);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (options["asyncapi:merged"] && options.service !== 'all') {
|
|
238
|
-
throw new Error(messages.MERGED_FLAG);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function* _iterate(services, csn, applicationNamespace, presets) {
|
|
243
|
-
for (const [key, value] of Object.entries(services)) {
|
|
244
|
-
const generatedAsyncAPI = _getAsyncApi(csn, value.events, key, applicationNamespace, presets);
|
|
245
|
-
yield [generatedAsyncAPI, { file: key }];
|
|
246
|
-
}
|
|
247
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const errorMessages = {
|
|
4
|
-
APPLICATION_NAMESPACE: 'Preset for application namespace needs to be added.',
|
|
5
|
-
TITLE_VERSION_MERGED: 'Preset for Title and Version info needs to be added when merged flag is used.',
|
|
6
|
-
NO_EVENTS: 'No events found in the service.',
|
|
7
|
-
TITLE_VERSION_ANNOTATIONS: 'Title and Version info annotations needs to be added to the service(s).',
|
|
8
|
-
UNSUPPORTED_VERSION: 'The version value provided is unsupported.',
|
|
9
|
-
NO_SERVICES: 'There are no service definitions found in the given model(s).',
|
|
10
|
-
MERGED_FLAG: 'Merged flag cannot be used with single service definition.',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
module.exports = errorMessages;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns value of EventType Annotation if it is present. Otherwise it returns the definition name only.
|
|
3
|
-
*/
|
|
4
|
-
function getEventName(eventName, eventDefinition) {
|
|
5
|
-
|
|
6
|
-
if (eventDefinition["@AsyncAPI.EventType"]) {
|
|
7
|
-
eventName = eventDefinition["@AsyncAPI.EventType"];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return eventName;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Gets the property value from the entry if it is defined otherwise returns undefined.
|
|
15
|
-
*/
|
|
16
|
-
function getOwnValue(entry, key) {
|
|
17
|
-
if (Object.prototype.hasOwnProperty.call(entry, key)) {
|
|
18
|
-
return entry[key];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = {
|
|
25
|
-
getEventName,
|
|
26
|
-
getOwnValue
|
|
27
|
-
}
|