@sap/cds-dk 7.9.4 → 8.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2116 -0
- package/bin/add.js +18 -52
- package/bin/bind.js +2 -2
- package/bin/build.js +29 -4
- package/bin/cds.js +23 -11
- 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 +2 -11
- 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 +3 -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 +20 -25
- package/lib/build/provider/hana/template/.hdiconfig-all +3 -0
- package/lib/build/provider/hana/template/.hdiconfig-cloud +3 -0
- package/lib/build/provider/hana/template/package.json +4 -3
- package/lib/build/provider/internalBuildPlugin.js +32 -97
- package/lib/build/provider/internalBuildTaskProvider.js +10 -46
- 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/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 +16 -10
- package/lib/init/index.js +74 -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 -19
- 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/audit-logging/files/mta.yaml.hbs +14 -0
- 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 +25 -1
- package/lib/init/template/destination/index.js +12 -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/src/.hdiconfig +3 -0
- 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 +41 -8
- 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 +21 -8
- package/lib/init/template/html5-repo/index.js +33 -30
- 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-messaging/index.js +4 -0
- 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 +5 -0
- package/lib/init/template/workzone-standard/files/manifest.json.hbs +6 -0
- package/lib/init/template/workzone-standard/index.js +30 -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 +231 -1089
- 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
|
@@ -77,6 +77,7 @@ function _initialize(parserContext) {
|
|
|
77
77
|
parserContext.allInheritedEntityTypes = [];
|
|
78
78
|
parserContext.allowedNamespaces = [];
|
|
79
79
|
parserContext.allowAllNamespaces = false;
|
|
80
|
+
parserContext.mockServerUc = true;
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
// Function to extract allowed namespace attributes from given set of attributes
|
|
@@ -138,12 +139,16 @@ function _isValidEDMX(jsonObj) {
|
|
|
138
139
|
return isValid;
|
|
139
140
|
}
|
|
140
141
|
|
|
141
|
-
function
|
|
142
|
-
let
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
function _settingMockServerUc(jsonObj, parserContext) {
|
|
143
|
+
let EntityContainerObj = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityContainer;
|
|
144
|
+
// Setting mockerserverUc to false when there is no EntityContainer or when the EntityContainer exists but has no elements inside it
|
|
145
|
+
if (!EntityContainerObj || (EntityContainerObj && !EntityContainerObj.EntitySet && !EntityContainerObj.FunctionImport && !EntityContainerObj.AssociationSet)) {
|
|
146
|
+
parserContext.mockServerUc = false;
|
|
147
|
+
}
|
|
148
|
+
// Importer throws an error if AssociationSet is present without corresponding entitySets
|
|
149
|
+
else if ((EntityContainerObj && !EntityContainerObj.EntitySet && EntityContainerObj.AssociationSet)) {
|
|
150
|
+
throw new Error(messages.MISSING_ENTITY_SETS);
|
|
145
151
|
}
|
|
146
|
-
return isEntityContainerPresent;
|
|
147
152
|
}
|
|
148
153
|
|
|
149
154
|
function _isValidEDMXProvided(jsonObj) {
|
|
@@ -156,13 +161,6 @@ function _isValidEDMXProvided(jsonObj) {
|
|
|
156
161
|
return isValid;
|
|
157
162
|
}
|
|
158
163
|
|
|
159
|
-
function _validateEDMX(jsonObj) {
|
|
160
|
-
return (
|
|
161
|
-
_isValidEDMXProvided(jsonObj) &&
|
|
162
|
-
_hasEntityContainer(jsonObj)
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
164
|
function _getServiceNameSpace(jsonObj) {
|
|
167
165
|
let schemaArr = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema;
|
|
168
166
|
let schema = schemaArr;
|
|
@@ -183,12 +181,21 @@ function _getServiceNameSpace(jsonObj) {
|
|
|
183
181
|
return null;
|
|
184
182
|
}
|
|
185
183
|
|
|
184
|
+
function _checkAssociation(associationSet, parserContext) {
|
|
185
|
+
Object.keys(associationSet).forEach((i) => {
|
|
186
|
+
if (!parserContext.allEntitiesMC.includes(associationSet[i]._attributes.EntitySet)) {
|
|
187
|
+
throw new Error(messages.UNRESOLVED_TYPE + `'${associationSet[i]._attributes.EntitySet}'`);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
186
192
|
function _extractAssociationSet(associationSet, parserContext) {
|
|
187
193
|
let associations = {};
|
|
188
194
|
Object.keys(associationSet).forEach((key) => {
|
|
189
195
|
if (key === "_attributes") {
|
|
190
196
|
associations.Name = associationSet[key].Name;
|
|
191
197
|
associations.End = associationSet.End;
|
|
198
|
+
_checkAssociation(associations.End, parserContext);
|
|
192
199
|
parserContext.allAssociationSets[associationSet[key].Association] = associations;
|
|
193
200
|
}
|
|
194
201
|
});
|
|
@@ -319,8 +326,23 @@ function _extractFunctionImport(functionImport, parserContext) {
|
|
|
319
326
|
});
|
|
320
327
|
}
|
|
321
328
|
|
|
329
|
+
function _checkFunctionImports(functionImports, parserContext) {
|
|
330
|
+
if(functionImports.length) {
|
|
331
|
+
functionImports.forEach((functionImport) => {
|
|
332
|
+
if (functionImport._attributes.EntitySet && !parserContext.allEntitiesMC.includes(functionImport._attributes.EntitySet)) {
|
|
333
|
+
throw new Error(messages.UNRESOLVED_TYPE + `'${functionImport._attributes.EntitySet}'`);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
} else {
|
|
337
|
+
if (functionImports._attributes.EntitySet && !parserContext.allEntitiesMC.includes(functionImports._attributes.EntitySet)) {
|
|
338
|
+
throw new Error(messages.UNRESOLVED_TYPE + `'${functionImports._attributes.EntitySet}'`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
322
343
|
//extracting the function imports from the metadata
|
|
323
344
|
function _extractAllFunctionImports(functionImports, parserContext) {
|
|
345
|
+
_checkFunctionImports(functionImports, parserContext)
|
|
324
346
|
if (functionImports.length) {
|
|
325
347
|
//Has many function imports in metadata
|
|
326
348
|
for (let i = 0; i < functionImports.length; i++) {
|
|
@@ -1077,19 +1099,19 @@ function _generateCSNEntityProperties(entityKeysList, entityPropertiesMap, parse
|
|
|
1077
1099
|
return csnEntity;
|
|
1078
1100
|
}
|
|
1079
1101
|
|
|
1080
|
-
function _getAssociatedEntity(associationEnds, toRole, isAssociationSetMissing,
|
|
1102
|
+
function _getAssociatedEntity(associationEnds, toRole, isAssociationSetMissing, parserContext) {
|
|
1081
1103
|
let entityName;
|
|
1082
1104
|
let entitySetName;
|
|
1083
1105
|
let entityTypeName;
|
|
1084
1106
|
Object.keys(associationEnds).forEach((i) => {
|
|
1085
1107
|
if (toRole === associationEnds[i]._attributes.Role) {
|
|
1086
|
-
if (isAssociationSetMissing) {
|
|
1108
|
+
if (isAssociationSetMissing && parserContext.mockServerUc) {
|
|
1087
1109
|
entityTypeName = associationEnds[i]._attributes.Type;
|
|
1088
1110
|
entitySetName = parserContext.allEntitySetMapMC[entityTypeName][0];
|
|
1089
|
-
} else
|
|
1111
|
+
} else {
|
|
1090
1112
|
entitySetName = associationEnds[i]._attributes.EntitySet;
|
|
1091
1113
|
}
|
|
1092
|
-
if (mockServerUc) {
|
|
1114
|
+
if (parserContext.mockServerUc) {
|
|
1093
1115
|
entityName = parserContext.serviceNamespace + "." + entitySetName;
|
|
1094
1116
|
} else {
|
|
1095
1117
|
entityName = parserContext.allEntitySetMap[entitySetName];
|
|
@@ -1099,7 +1121,7 @@ function _getAssociatedEntity(associationEnds, toRole, isAssociationSetMissing,
|
|
|
1099
1121
|
return entityName;
|
|
1100
1122
|
}
|
|
1101
1123
|
|
|
1102
|
-
function _getCSNMultiplicity(associationEnds, toRole, entityName,
|
|
1124
|
+
function _getCSNMultiplicity(associationEnds, toRole, entityName, parserContext) {
|
|
1103
1125
|
let csn = "";
|
|
1104
1126
|
let multiplicity;
|
|
1105
1127
|
let attributes;
|
|
@@ -1107,7 +1129,7 @@ function _getCSNMultiplicity(associationEnds, toRole, entityName, mockServerUc,
|
|
|
1107
1129
|
Object.keys(associationEnds).forEach((i) => {
|
|
1108
1130
|
if (!stop) {
|
|
1109
1131
|
attributes = associationEnds[i]._attributes;
|
|
1110
|
-
if (mockServerUc) {
|
|
1132
|
+
if (parserContext.mockServerUc) {
|
|
1111
1133
|
let entityNameWithOutNS = parserContext.allEntitySetMap[_extractEntityFromNamespace(entityName)];
|
|
1112
1134
|
if (
|
|
1113
1135
|
toRole === attributes.Role &&
|
|
@@ -1121,7 +1143,7 @@ function _getCSNMultiplicity(associationEnds, toRole, entityName, mockServerUc,
|
|
|
1121
1143
|
toRole === attributes.Role &&
|
|
1122
1144
|
entityName === attributes.Type
|
|
1123
1145
|
) {
|
|
1124
|
-
|
|
1146
|
+
|
|
1125
1147
|
multiplicity = attributes.Multiplicity;
|
|
1126
1148
|
stop = true;
|
|
1127
1149
|
}
|
|
@@ -1140,137 +1162,15 @@ function _getCSNMultiplicity(associationEnds, toRole, entityName, mockServerUc,
|
|
|
1140
1162
|
return csn;
|
|
1141
1163
|
}
|
|
1142
1164
|
|
|
1143
|
-
function _getCSNRefrenentialCondition(navPropName, from, to) {
|
|
1144
|
-
let csn = "{\n";
|
|
1145
|
-
csn = csn + '"ref": [\n';
|
|
1146
|
-
csn = csn + '"' + navPropName + '",\n';
|
|
1147
|
-
csn = csn + '"' + from + '"\n';
|
|
1148
|
-
csn = csn + "]\n";
|
|
1149
|
-
csn = csn + "},\n";
|
|
1150
|
-
|
|
1151
|
-
csn = csn + '"=",\n';
|
|
1152
|
-
|
|
1153
|
-
csn = csn + "{\n";
|
|
1154
|
-
csn = csn + '"ref": [\n';
|
|
1155
|
-
csn = csn + '"' + to + '"';
|
|
1156
|
-
csn = csn + "]\n";
|
|
1157
|
-
csn = csn + "}\n";
|
|
1158
|
-
return csn;
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
function _getCSNMultipleRefrenentialConditions(refConstraints, navPropName, role) {
|
|
1162
|
-
let csn = "";
|
|
1163
|
-
csn = csn + '"on": [\n';
|
|
1164
|
-
Object.keys(refConstraints).forEach((i) => {
|
|
1165
|
-
let roleName = refConstraints[i].Principal._attributes.Role;
|
|
1166
|
-
let principalProperties = refConstraints[i].Principal.PropertyRef;
|
|
1167
|
-
let dependentProperties = refConstraints[i].Dependent.PropertyRef;
|
|
1168
|
-
let from = "";
|
|
1169
|
-
let to = "";
|
|
1170
|
-
if (roleName && roleName === role) {
|
|
1171
|
-
from = principalProperties._attributes.Name;
|
|
1172
|
-
to = dependentProperties._attributes.Name;
|
|
1173
|
-
} else {
|
|
1174
|
-
from = dependentProperties._attributes.Name;
|
|
1175
|
-
to = principalProperties._attributes.Name;
|
|
1176
|
-
}
|
|
1177
|
-
csn = csn + _getCSNRefrenentialCondition(navPropName, from, to);
|
|
1178
|
-
if (i < refConstraints.length - 1) {
|
|
1179
|
-
csn = csn + ",\n";
|
|
1180
|
-
csn = csn + '"and",\n';
|
|
1181
|
-
}
|
|
1182
|
-
});
|
|
1183
|
-
csn = csn + "]\n";
|
|
1184
|
-
return csn;
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
function _getCSNRefrenentialConditions(refConstraints, navPropName, role) {
|
|
1188
|
-
let csn = "";
|
|
1189
|
-
let from;
|
|
1190
|
-
let to;
|
|
1191
|
-
let roleName = refConstraints.Principal._attributes.Role;
|
|
1192
|
-
let principalProperties = refConstraints.Principal.PropertyRef;
|
|
1193
|
-
let dependentProperties = refConstraints.Dependent.PropertyRef;
|
|
1194
|
-
if (dependentProperties.length > 0) {
|
|
1195
|
-
// Multiple principal and dependents within Referential Constraint
|
|
1196
|
-
csn = csn + '"on": [\n';
|
|
1197
|
-
Object.keys(dependentProperties).forEach((i) => {
|
|
1198
|
-
if (roleName && roleName === role) {
|
|
1199
|
-
from = principalProperties[i]._attributes.Name;
|
|
1200
|
-
to = dependentProperties[i]._attributes.Name;
|
|
1201
|
-
} else {
|
|
1202
|
-
from = dependentProperties[i]._attributes.Name;
|
|
1203
|
-
to = principalProperties[i]._attributes.Name;
|
|
1204
|
-
}
|
|
1205
|
-
csn = csn + _getCSNRefrenentialCondition(navPropName, from, to);
|
|
1206
|
-
if (i < dependentProperties.length - 1) {
|
|
1207
|
-
csn = csn + ",\n";
|
|
1208
|
-
csn = csn + '"and",\n';
|
|
1209
|
-
}
|
|
1210
|
-
});
|
|
1211
|
-
csn = csn + "]\n";
|
|
1212
|
-
} else {
|
|
1213
|
-
// Single principal and dependents within Referential Constraint
|
|
1214
|
-
csn = csn + '"on": [\n';
|
|
1215
|
-
if (roleName && roleName === role) {
|
|
1216
|
-
from = principalProperties._attributes.Name;
|
|
1217
|
-
to = dependentProperties._attributes.Name;
|
|
1218
|
-
} else {
|
|
1219
|
-
from = dependentProperties._attributes.Name;
|
|
1220
|
-
to = principalProperties._attributes.Name;
|
|
1221
|
-
}
|
|
1222
|
-
csn = csn + _getCSNRefrenentialCondition(navPropName, from, to);
|
|
1223
|
-
csn = csn + "]\n";
|
|
1224
|
-
}
|
|
1225
|
-
return csn;
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
function _getCSNRefrenentialConstraints(associations, navPropName, toRole) {
|
|
1229
|
-
let csn = "";
|
|
1230
|
-
let endProperties;
|
|
1231
|
-
let matchingRole = "";
|
|
1232
|
-
let refConstraints = associations.ReferentialConstraint;
|
|
1233
|
-
if (!refConstraints) {
|
|
1234
|
-
return csn;
|
|
1235
|
-
}
|
|
1236
|
-
endProperties = associations.End;
|
|
1237
|
-
Object.keys(endProperties).forEach((i) => {
|
|
1238
|
-
let role = endProperties[i]._attributes.Role;
|
|
1239
|
-
if (role && role === toRole) {
|
|
1240
|
-
matchingRole = endProperties[i]._attributes.Role;
|
|
1241
|
-
}
|
|
1242
|
-
});
|
|
1243
|
-
if (refConstraints.length > 0) {
|
|
1244
|
-
// Multiple referential constraints within Association
|
|
1245
|
-
csn = csn +
|
|
1246
|
-
_getCSNMultipleRefrenentialConditions(
|
|
1247
|
-
refConstraints,
|
|
1248
|
-
navPropName,
|
|
1249
|
-
matchingRole
|
|
1250
|
-
);
|
|
1251
|
-
} else {
|
|
1252
|
-
// Single referential constraint within Association
|
|
1253
|
-
csn = csn +
|
|
1254
|
-
_getCSNRefrenentialConditions(
|
|
1255
|
-
refConstraints,
|
|
1256
|
-
navPropName,
|
|
1257
|
-
matchingRole
|
|
1258
|
-
);
|
|
1259
|
-
}
|
|
1260
|
-
return csn;
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
1165
|
function _getCSNAssociatedRefrenentialConstraints(
|
|
1264
1166
|
associations,
|
|
1265
1167
|
toRole,
|
|
1266
1168
|
entityName,
|
|
1267
1169
|
navPropName,
|
|
1268
|
-
mockServerUc,
|
|
1269
1170
|
parserContext
|
|
1270
1171
|
) {
|
|
1271
1172
|
let csn = "";
|
|
1272
1173
|
let multiplicity;
|
|
1273
|
-
let referentialConstraint;
|
|
1274
1174
|
csn = csn + '"target": "' + entityName + '"';
|
|
1275
1175
|
if (!associations) {
|
|
1276
1176
|
return csn;
|
|
@@ -1279,21 +1179,12 @@ function _getCSNAssociatedRefrenentialConstraints(
|
|
|
1279
1179
|
associations.End,
|
|
1280
1180
|
toRole,
|
|
1281
1181
|
entityName,
|
|
1282
|
-
mockServerUc,
|
|
1283
1182
|
parserContext
|
|
1284
1183
|
);
|
|
1285
1184
|
if (multiplicity) {
|
|
1286
1185
|
csn = csn + ",\n" + multiplicity;
|
|
1287
1186
|
}
|
|
1288
|
-
|
|
1289
|
-
associations,
|
|
1290
|
-
navPropName,
|
|
1291
|
-
toRole,
|
|
1292
|
-
mockServerUc
|
|
1293
|
-
);
|
|
1294
|
-
if (referentialConstraint) {
|
|
1295
|
-
csn = csn + ",\n" + referentialConstraint;
|
|
1296
|
-
}
|
|
1187
|
+
|
|
1297
1188
|
return csn;
|
|
1298
1189
|
}
|
|
1299
1190
|
|
|
@@ -1301,7 +1192,6 @@ function _getCSNAssociatedEntitySet(
|
|
|
1301
1192
|
relationshipName,
|
|
1302
1193
|
toRole,
|
|
1303
1194
|
navPropName,
|
|
1304
|
-
mockServerUc,
|
|
1305
1195
|
parserContext
|
|
1306
1196
|
) {
|
|
1307
1197
|
let associationSet = parserContext.allAssociationSets[relationshipName];
|
|
@@ -1313,13 +1203,11 @@ function _getCSNAssociatedEntitySet(
|
|
|
1313
1203
|
if (associationSet === undefined) {
|
|
1314
1204
|
isAssociationSetMissing = true;
|
|
1315
1205
|
}
|
|
1316
|
-
|
|
1317
1206
|
let associationEnd = associationSet ? associationSet.End : association.End;
|
|
1318
1207
|
let entityName = _getAssociatedEntity(
|
|
1319
1208
|
associationEnd,
|
|
1320
1209
|
toRole,
|
|
1321
1210
|
isAssociationSetMissing,
|
|
1322
|
-
mockServerUc,
|
|
1323
1211
|
parserContext
|
|
1324
1212
|
);
|
|
1325
1213
|
let differentAssociationNames;
|
|
@@ -1341,7 +1229,6 @@ function _getCSNAssociatedEntitySet(
|
|
|
1341
1229
|
toRole,
|
|
1342
1230
|
entityName,
|
|
1343
1231
|
navPropName,
|
|
1344
|
-
mockServerUc,
|
|
1345
1232
|
parserContext
|
|
1346
1233
|
);
|
|
1347
1234
|
}
|
|
@@ -1371,7 +1258,7 @@ function _findAssociationType(relationshipName, fromRole, parserContext) {
|
|
|
1371
1258
|
return '"type": "cds.' + (associationType === "composition" ? 'Composition"' : 'Association"') + ',\n';
|
|
1372
1259
|
}
|
|
1373
1260
|
|
|
1374
|
-
function _getServiceEntityNavigationProperty(navPropAttributes,
|
|
1261
|
+
function _getServiceEntityNavigationProperty(navPropAttributes, parserContext) {
|
|
1375
1262
|
let csn = "";
|
|
1376
1263
|
let navPropName;
|
|
1377
1264
|
let relationshipName;
|
|
@@ -1392,12 +1279,6 @@ function _getServiceEntityNavigationProperty(navPropAttributes, mockServerUc, pa
|
|
|
1392
1279
|
if (allowedNamespaceAttributes.length) {
|
|
1393
1280
|
csn += _generateNamespaceAttributes(allowedNamespaceAttributes, false);
|
|
1394
1281
|
}
|
|
1395
|
-
// annotation for on conditions
|
|
1396
|
-
csn = csn + `"@cds.ambiguous": "missing on condition?",\n`;
|
|
1397
|
-
|
|
1398
|
-
//Code for notNull working but change is not reflecting when we use: cds compile {file-path} -2 edmx > {newFileName}
|
|
1399
|
-
/*if (navPropAttributes.Nullable === "false")
|
|
1400
|
-
csn = csn + '"notNull": true,\n';*/
|
|
1401
1282
|
|
|
1402
1283
|
// if documentation exists for navigation property
|
|
1403
1284
|
if (navPropDoc)
|
|
@@ -1409,7 +1290,6 @@ function _getServiceEntityNavigationProperty(navPropAttributes, mockServerUc, pa
|
|
|
1409
1290
|
relationshipName,
|
|
1410
1291
|
toRole,
|
|
1411
1292
|
navPropName,
|
|
1412
|
-
mockServerUc,
|
|
1413
1293
|
parserContext
|
|
1414
1294
|
);
|
|
1415
1295
|
// Convert managed associations and compositions in unmanaged with empty key to avoid
|
|
@@ -1425,7 +1305,6 @@ function _getServiceEntityNavigationProperty(navPropAttributes, mockServerUc, pa
|
|
|
1425
1305
|
function _generateCSNEntityNavigationProperties(
|
|
1426
1306
|
entityNavigationPropertiesMap,
|
|
1427
1307
|
hasProperties,
|
|
1428
|
-
mockServerUc,
|
|
1429
1308
|
parserContext
|
|
1430
1309
|
) {
|
|
1431
1310
|
let csn = "";
|
|
@@ -1447,7 +1326,6 @@ function _generateCSNEntityNavigationProperties(
|
|
|
1447
1326
|
csn = csn +
|
|
1448
1327
|
_getServiceEntityNavigationProperty(
|
|
1449
1328
|
navPropAttributes,
|
|
1450
|
-
mockServerUc,
|
|
1451
1329
|
parserContext
|
|
1452
1330
|
);
|
|
1453
1331
|
if (i < entityNavProperties.length - 1) {
|
|
@@ -1474,7 +1352,6 @@ function _constructServiceEntity(
|
|
|
1474
1352
|
entityNavigationPropertiesMap,
|
|
1475
1353
|
entityAttributes,
|
|
1476
1354
|
ignorePersistenceSkip,
|
|
1477
|
-
mockServerUc,
|
|
1478
1355
|
documentation,
|
|
1479
1356
|
parserContext
|
|
1480
1357
|
) {
|
|
@@ -1547,7 +1424,6 @@ function _constructServiceEntity(
|
|
|
1547
1424
|
_generateCSNEntityNavigationProperties(
|
|
1548
1425
|
entityNavigationPropertiesMap,
|
|
1549
1426
|
hasProperties,
|
|
1550
|
-
mockServerUc,
|
|
1551
1427
|
parserContext
|
|
1552
1428
|
);
|
|
1553
1429
|
csnEntity = csnEntity + "}\n";
|
|
@@ -1591,7 +1467,7 @@ function _addBlobElement(properties) {
|
|
|
1591
1467
|
properties['blob'] = blobElement;
|
|
1592
1468
|
}
|
|
1593
1469
|
|
|
1594
|
-
function _parseServiceEntity(entityName, entity, ignorePersistenceSkip,
|
|
1470
|
+
function _parseServiceEntity(entityName, entity, ignorePersistenceSkip, parserContext) {
|
|
1595
1471
|
let entityAttributes;
|
|
1596
1472
|
let entityKeysList;
|
|
1597
1473
|
let entityPropertiesMap;
|
|
@@ -1642,18 +1518,17 @@ function _parseServiceEntity(entityName, entity, ignorePersistenceSkip, mockServ
|
|
|
1642
1518
|
entityNavigationPropertiesMap,
|
|
1643
1519
|
entityAttributes,
|
|
1644
1520
|
ignorePersistenceSkip,
|
|
1645
|
-
mockServerUc,
|
|
1646
1521
|
documentation,
|
|
1647
1522
|
parserContext
|
|
1648
1523
|
);
|
|
1649
1524
|
}
|
|
1650
1525
|
|
|
1651
|
-
function _getEntitesWithNamesFromEntitySets(entityJson,
|
|
1652
|
-
const getEntityName = mockServerUc
|
|
1526
|
+
function _getEntitesWithNamesFromEntitySets(entityJson, parserContext) {
|
|
1527
|
+
const getEntityName = parserContext.mockServerUc
|
|
1653
1528
|
? (entity) => parserContext.allEntitySetMapMC[parserContext.serviceNamespace + "." + _getEntityName(entity)]
|
|
1654
1529
|
: (entity) => [_getEntityName(entity)];
|
|
1655
1530
|
|
|
1656
|
-
const isNameInEntitySet = mockServerUc
|
|
1531
|
+
const isNameInEntitySet = parserContext.mockServerUc
|
|
1657
1532
|
? (name) => parserContext.allEntitiesMC.indexOf(name) >= 0
|
|
1658
1533
|
: (name) => parserContext.allEntities.indexOf(name) >= 0;
|
|
1659
1534
|
|
|
@@ -1693,31 +1568,30 @@ function _getEntitesWithNamesFromEntityTypes(entityJson, parserContext) {
|
|
|
1693
1568
|
return entities;
|
|
1694
1569
|
}
|
|
1695
1570
|
|
|
1696
|
-
function _parsingServiceEntities(entitiesWithNames, ignorePersistenceSkip,
|
|
1571
|
+
function _parsingServiceEntities(entitiesWithNames, ignorePersistenceSkip, parserContext) {
|
|
1697
1572
|
return entitiesWithNames.map((entityWithName) =>
|
|
1698
1573
|
entityWithName.name.map((entityName) =>
|
|
1699
1574
|
_parseServiceEntity(
|
|
1700
1575
|
entityName,
|
|
1701
1576
|
entityWithName.entity,
|
|
1702
1577
|
ignorePersistenceSkip,
|
|
1703
|
-
mockServerUc,
|
|
1704
1578
|
parserContext
|
|
1705
1579
|
)
|
|
1706
1580
|
).join("},") + "}"
|
|
1707
1581
|
);
|
|
1708
1582
|
}
|
|
1709
1583
|
|
|
1710
|
-
function _getServiceEntitites(entityJson = [], ignorePersistenceSkip,
|
|
1584
|
+
function _getServiceEntitites(entityJson = [], ignorePersistenceSkip, parserContext) {
|
|
1711
1585
|
const entities = Array.isArray(entityJson) ? entityJson : [entityJson];
|
|
1712
1586
|
let entitiesWithNames = []; // [0]-> entity set, [1]-> entity type
|
|
1713
1587
|
let parsedEntities = []; // [0]-> entity set, [1]-> entity type
|
|
1714
1588
|
|
|
1715
|
-
entitiesWithNames[0] = _getEntitesWithNamesFromEntitySets(entities,
|
|
1589
|
+
entitiesWithNames[0] = _getEntitesWithNamesFromEntitySets(entities, parserContext);
|
|
1716
1590
|
entitiesWithNames[1] = _getEntitesWithNamesFromEntityTypes(entities, parserContext);
|
|
1717
1591
|
|
|
1718
1592
|
for (let i = 0; i < 2; i++) {
|
|
1719
1593
|
if (entitiesWithNames[i].length) {
|
|
1720
|
-
parsedEntities[i] = _parsingServiceEntities(entitiesWithNames[i], ignorePersistenceSkip,
|
|
1594
|
+
parsedEntities[i] = _parsingServiceEntities(entitiesWithNames[i], ignorePersistenceSkip, parserContext);
|
|
1721
1595
|
}
|
|
1722
1596
|
}
|
|
1723
1597
|
|
|
@@ -1747,33 +1621,28 @@ function _getServiceEntitites(entityJson = [], ignorePersistenceSkip, mockServer
|
|
|
1747
1621
|
return "";
|
|
1748
1622
|
}
|
|
1749
1623
|
|
|
1750
|
-
function
|
|
1624
|
+
function _checkEntityType(entityJson, parserContext) {
|
|
1625
|
+
const entity = Object.values(entityJson).map(item => item._attributes.Name);
|
|
1626
|
+
|
|
1627
|
+
Object.keys(parserContext.allEntities).forEach((i) => {
|
|
1628
|
+
if (!entity.includes(parserContext.allEntities[i])) {
|
|
1629
|
+
throw new Error(messages.UNRESOLVED_TYPE + `'${parserContext.allEntities[i]}'`);
|
|
1630
|
+
}
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
function _generateEDMXJSON2CSN(jsonObj, ignorePersistenceSkip, parserContext) {
|
|
1751
1635
|
const csn = {};
|
|
1752
1636
|
csn.meta = {};
|
|
1753
1637
|
csn.meta.creator = 'cds-dk ' + versionInfo;
|
|
1754
1638
|
csn.$version = '2.0';
|
|
1755
1639
|
csn.definitions = {};
|
|
1756
1640
|
|
|
1757
|
-
// Extract association sets
|
|
1758
|
-
let associationSets = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityContainer.AssociationSet;
|
|
1759
|
-
if (associationSets) {
|
|
1760
|
-
_extractAllAssociationSets(associationSets, parserContext);
|
|
1761
|
-
}
|
|
1762
1641
|
// Extract associations
|
|
1763
1642
|
const associations = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.Association;
|
|
1764
1643
|
if (associations) {
|
|
1765
1644
|
_extractAllAssociations(associations, parserContext);
|
|
1766
1645
|
}
|
|
1767
|
-
// Extract entities from EntitySets
|
|
1768
|
-
const entitySets = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityContainer.EntitySet;
|
|
1769
|
-
if (entitySets) {
|
|
1770
|
-
_extractAllEntityFromEntitySets(entitySets, parserContext);
|
|
1771
|
-
}
|
|
1772
|
-
// Extract function imports
|
|
1773
|
-
const functionImports = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityContainer.FunctionImport;
|
|
1774
|
-
if (functionImports) {
|
|
1775
|
-
_extractAllFunctionImports(functionImports, parserContext);
|
|
1776
|
-
}
|
|
1777
1646
|
// Extract complex types
|
|
1778
1647
|
const complexTypes = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.ComplexType;
|
|
1779
1648
|
if (complexTypes) {
|
|
@@ -1784,7 +1653,7 @@ function _generateEDMXJSON2CSN(jsonObj, ignorePersistenceSkip, mockServerUc, par
|
|
|
1784
1653
|
const entityJson = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityType;
|
|
1785
1654
|
const definitions = [];
|
|
1786
1655
|
|
|
1787
|
-
if (mockServerUc) {
|
|
1656
|
+
if (parserContext.mockServerUc) {
|
|
1788
1657
|
let def = '"' + parserContext.serviceNamespace + '": {"kind": "service"' + ',\n' + '"@cds.external": true';
|
|
1789
1658
|
let serviceDoc = jsonObj["edmx:Edmx"]["edmx:DataServices"]["Schema"].EntityContainer.Documentation;
|
|
1790
1659
|
let namespaceAttributes = namespaceAttributeFilter(
|
|
@@ -1799,10 +1668,26 @@ function _generateEDMXJSON2CSN(jsonObj, ignorePersistenceSkip, mockServerUc, par
|
|
|
1799
1668
|
def += _generateNamespaceAttributes(namespaceAttributes, true);
|
|
1800
1669
|
def += "}";
|
|
1801
1670
|
definitions.push(def);
|
|
1671
|
+
// Extract entities from EntitySets
|
|
1672
|
+
const entitySets = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityContainer.EntitySet;
|
|
1673
|
+
if (entitySets) {
|
|
1674
|
+
_extractAllEntityFromEntitySets(entitySets, parserContext);
|
|
1675
|
+
_checkEntityType(entityJson, parserContext);
|
|
1676
|
+
}
|
|
1677
|
+
// Extract association sets
|
|
1678
|
+
let associationSets = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityContainer.AssociationSet;
|
|
1679
|
+
if (associationSets) {
|
|
1680
|
+
_extractAllAssociationSets(associationSets, parserContext);
|
|
1681
|
+
}
|
|
1682
|
+
// Extract function imports
|
|
1683
|
+
const functionImports = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityContainer.FunctionImport;
|
|
1684
|
+
if (functionImports) {
|
|
1685
|
+
_extractAllFunctionImports(functionImports, parserContext);
|
|
1686
|
+
}
|
|
1802
1687
|
}
|
|
1803
1688
|
|
|
1804
1689
|
if (entityJson) {
|
|
1805
|
-
definitions.push(_getServiceEntitites(entityJson, ignorePersistenceSkip,
|
|
1690
|
+
definitions.push(_getServiceEntitites(entityJson, ignorePersistenceSkip, parserContext));
|
|
1806
1691
|
}
|
|
1807
1692
|
|
|
1808
1693
|
// If complex type exists
|
|
@@ -1832,6 +1717,7 @@ function getEdmxv2CSN(edmx2jsonModel, ignorePersistenceSkip, mockServerUc, conte
|
|
|
1832
1717
|
|
|
1833
1718
|
const parserContext = {};
|
|
1834
1719
|
_initialize(parserContext);
|
|
1720
|
+
parserContext.mockServerUc = mockServerUc
|
|
1835
1721
|
|
|
1836
1722
|
if (!context.include_all_namespaces && context.namespaces.length) {
|
|
1837
1723
|
parserContext.allowedNamespaces = parserContext.allowedNamespaces.concat(context.namespaces)
|
|
@@ -1840,7 +1726,8 @@ function getEdmxv2CSN(edmx2jsonModel, ignorePersistenceSkip, mockServerUc, conte
|
|
|
1840
1726
|
parserContext.allowAllNamespaces = true;
|
|
1841
1727
|
}
|
|
1842
1728
|
|
|
1843
|
-
isValid =
|
|
1729
|
+
isValid = _isValidEDMXProvided(edmx2jsonModel);
|
|
1730
|
+
_settingMockServerUc(edmx2jsonModel, parserContext)
|
|
1844
1731
|
if (isValid) {
|
|
1845
1732
|
parserContext.serviceNamespace = _getServiceNameSpace(edmx2jsonModel);
|
|
1846
1733
|
context.schemaNamespace = parserContext.serviceNamespace; // required for `--keep-namespace` scenario
|
|
@@ -1853,7 +1740,6 @@ function getEdmxv2CSN(edmx2jsonModel, ignorePersistenceSkip, mockServerUc, conte
|
|
|
1853
1740
|
csnDataModel = _generateEDMXJSON2CSN(
|
|
1854
1741
|
edmx2jsonModel,
|
|
1855
1742
|
ignorePersistenceSkip,
|
|
1856
|
-
mockServerUc,
|
|
1857
1743
|
parserContext
|
|
1858
1744
|
);
|
|
1859
1745
|
}
|
|
@@ -636,21 +636,7 @@ function _generateStructuredDataTypeCsn(dataType, propertyObject, isPrimaryKey,
|
|
|
636
636
|
|
|
637
637
|
function _parseAssociationProperty(foreignReference, associationNode, parserContext) {
|
|
638
638
|
const associationProperty = {};
|
|
639
|
-
let foreignKeys;
|
|
640
|
-
// var foreignReference = associationNode.$Type;
|
|
641
|
-
let refConstraint = associationNode.$ReferentialConstraint;
|
|
642
|
-
let data;
|
|
643
|
-
let ref;
|
|
644
|
-
|
|
645
639
|
associationProperty.type = (associationNode.$OnDelete === 'Cascade') ? 'cds.Composition' : 'cds.Association';
|
|
646
|
-
// annotation for ON condition
|
|
647
|
-
associationProperty["@cds.ambiguous"] = 'missing on condition?';
|
|
648
|
-
// associationProperty.target = associationNode.$Type;
|
|
649
|
-
|
|
650
|
-
// Code for NavigationProperty for notNull
|
|
651
|
-
// if (!associationProperty.$Nullable) {
|
|
652
|
-
// associationProperty["notNull"] = true;
|
|
653
|
-
// }
|
|
654
640
|
|
|
655
641
|
let resolvedEntityName;
|
|
656
642
|
let entityTypeMapping = (
|
|
@@ -686,29 +672,6 @@ function _parseAssociationProperty(foreignReference, associationNode, parserCont
|
|
|
686
672
|
} else {
|
|
687
673
|
associationProperty.cardinality.max = 1;
|
|
688
674
|
}
|
|
689
|
-
// on -> "SalesOrders.CustomerID=CustomerID and SalesOrders.Type=Type"
|
|
690
|
-
if (refConstraint) {
|
|
691
|
-
associationProperty.on = [];
|
|
692
|
-
foreignKeys = Object.keys(refConstraint);
|
|
693
|
-
|
|
694
|
-
for (let i = 0; i < foreignKeys.length; i++) {
|
|
695
|
-
data = {};
|
|
696
|
-
ref = [];
|
|
697
|
-
ref.push(foreignReference);
|
|
698
|
-
ref.push(refConstraint[foreignKeys[i]]);
|
|
699
|
-
data.ref = ref;
|
|
700
|
-
associationProperty.on.push(data);
|
|
701
|
-
associationProperty.on.push('=');
|
|
702
|
-
data = {};
|
|
703
|
-
ref = [];
|
|
704
|
-
ref.push(foreignKeys[i]);
|
|
705
|
-
data.ref = ref;
|
|
706
|
-
associationProperty.on.push(data);
|
|
707
|
-
if (i < foreignKeys.length - 1) {
|
|
708
|
-
associationProperty.on.push(' and ');
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
675
|
// Convert managed associations and compositions in unmanaged with empty key to avoid
|
|
713
676
|
// "generation" of keys, that do not exist in the external service.
|
|
714
677
|
if (common.checkForEmptyKeys(associationProperty, "V4")) {
|
|
@@ -1723,7 +1686,7 @@ function _generateEDMX2JSON(edmx, name_space) {
|
|
|
1723
1686
|
const v4Conv = MetadataConverterFactory.createEdmxV40XmlToV40Json(name_space);
|
|
1724
1687
|
v4Conv.execute(inputBuffer, (error, json, missingReferencedDocuments) => {
|
|
1725
1688
|
if (missingReferencedDocuments?.length > 0) {
|
|
1726
|
-
console.log(missingReferencedDocuments);
|
|
1689
|
+
console.log(missingReferencedDocuments);
|
|
1727
1690
|
}
|
|
1728
1691
|
resolve(json);
|
|
1729
1692
|
});
|