@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds-dk",
3
- "version": "4.9.7",
3
+ "version": "6.0.3",
4
4
  "description": "Command line client and development toolkit for the SAP Cloud Application Programming Model",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [
@@ -16,14 +16,14 @@
16
16
  },
17
17
  "main": "lib/index.js",
18
18
  "dependencies": {
19
- "@sap/cds": "^5.9.2",
20
- "@sap/cds-foss": "^3",
19
+ "@sap/cds": "^6.0.3",
20
+ "@sap/cds-foss": "^4",
21
21
  "@sap/eslint-plugin-cds": "^2.3.3",
22
22
  "axios": ">=0.21",
23
23
  "connect-livereload": "^0.6.1",
24
24
  "eslint": "^8",
25
25
  "express": "^4.17.1",
26
- "htmlparser2": "^7.2.0",
26
+ "htmlparser2": "^8.0.0",
27
27
  "livereload-js": "^3.3.1",
28
28
  "md5": "^2.3.0",
29
29
  "mustache": "^4.0.1",
@@ -33,7 +33,7 @@
33
33
  "xml-js": "^1.6.11"
34
34
  },
35
35
  "optionalDependencies": {
36
- "sqlite3": "npm:@mendix/sqlite3@^5.0.2"
36
+ "sqlite3": "^5.0.4"
37
37
  },
38
38
  "files": [
39
39
  "bin/",
@@ -1,235 +0,0 @@
1
-
2
- "use strict";
3
- let convert = require('xml-js');
4
- let axios = require('axios');
5
- let edmxv2CSN = require("./v2parser");
6
- let edmxv4CSN = require("./v4parser");
7
- const messages = require("./message").getMessages();
8
- let common = require("./common");
9
- const cds = require('@sap/cds');
10
- const fs = cds.utils, { path } = fs;
11
- let defaultFileName;
12
-
13
- async function _isValidXML(text) {
14
- let isValid = false;
15
- let cjson;
16
- try {
17
- cjson = convert.xml2json(text, {
18
- compact: true,
19
- spaces: 4
20
- });
21
- JSON.parse(cjson);
22
- isValid = true;
23
- } catch (err) {
24
- isValid = false;
25
- }
26
- return isValid;
27
- }
28
-
29
- async function isValidInputFile(inputFileLoc) {
30
- let file;
31
- const fileResolved = await fs.isfile(inputFileLoc);
32
-
33
- if (!fileResolved) {
34
- throw new Error(messages.SPECIFY_INPUT_FILE);
35
- }
36
- else if (inputFileLoc.endsWith(".edmx") || inputFileLoc.endsWith(".xml")) {
37
- file = fileResolved;
38
- defaultFileName = file;
39
- } else {
40
- throw new Error(messages.INVALID_INPUT_FILE);
41
- }
42
- return file;
43
- }
44
-
45
- function validateAndComputeOutputFilePath(outputFileLoc, as) {
46
- let index, extension, expectedExtension, supportedExtension;
47
- if (typeof(outputFileLoc) !== 'boolean') {
48
- index = outputFileLoc.lastIndexOf(".");
49
- extension = outputFileLoc.substring(index + 1);
50
- expectedExtension = (as) ? common.getSuffix(as) : "csn";
51
- supportedExtension = (index > 0) ? common.supportedFormats().includes(extension) : false;
52
- }
53
-
54
- if (outputFileLoc === true || // if output file is not mentioned
55
- outputFileLoc[0] === "-" || // if output file is missing and "--as" is considered as output file
56
- outputFileLoc.trim() === "") {
57
- throw new Error(messages.SPECIFY_OUTPUT_FILE);
58
- } else if (index > 0 && !supportedExtension) {
59
- // extension not supported, eg., "test.abs", "./sv/external.test.abcs", "./a."
60
- throw new Error(messages.INVALID_OUTPUT_FILE);
61
- } else if (index > 0 && !as && extension != "json" && extension != "csn") {
62
- // --as option is not provided but output file is like: "test.cds", "./srv/external/test.cds"
63
- throw new Error(messages.INCORRECT_EXTENSION);
64
- } else if (index > 0 && as && extension != expectedExtension){
65
- // extension not supported by --as option, e.g., "cds import <file> --out test.yml --as cds"
66
- throw new Error(messages.OUTPUT_FILE_MISMATCH);
67
- } else if (supportedExtension || (!outputFileLoc.endsWith("\\") && !outputFileLoc.endsWith("/"))) {
68
- // eg., "./a.csn", "tst.cds", "./srv/external/test", "test", "c:\windows\output\test"
69
- return outputFileLoc;
70
- } else if (outputFileLoc.endsWith("/") || outputFileLoc.endsWith("\\")){
71
- // File name not specified ("./srv/external/", "c:\windows\output\test\")
72
- return outputFileLoc + path.parse(defaultFileName).name;
73
- }
74
- }
75
-
76
- async function getMetadataFromFile(path) {
77
- let edmx;
78
- edmx = await fs.read(path, "utf-8");
79
- return edmx;
80
- }
81
-
82
- async function getMetadataFromURL(url) {
83
- let edmx;
84
- const response = await axios.get(url);
85
- edmx = response["data"];
86
- if (edmx && (await _isValidXML(edmx))) {
87
- return edmx;
88
- } else {
89
- throw new Error(messages.INVALID_EDMX_METADATA);
90
- }
91
- }
92
-
93
- function _convertEDMXWithMultipleSchemas(edmx, multipleSchemas, namespace) {
94
- /*
95
- This is a quick hack only handling the following case we saw from SFSF:
96
-
97
- <edmx:DataServices>
98
- <Schema Namespace="SFODataSet">
99
- <EntityContainer>
100
- <EntitySet Name="Foos" EntityType="SFOData.Foo"> ... </EntitySet>
101
- </EntityContainer>
102
- </Schema>
103
- <Schema Namespace="SFOData">
104
- <EntityType Name="Foo"> ... </EntityType>
105
- </Schema>
106
- </edmx:DataServices>
107
-
108
- which is turned into that:
109
-
110
- <edmx:DataServices>
111
- <Schema Namespace="SFOData">
112
- <EntityContainer>
113
- <EntitySet Name="Foos" EntityType="SFOData.Foo"> ... </EntitySet>
114
- </EntityContainer>
115
- <EntityType Name="Foo"> ... </EntityType>
116
- </Schema>
117
- </edmx:DataServices>
118
- */
119
-
120
- // Remove the ending and beginning of the first and second schema tag
121
- edmx = edmx.replace(multipleSchemas, '');
122
- // Now capture the schema tag details
123
- let schemaDetails = edmx.match(/(<Schema [^>]*>)/);
124
- // Replace the Namespace value with the correct one
125
- schemaDetails = schemaDetails[0].replace(/Namespace="[^"]+"/, `Namespace="${namespace}"`);
126
- // Place the above computed schema details in the edmx content
127
- edmx = edmx.replace(/(<Schema [^>]*>)/, `${schemaDetails}`);
128
-
129
- return edmx;
130
- }
131
-
132
- async function edmx2csn(edmx, filename, context) {
133
- const result = edmx.match(/EntityType="([^"]+)/);
134
- const multipleSchemas = /(\s*<\/Schema>\s*<Schema [^>]*>)\s*/m;
135
- if (!result) {
136
- throw new Error(messages.MISSING_ENTITIES);
137
- }
138
- const index = result[1].lastIndexOf(".");
139
- const namespace = (index > 0) ? result[1].substring(0, index) : result[1];
140
-
141
- if (multipleSchemas.test(edmx)) {
142
- edmx = _convertEDMXWithMultipleSchemas(edmx, multipleSchemas, namespace);
143
- }
144
- let csn = await generateCSN(edmx, false, true, context);
145
- const regex = /^[\p{Letter}\p{Nl}_]{1}[_\p{Letter}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}]{0,127}$/gu
146
- // 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
147
- if (filename) {
148
- // Replace namespace by given filename in the csn file instead of edmx file
149
- const re = RegExp(`([("/])${namespace}([/").])`, 'g');
150
- let name = path.parse(filename).name;
151
- if (!(name.match(regex))) { // check if the filename is in the right format with the regex if not replace unaccepted characters with underscore (_)
152
- name = name.replace(/^[^a-z\p{Nl}_]/gui, '_');
153
- name = name.replace(/[^a-z0-9_\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}]/gui, '_');
154
- }
155
- const fn = `$1${name}$2`;
156
- csn = csn.replace(re, fn);
157
- }
158
- return JSON.parse(csn);
159
- }
160
-
161
- async function _generateEDMX2JSON(edmx) {
162
- // Reinitialize
163
- let cjson = convert.xml2json(edmx, {
164
- compact: true,
165
- spaces: 4
166
- });
167
- return JSON.parse(cjson);
168
- }
169
-
170
- async function generateCSN(edmx, ignorePersistenceSkip, mockServerUc, context) {
171
- let csn;
172
- let odataVersion;
173
- let edmx2jsonModel;
174
- let defaultNamespaces;
175
- let namespaces = [];
176
- if(context.namespaces) namespaces.push(...(context.namespaces));
177
- odataVersion = await common.getVersion(edmx);
178
- if (odataVersion === "V2") {
179
- if(context){
180
- context.oDataVersion = "V2";
181
- }
182
- //default namespaces to be present
183
- if(!context.include_all_namespaces)
184
- {
185
- defaultNamespaces = ['edmx','sap','m'];
186
- namespaces = namespaces.concat(defaultNamespaces);
187
- namespaces = namespaces.filter((item,pos) => namespaces.indexOf(item) === pos); //removing duplicate values
188
- }
189
- context.namespaces = namespaces;
190
- edmx2jsonModel = await _generateEDMX2JSON(edmx);
191
- return new Promise(function getCsn(resolve, reject) {
192
- csn = edmxv2CSN.getEdmxv2CSN(
193
- edmx2jsonModel,
194
- ignorePersistenceSkip,
195
- mockServerUc,
196
- context
197
- );
198
- if (csn) {
199
- resolve(csn);
200
- } else {
201
- reject("Error Occurred");
202
- }
203
- });
204
- }
205
- else if (odataVersion === 'V4') {
206
- if(context){
207
- context.oDataVersion = "V4";
208
- }
209
- //default namespaces to be present
210
- if(!context.include_all_namespaces)
211
- {
212
- defaultNamespaces = ['edmx'];
213
- namespaces = namespaces.concat(defaultNamespaces);
214
- namespaces = namespaces.filter((item,pos) => namespaces.indexOf(item) === pos); //removing duplicate values
215
- }
216
- context.namespaces = namespaces;
217
- return edmxv4CSN.getEdmxv4CSN(edmx, ignorePersistenceSkip, mockServerUc, context);
218
- }
219
- return new Promise(function invalidFile(resolve, reject) {
220
- reject(new Error(messages.INVALID_EDMX_METADATA));
221
- });
222
- }
223
- async function saveCSNModel(csnDataModel, fileLoc) {
224
- await fs.write(fileLoc, csnDataModel, "utf-8");
225
- }
226
-
227
- module.exports = {
228
- isValidInputFile,
229
- validateAndComputeOutputFilePath,
230
- edmx2csn,
231
- getMetadataFromFile,
232
- getMetadataFromURL,
233
- generateCSN,
234
- saveCSNModel,
235
- };