@sap/cds-dk 4.9.7 → 6.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.
Files changed (145) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/bin/activate.js +4 -4
  3. package/bin/add.js +11 -5
  4. package/bin/bind.js +16 -28
  5. package/bin/build/all.js +2 -2
  6. package/bin/build/index.js +12 -19
  7. package/bin/cds.js +22 -19
  8. package/bin/compile/index.js +12 -3
  9. package/bin/deploy/index.js +15 -9
  10. package/bin/deploy/to-hana.js +4 -4
  11. package/bin/deploy/to-sqlite.js +1 -1
  12. package/bin/env.js +13 -4
  13. package/bin/eval.js +1 -1
  14. package/bin/fix-redirects.js +1 -1
  15. package/bin/import.js +44 -179
  16. package/bin/repl.js +1 -1
  17. package/bin/watch.js +10 -15
  18. package/lib/bind/BindingManager.js +87 -0
  19. package/lib/bind/bindingResolver.js +15 -87
  20. package/lib/bind/bindingUtil.js +18 -11
  21. package/lib/bind/cfKeyProvider.js +58 -29
  22. package/lib/bind/kubernetesCredentialsProvider.js +44 -21
  23. package/lib/bind/userCdsrcJsonStorageProvider.js +12 -18
  24. package/lib/cds.js +13 -0
  25. package/lib/client/base_command.js +3 -2
  26. package/lib/client/extend.js +6 -7
  27. package/lib/client/helper/fs_helper.js +7 -8
  28. package/lib/client/settings_manager.js +14 -10
  29. package/lib/compile/index.js +9 -10
  30. package/lib/compile/openapi/csdl2openapi.js +151 -43
  31. package/lib/compile/openapi/index.js +2 -2
  32. package/lib/compile/to-xsuaa.js +3 -2
  33. package/lib/import/common.js +342 -27
  34. package/lib/import/importapi.js +81 -13
  35. package/lib/import/message.js +4 -4
  36. package/lib/import/odata/index.js +141 -0
  37. package/lib/import/{utils → odata/metadataconverter}/MetadataConverter.js +2 -2
  38. package/lib/import/{utils → odata/metadataconverter}/MetadataConverterFactory.js +1 -1
  39. package/lib/import/{utils → odata/util}/MultiMap.js +0 -0
  40. package/lib/import/{v2parser.js → odata/v2parser.js} +405 -468
  41. package/lib/import/{v4parser.js → odata/v4parser.js} +311 -322
  42. package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Aggregation.V1.json +0 -0
  43. package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Authorization.V1.json +0 -0
  44. package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Capabilities.V1.json +0 -0
  45. package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Core.V1.json +0 -0
  46. package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Measures.V1.json +0 -0
  47. package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Validation.V1.json +0 -0
  48. package/lib/import/openapi/importOpenAPI.js +521 -0
  49. package/lib/import/openapi/index.js +19 -0
  50. package/lib/import/openapi/utilities.js +38 -0
  51. package/lib/index.js +1 -1
  52. package/lib/init/constants.js +7 -2
  53. package/lib/init/index.js +10 -3
  54. package/lib/init/template/_merging/existences.js +79 -19
  55. package/lib/init/template/approuter/files/mta.yaml.hbs +25 -11
  56. package/lib/init/template/approuter/files/package.json +1 -1
  57. package/lib/init/template/approuter/files/xs-app.json.hbs +7 -0
  58. package/lib/init/template/approuter/index.js +61 -54
  59. package/lib/init/template/auditlog/index.js +2 -2
  60. package/lib/init/template/data/index.js +2 -2
  61. package/lib/init/template/hana/files/mta.yaml.hbs +17 -17
  62. package/lib/init/template/hana/index.js +8 -4
  63. package/lib/init/template/helm/index.js +39 -0
  64. package/lib/init/template/helm/update/index.js +28 -0
  65. package/lib/init/template/java/index.js +7 -9
  66. package/lib/init/template/kibana-logging/index.js +5 -6
  67. package/lib/init/template/lint/index.js +1 -1
  68. package/lib/init/template/mta/index.js +4 -4
  69. package/lib/init/template/mtx/files/java/package.json +9 -9
  70. package/lib/init/template/mtx/files/mta.yaml.hbs +0 -7
  71. package/lib/init/template/mtx/files/xs-security.json.hbs +11 -20
  72. package/lib/init/template/mtx/index.js +50 -57
  73. package/lib/init/template/nodejs/files/package.json.hbs +2 -2
  74. package/lib/init/template/notebook/index.js +2 -0
  75. package/lib/init/template/templateBase.js +8 -6
  76. package/lib/init/template/xsuaa/index.js +9 -5
  77. package/lib/init/util/fsUtil.js +25 -10
  78. package/lib/init/util/logger.js +1 -1
  79. package/lib/init/util/mvnArchetypeUtil.js +4 -10
  80. package/lib/init/util/projectReader.js +17 -9
  81. package/lib/init/util/templateUtil.js +30 -34
  82. package/lib/k8s/ChartAdder.js +65 -0
  83. package/lib/k8s/ChartBuilder.js +186 -0
  84. package/lib/k8s/Context.js +71 -0
  85. package/lib/k8s/ImageUtil.js +21 -0
  86. package/lib/k8s/Model.d.ts +53 -0
  87. package/lib/k8s/auditlog/index.js +29 -0
  88. package/lib/k8s/auditlog/templates/auditlog.yaml +1 -0
  89. package/lib/k8s/buildModel.js +70 -0
  90. package/lib/k8s/connectivity/index.js +80 -0
  91. package/lib/k8s/connectivity/templates/connectivity-binding.yaml +9 -0
  92. package/lib/k8s/connectivity/templates/connectivity-proxy-info.yaml +20 -0
  93. package/lib/k8s/connectivity/templates/connectivity.yaml +1 -0
  94. package/lib/k8s/deployment/index.js +81 -0
  95. package/lib/k8s/deployment/subchart/Chart.yaml +6 -0
  96. package/lib/k8s/deployment/subchart/templates/_helpers.tpl +156 -0
  97. package/lib/k8s/deployment/subchart/templates/api-rule.yaml +24 -0
  98. package/lib/k8s/deployment/subchart/templates/deployment.yaml +110 -0
  99. package/lib/k8s/deployment/subchart/templates/network-policy.yaml +16 -0
  100. package/lib/k8s/deployment/subchart/templates/pod-disruption-budget.yaml +11 -0
  101. package/lib/k8s/deployment/subchart/templates/secret.yaml +10 -0
  102. package/lib/k8s/deployment/subchart/templates/service-binding.yaml +27 -0
  103. package/lib/k8s/deployment/subchart/templates/service.yaml +11 -0
  104. package/lib/k8s/deployment/subchart/values-lint.yaml +8 -0
  105. package/lib/k8s/deployment/subchart/values.schema.json +449 -0
  106. package/lib/k8s/deployment/subchart/values.yaml +76 -0
  107. package/lib/k8s/deployment/subchart-override/templates/_web_application_helpers.tpl +81 -0
  108. package/lib/k8s/destinations/index.js +40 -0
  109. package/lib/k8s/destinations/lib.js +16 -0
  110. package/lib/k8s/destinations/templates/destinations.yaml +1 -0
  111. package/lib/k8s/docker/push.js +8 -0
  112. package/lib/k8s/event-mesh/index.js +53 -0
  113. package/lib/k8s/event-mesh/lib.js +9 -0
  114. package/lib/k8s/event-mesh/templates/event-mesh.yaml +1 -0
  115. package/lib/k8s/hana-deployer/index.js +38 -0
  116. package/lib/k8s/hana-deployer/templates/hana-deployer-job.yaml +41 -0
  117. package/lib/k8s/helm/Release.js +80 -0
  118. package/lib/k8s/html5-apps-deployer/index.js +43 -0
  119. package/lib/k8s/html5-apps-deployer/templates/_html5_deployment_helpers.tpl +16 -0
  120. package/lib/k8s/html5-apps-deployer/templates/html5-apps-deployer-job.yaml +53 -0
  121. package/lib/k8s/html5-apps-repo-host/index.js +26 -0
  122. package/lib/k8s/html5-apps-repo-host/lib.js +16 -0
  123. package/lib/k8s/html5-apps-repo-host/templates/html5-apps-repo-host.yaml +1 -0
  124. package/lib/k8s/index.js +153 -0
  125. package/lib/k8s/modules.js +36 -0
  126. package/lib/k8s/multitenancy/index.js +24 -0
  127. package/lib/k8s/multitenancy/lib.js +25 -0
  128. package/lib/k8s/multitenancy/templates/saas-registry.yaml +19 -0
  129. package/lib/k8s/readProject.js +14 -0
  130. package/lib/k8s/resources/helm/chart/templates/NOTES.txt +11 -0
  131. package/lib/k8s/resources/helm/chart/templates/_deployment_helpers.tpl +221 -0
  132. package/lib/k8s/resources/helm/chart/templates/_helpers.tpl +167 -0
  133. package/lib/k8s/resources/helm/chart/templates/_sapcp_helpers.tpl +103 -0
  134. package/lib/k8s/util.js +186 -0
  135. package/lib/k8s/wrapFeature.js +55 -0
  136. package/lib/k8s/xsuaa/index.js +64 -0
  137. package/lib/k8s/xsuaa/lib.js +17 -0
  138. package/lib/k8s/xsuaa/templates/xsuaa.yaml +1 -0
  139. package/lib/lint/generators.js +1 -1
  140. package/lib/util/exec.js +1 -1
  141. package/lib/util/write.js +1 -1
  142. package/lib/watch/node-watch.js +43 -14
  143. package/npm-shrinkwrap.json +923 -2705
  144. package/package.json +5 -5
  145. package/lib/import/index.js +0 -235
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+
3
+ let edmxv2CSN = require("./v2parser");
4
+ let edmxv4CSN = require("./v4parser");
5
+ const messages = require("../message").getMessages();
6
+ let common = require("../common");
7
+ const { path } = require('../../cds').utils;
8
+
9
+ function getNamespaces(context) {
10
+ if (context.include_namespaces === "*") context.include_all_namespaces = true;
11
+ else if (typeof context.include_namespaces === 'string' && !context.include_namespaces.startsWith('-')) context.namespaces = context.include_namespaces.replace(/ /g, "").split(',');
12
+ else throw new Error(messages.INCORRECT_INPUT_NAMESPACES);
13
+ }
14
+
15
+ function _convertEDMXWithMultipleSchemas(edmx, multipleSchemas, namespace) {
16
+ /*
17
+ This is a quick hack only handling the following case we saw from SFSF:
18
+
19
+ <edmx:DataServices>
20
+ <Schema Namespace="SFODataSet">
21
+ <EntityContainer>
22
+ <EntitySet Name="Foos" EntityType="SFOData.Foo"> ... </EntitySet>
23
+ </EntityContainer>
24
+ </Schema>
25
+ <Schema Namespace="SFOData">
26
+ <EntityType Name="Foo"> ... </EntityType>
27
+ </Schema>
28
+ </edmx:DataServices>
29
+
30
+ which is turned into that:
31
+
32
+ <edmx:DataServices>
33
+ <Schema Namespace="SFOData">
34
+ <EntityContainer>
35
+ <EntitySet Name="Foos" EntityType="SFOData.Foo"> ... </EntitySet>
36
+ </EntityContainer>
37
+ <EntityType Name="Foo"> ... </EntityType>
38
+ </Schema>
39
+ </edmx:DataServices>
40
+ */
41
+
42
+ // Remove the ending and beginning of the first and second schema tag
43
+ edmx = edmx.replace(multipleSchemas, '');
44
+ // Now capture the schema tag details
45
+ let schemaDetails = edmx.match(/(<Schema [^>]*>)/);
46
+ // Replace the Namespace value with the correct one
47
+ schemaDetails = schemaDetails[0].replace(/Namespace="[^"]+"/, `Namespace="${namespace}"`);
48
+ // Place the above computed schema details in the edmx content
49
+ edmx = edmx.replace(/(<Schema [^>]*>)/, `${schemaDetails}`);
50
+
51
+ return edmx;
52
+ }
53
+
54
+ async function edmx2csn(edmx, filename, context) {
55
+ let namespace;
56
+ const result = edmx.match(/EntityType="([^"]+)/);
57
+ const multipleSchemas = /(\s*<\/Schema>\s*<Schema [^>]*>)\s*/m;
58
+ if (result) {
59
+ const index = result[1].lastIndexOf(".");
60
+ namespace = (index > 0) ? result[1].substring(0, index) : result[1];
61
+ }
62
+ else {
63
+ // to support edmx without entities - unbounded actions and functions only
64
+ console.warn('There are no entities in the OData model');
65
+ let schema = edmx.match(/(<Schema [^>]*>)/);
66
+ if (!schema) throw new Error(messages.INVALID_EDMX_METADATA);
67
+ schema = schema[0].match(/Namespace="[^"]+"/);
68
+ namespace = schema[0].slice(schema[0].lastIndexOf('Namespace') + 11, schema[0].lastIndexOf('"'));
69
+ }
70
+ if (multipleSchemas.test(edmx)) {
71
+ edmx = _convertEDMXWithMultipleSchemas(edmx, multipleSchemas, namespace);
72
+ }
73
+ let csn = await _generateCSN(edmx, false, true, context);
74
+ const regex = /^[\p{Letter}\p{Nl}_]{1}[_\p{Letter}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}]{0,127}$/gu
75
+ // Regex checks for this condition “A-B” must start with a letter or underscore, followed by at most 127 letters, underscores or digits in the fileName
76
+ if (filename) {
77
+ // Replace namespace by given filename in the csn file instead of edmx file
78
+ const re = RegExp(`([("/])${namespace}([/").])`, 'g');
79
+ let name = path.parse(filename).name;
80
+ if (!(name.match(regex))) { // check if the filename is in the right format with the regex if not replace unaccepted characters with underscore (_)
81
+ name = name.replace(/^[^a-z\p{Nl}_]/gui, '_');
82
+ name = name.replace(/[^a-z0-9_\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}]/gui, '_');
83
+ }
84
+ const fn = `$1${name}$2`;
85
+ csn = csn.replace(re, fn);
86
+ }
87
+ return JSON.parse(csn);
88
+ }
89
+
90
+ async function _generateCSN(edmx, ignorePersistenceSkip, mockServerUc, context) {
91
+ let csn;
92
+ let odataVersion;
93
+ let edmx2jsonModel;
94
+ let defaultNamespaces;
95
+ let namespaces = [];
96
+ if (context.namespaces) namespaces.push(...(context.namespaces));
97
+ odataVersion = await common.getVersion(edmx);
98
+ if (odataVersion === "V2") {
99
+ if (context) {
100
+ context.inputFileVersion = "V2";
101
+ }
102
+ // default namespaces to be present
103
+ if (!context.include_all_namespaces) {
104
+ defaultNamespaces = ['edmx', 'sap', 'm'];
105
+ namespaces = namespaces.concat(defaultNamespaces);
106
+ namespaces = namespaces.filter((item, pos) => namespaces.indexOf(item) === pos); //removing duplicate values
107
+ }
108
+ context.namespaces = namespaces;
109
+ edmx2jsonModel = await common.generateEDMX2JSON(edmx);
110
+ return new Promise(function getCsn(resolve, reject) {
111
+ csn = edmxv2CSN.getEdmxv2CSN(edmx2jsonModel, ignorePersistenceSkip, mockServerUc, context);
112
+ if (csn) resolve(csn);
113
+ else reject("Error Occurred");
114
+ });
115
+ }
116
+ else if (odataVersion === 'V4') {
117
+ if (context) {
118
+ context.inputFileVersion = "V4";
119
+ }
120
+ // default namespaces to be present
121
+ if (!context.include_all_namespaces) {
122
+ defaultNamespaces = ['edmx'];
123
+ namespaces = namespaces.concat(defaultNamespaces);
124
+ namespaces = namespaces.filter((item, pos) => namespaces.indexOf(item) === pos); //removing duplicate values
125
+ }
126
+ context.namespaces = namespaces;
127
+ return new Promise(function(resolve, reject) {
128
+ csn = edmxv4CSN.getEdmxv4CSN(edmx, ignorePersistenceSkip, mockServerUc, context);
129
+ if (csn) resolve(csn);
130
+ else reject("Error Occurred");
131
+ });
132
+ }
133
+ return new Promise(function invalidFile(resolve, reject) {
134
+ reject(new Error(messages.INVALID_EDMX_METADATA));
135
+ });
136
+ }
137
+
138
+ module.exports = {
139
+ getNamespaces,
140
+ edmx2csn
141
+ };
@@ -466,8 +466,8 @@ class Expression {
466
466
  */
467
467
  if (args.includes('$Scale') && (target.$Type === 'Edm.Decimal' || target.$UnderlyingType === 'Edm.Decimal')) {
468
468
  if (attribs.Scale != null) {
469
- if (attribs.Scale === 'variable') {
470
- target.$Scale = 'variable';
469
+ if (attribs.Scale === 'variable' || attribs.Scale === 'floating' ) {
470
+ target.$Scale = attribs.Scale;
471
471
  } else if (attribs.Scale !== '0') {
472
472
  target.$Scale = parseInt(attribs.Scale, 10);
473
473
  }
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  const xmljs = require('xml-js');
3
- const MetadataConverterV4 = require('../utils/MetadataConverter');
3
+ const MetadataConverterV4 = require('./MetadataConverter');
4
4
 
5
5
  /**
6
6
  * Factory to create the various converters
File without changes