@sap/cds-dk 6.0.2 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +63 -0
- package/bin/add.js +29 -16
- package/bin/cds.js +7 -3
- package/bin/compile/index.js +6 -1
- package/bin/deploy/index.js +7 -1
- package/bin/fix-redirects.js +4 -2
- package/bin/init.js +5 -0
- package/bin/login.js +8 -2
- package/bin/pull.js +58 -0
- package/bin/push.js +52 -0
- package/bin/subscribe.js +45 -0
- package/lib/bind/bindingResolver.js +1 -2
- package/lib/bind/bindingUtil.js +1 -2
- package/lib/bind/cfKeyProvider.js +3 -3
- package/lib/client/activate.js +1 -1
- package/lib/client/auth_manager.js +7 -3
- package/lib/client/extend.js +1 -1
- package/lib/client/helper/cf_helper.js +1 -0
- package/lib/client/helper/url_helper.js +7 -3
- package/lib/client/index.js +1 -1
- package/lib/client/params.js +4 -2
- package/lib/client/pull.js +51 -0
- package/lib/client/push.js +49 -0
- package/lib/client/settings_manager.js +74 -21
- package/lib/compile/openapi/csdl2openapi.js +135 -163
- package/lib/compile/openapi/index.js +0 -1
- package/lib/import/common.js +9 -1
- package/lib/import/odata/metadataconverter/MetadataConverter.js +17 -4
- package/lib/import/odata/v2parser.js +0 -1
- package/lib/import/odata/v4parser.js +103 -29
- package/lib/import/openapi/importOpenAPI.js +3 -3
- package/lib/init/constants.js +9 -3
- package/lib/init/template/_merging/registry-mta.js +290 -0
- package/lib/init/template/approuter/index.js +22 -32
- package/lib/init/template/auditlog/index.js +7 -9
- package/lib/init/template/extensibility/files/cds.package.json +7 -0
- package/lib/init/template/extensibility/files/cds.package.json.hbs +9 -0
- package/lib/init/template/extensibility/files/xs-security.json.hbs +26 -0
- package/lib/init/template/extensibility/index.js +48 -0
- package/lib/init/template/hana/files/java/cdsrc.json.hbs +1 -1
- package/lib/init/template/hana/files/java/profile.cdsrc.json.hbs +2 -2
- package/lib/init/template/hana/files/mta.yaml.hbs +10 -0
- package/lib/init/template/hana/files/nodejs/cds.package.json.hbs +1 -1
- package/lib/init/template/hana/files/nodejs/cds.profile.package.json.hbs +2 -2
- package/lib/init/template/hana/index.js +76 -63
- package/lib/init/template/kibana-logging/index.js +31 -37
- package/lib/init/template/lint/files/.eslint/rules/no-entity-moo.js +14 -14
- package/lib/init/template/lint/index.js +1 -1
- package/lib/init/template/mta/files/mta.yaml.hbs +1 -1
- package/lib/init/template/mta/index.js +13 -7
- package/lib/init/template/mtx/index.js +2 -142
- package/lib/init/template/multitenancy/files/cds.package.json +7 -0
- package/lib/init/template/multitenancy/files/cds.package.json.hbs +9 -0
- package/lib/init/template/{mtx → multitenancy}/files/dependencies.package.json +1 -1
- package/lib/init/template/multitenancy/files/java/.cdsrc.json +19 -0
- package/lib/init/template/multitenancy/files/java/package.json +31 -0
- package/lib/init/template/{mtx → multitenancy}/files/mta.yaml.hbs +13 -6
- package/lib/init/template/multitenancy/files/xs-security.json.hbs +18 -0
- package/lib/init/template/multitenancy/index.js +109 -0
- package/lib/init/template/nodejs/files/package.json.hbs +3 -0
- package/lib/init/template/templateBase.js +4 -3
- package/lib/init/template/toggles/files/cds.package.json +7 -0
- package/lib/init/template/toggles/files/cds.package.json.hbs +9 -0
- package/lib/init/template/toggles/index.js +24 -0
- package/lib/init/template/xsuaa/files/mta.yaml.hbs +10 -0
- package/lib/init/template/xsuaa/index.js +44 -33
- package/lib/init/util/projectReader.js +13 -8
- package/lib/init/util/templateUtil.js +112 -110
- package/lib/k8s/ChartAdder.js +11 -3
- package/lib/k8s/ChartBuilder.js +6 -0
- package/lib/k8s/buildModel.js +1 -3
- package/lib/k8s/connectivity/index.js +11 -5
- package/lib/k8s/connectivity/templates/connectivity-proxy-info.yaml +7 -3
- package/lib/k8s/deployment/index.js +2 -4
- package/lib/k8s/deployment/subchart/Chart.yaml +1 -1
- package/lib/k8s/deployment/subchart/templates/_helpers.tpl +22 -11
- package/lib/k8s/deployment/subchart/templates/deployment.yaml +12 -5
- package/lib/k8s/deployment/subchart/templates/network-policy.yaml +3 -1
- package/lib/k8s/deployment/subchart/templates/pod-disruption-budget.yaml +1 -1
- package/lib/k8s/deployment/subchart/values.md +812 -0
- package/lib/k8s/deployment/subchart/values.schema.json +125 -30
- package/lib/k8s/deployment/subchart/values.yaml +7 -3
- package/lib/k8s/hana-deployer/index.js +10 -0
- package/lib/k8s/hana-deployer/templates/hana-deployer-job.yaml +8 -0
- package/lib/k8s/html5-apps-deployer/index.js +10 -0
- package/lib/k8s/html5-apps-deployer/templates/html5-apps-deployer-job.yaml +8 -0
- package/lib/k8s/index.js +2 -2
- package/lib/k8s/resources/helm/chart/templates/_deployment_helpers.tpl +1 -159
- package/lib/k8s/resources/helm/chart/templates/_helpers.tpl +0 -33
- package/lib/k8s/resources/helm/chart/templates/_sapcp_helpers.tpl +1 -1
- package/lib/k8s/resources/helm/chart/values.schema.json +449 -0
- package/lib/k8s/xsuaa/lib.js +10 -7
- package/lib/lint/Linter.js +155 -158
- package/lib/lint/generators.js +1 -1
- package/lib/lint/io.js +13 -5
- package/npm-shrinkwrap.json +1053 -136
- package/package.json +5 -4
- package/lib/init/template/_merging/existences.js +0 -297
- package/lib/init/template/mtx/files/cds.package.json +0 -12
- package/lib/init/template/mtx/files/cds.package.json.hbs +0 -14
- package/lib/init/template/mtx/files/java/.cdsrc.json +0 -17
- package/lib/init/template/mtx/files/java/package.json +0 -43
- package/lib/init/template/mtx/files/java/server.js +0 -30
- package/lib/init/template/mtx/files/xs-security.json.hbs +0 -48
- package/lib/lint/.eslintrc.js +0 -3
|
@@ -43,6 +43,27 @@ const edmxncdsdatatype = {
|
|
|
43
43
|
"Edm.DateTimeOffset_a": "cds.Timestamp",
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
+
const known_vocabularies = {
|
|
47
|
+
'Org.OData.Authorization.V1': 'Authorization',
|
|
48
|
+
'Org.OData.Aggregation.V1': 'Aggregation',
|
|
49
|
+
'Org.OData.Core.V1': 'Core',
|
|
50
|
+
'Org.OData.Capabilities.V1': 'Capabilities',
|
|
51
|
+
'Org.OData.Validation.V1': 'Validation',
|
|
52
|
+
'Org.OData.Measures.V1': 'Measures',
|
|
53
|
+
'Org.OData.Repeatability.V1': 'Repeatability',
|
|
54
|
+
|
|
55
|
+
'com.sap.vocabularies.Analytics.v1': 'Analytics',
|
|
56
|
+
'com.sap.vocabularies.CodeList.v1': 'CodeList',
|
|
57
|
+
'com.sap.vocabularies.Common.v1': 'Common',
|
|
58
|
+
'com.sap.vocabularies.Communication.v1': 'Communication',
|
|
59
|
+
'com.sap.vocabularies.Graph.v1': 'Graph',
|
|
60
|
+
'com.sap.vocabularies.HTML5.v1': 'HTML5',
|
|
61
|
+
'com.sap.vocabularies.ODM.v1': 'ODM',
|
|
62
|
+
'com.sap.vocabularies.PersonalData.v1': 'PersonalData',
|
|
63
|
+
'com.sap.vocabularies.Session.v1': 'Session',
|
|
64
|
+
'com.sap.vocabularies.UI.v1': 'UI',
|
|
65
|
+
};
|
|
66
|
+
|
|
46
67
|
function _initialize(parserContext) {
|
|
47
68
|
parserContext.unboundedActions = {};
|
|
48
69
|
parserContext.boundedActions = {};
|
|
@@ -883,7 +904,7 @@ function _generateCSN(edmxAsJson, ignorePersistenceSkip, mockServerUc, parserCon
|
|
|
883
904
|
_parseBounded(csn.definitions, 0, parserContext);
|
|
884
905
|
_parseBounded(csn.definitions, 1, parserContext);
|
|
885
906
|
// Step 7: get all annotations
|
|
886
|
-
_generateDocumentation(schemaData, csn.definitions);
|
|
907
|
+
_generateDocumentation(edmxAsJson, schemaData, csn.definitions, parserContext);
|
|
887
908
|
|
|
888
909
|
return JSON.stringify(csn, null, 4);
|
|
889
910
|
}
|
|
@@ -892,7 +913,7 @@ function _replaceSpecialCharacters(text) {
|
|
|
892
913
|
return text.replace(/(?:\\[rn]|[\r\n]+)+/gm, "\n").replace(/\s+/g, ' ').replace(/"/g, """).trim();
|
|
893
914
|
}
|
|
894
915
|
|
|
895
|
-
function _checkAnnotatationTerm(annotation, path, no_of_terms, targetString) {
|
|
916
|
+
function _checkAnnotatationTerm(annotation, path, no_of_terms, targetString, vocab) {
|
|
896
917
|
if (path) {
|
|
897
918
|
if (targetString === "@Core.Description" && annotation[1]["@Core.Description"]) {
|
|
898
919
|
if (path.doc === undefined)
|
|
@@ -903,60 +924,114 @@ function _checkAnnotatationTerm(annotation, path, no_of_terms, targetString) {
|
|
|
903
924
|
else if (targetString === "@Core.LongDescription" && annotation[1]["@Core.LongDescription"]) {
|
|
904
925
|
_generateLongDescription(annotation, path, no_of_terms);
|
|
905
926
|
}
|
|
927
|
+
else if (vocab) {
|
|
928
|
+
if (vocab.includes(targetString.substring(targetString.indexOf('@') + 1, targetString.lastIndexOf('.')))) {
|
|
929
|
+
path[targetString] = annotation[1][targetString];
|
|
930
|
+
}
|
|
931
|
+
}
|
|
906
932
|
}
|
|
907
933
|
}
|
|
908
|
-
function _checkAnnotationTarget(annotation, cdsDefs, str, no_of_terms) {
|
|
909
|
-
if (annotation[0].indexOf('/') === -1 && annotation[0].indexOf('(') === -1) {
|
|
910
|
-
if (annotation[0].endsWith(".EntityContainer")) {
|
|
911
|
-
let path = annotation[0].split(".")[0];
|
|
912
934
|
|
|
913
|
-
|
|
914
|
-
|
|
935
|
+
function checkEntitySetMap(pathName, parserContext) {
|
|
936
|
+
if (parserContext.entitySetToEntityTypeMap.get(pathName) != null) {
|
|
937
|
+
pathName = parserContext.namespace + '.' + parserContext.entitySetToEntityTypeMap.get(pathName)[0];
|
|
938
|
+
}
|
|
939
|
+
return pathName;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
function _checkAnnotationTarget(annotation, cdsDefs, str, no_of_terms, vocab, parserContext) {
|
|
943
|
+
if ((annotation[0].indexOf('/') === -1 && annotation[0].indexOf('(') === -1) || annotation[0].includes("Container")) {
|
|
915
944
|
if (cdsDefs[annotation[0]]) {
|
|
916
|
-
_checkAnnotatationTerm(annotation, cdsDefs[annotation[0]], no_of_terms, str);
|
|
945
|
+
_checkAnnotatationTerm(annotation, cdsDefs[annotation[0]], no_of_terms, str, vocab);
|
|
917
946
|
}
|
|
918
|
-
|
|
947
|
+
if (annotation[0].indexOf('/') > 0) {
|
|
948
|
+
let path = annotation[0].split('/');
|
|
949
|
+
let temp = parserContext.namespace + '.' + path[1];
|
|
950
|
+
let path1 = checkEntitySetMap(temp, parserContext);
|
|
951
|
+
if (cdsDefs[path1]) {
|
|
952
|
+
_checkAnnotatationTerm(annotation, cdsDefs[path1], no_of_terms, str, vocab);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
else if (annotation[0].includes("Container")) {
|
|
956
|
+
let path = annotation[0].substring(0,annotation[0].lastIndexOf('.'));
|
|
957
|
+
let actualPath = checkEntitySetMap(path, parserContext);
|
|
958
|
+
_checkAnnotatationTerm(annotation, cdsDefs[actualPath], no_of_terms, str, vocab);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
else if (annotation[0].indexOf('(') === -1 && !(annotation[0].indexOf('/') === -1)) {
|
|
919
962
|
let path = annotation[0].split('/');
|
|
920
|
-
|
|
921
|
-
|
|
963
|
+
let path1 = checkEntitySetMap(path[0], parserContext);
|
|
964
|
+
if (cdsDefs[path1]) {
|
|
965
|
+
_checkAnnotatationTerm(annotation, cdsDefs[path1]["elements"][path[1]], no_of_terms, str, vocab);
|
|
922
966
|
}
|
|
923
967
|
} else {
|
|
924
968
|
let path = annotation[0].split('(');
|
|
925
|
-
|
|
969
|
+
let actualPath = checkEntitySetMap(path[0], parserContext);
|
|
970
|
+
if (cdsDefs[actualPath] === undefined) {
|
|
926
971
|
let temp = path[1].split(')');
|
|
927
972
|
let path1 = temp[0].split(',');
|
|
928
973
|
let path2 = path[0].split('.');
|
|
929
974
|
if (cdsDefs[path1[0]]) {
|
|
930
|
-
_checkAnnotatationTerm(annotation, cdsDefs[path1[0]]["actions"][path2[1]], no_of_terms, str);
|
|
975
|
+
_checkAnnotatationTerm(annotation, cdsDefs[path1[0]]["actions"][path2[1]], no_of_terms, str, vocab);
|
|
931
976
|
}
|
|
932
977
|
} else {
|
|
933
978
|
if (path[1].indexOf('/') === -1) {
|
|
934
|
-
_checkAnnotatationTerm(annotation, cdsDefs[path[0]], no_of_terms, str);
|
|
979
|
+
_checkAnnotatationTerm(annotation, cdsDefs[path[0]], no_of_terms, str, vocab);
|
|
935
980
|
} else {
|
|
936
981
|
let path1 = path[1].split('/');
|
|
937
982
|
if (cdsDefs[path[0]] && cdsDefs[path[0]]["params"]) {
|
|
938
|
-
_checkAnnotatationTerm(annotation, cdsDefs[path[0]]["params"][path1[1]], no_of_terms, str);
|
|
983
|
+
_checkAnnotatationTerm(annotation, cdsDefs[path[0]]["params"][path1[1]], no_of_terms, str, vocab);
|
|
939
984
|
}
|
|
940
985
|
}
|
|
941
986
|
}
|
|
942
987
|
}
|
|
943
988
|
}
|
|
944
989
|
|
|
945
|
-
function
|
|
990
|
+
function _replaceSchemaDataAnnotation(vocabAlias, vocabNamespce, schemaDataAnnotation) {
|
|
991
|
+
for (let v in vocabAlias) {
|
|
992
|
+
if (schemaDataAnnotation.includes(vocabAlias[v])) {
|
|
993
|
+
schemaDataAnnotation = schemaDataAnnotation.split(vocabAlias[v]).join(known_vocabularies[vocabNamespce[v]]);
|
|
994
|
+
}
|
|
995
|
+
if (schemaDataAnnotation.includes(vocabNamespce[v])) {
|
|
996
|
+
schemaDataAnnotation = schemaDataAnnotation.split(vocabNamespce[v]).join(known_vocabularies[vocabNamespce[v]]);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
return JSON.parse(schemaDataAnnotation);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
function _generateDocumentation(edmxAsJson, schemaData, cdsDefs, parserContext) {
|
|
1003
|
+
let vocabAlias = [];
|
|
1004
|
+
let vocab = [];
|
|
1005
|
+
let vocabNamespce = [];
|
|
946
1006
|
if (schemaData[0].$Annotations) {
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
1007
|
+
if (edmxAsJson.$Reference) {
|
|
1008
|
+
Object.entries(edmxAsJson.$Reference).forEach(a => {
|
|
1009
|
+
if (known_vocabularies.hasOwnProperty(a[1].$Include[0].$Namespace)) {
|
|
1010
|
+
vocabAlias.push(a[1].$Include[0].$Alias);
|
|
1011
|
+
vocabNamespce.push(a[1].$Include[0].$Namespace);
|
|
1012
|
+
vocab.push(known_vocabularies[a[1].$Include[0].$Namespace])
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
951
1016
|
|
|
952
|
-
|
|
953
|
-
_checkAnnotationTarget(annotation, cdsDefs, "@Core.Description", no_of_terms);
|
|
954
|
-
}
|
|
955
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
956
|
-
if (annotation[1].hasOwnProperty('@Core.LongDescription')) {
|
|
957
|
-
_checkAnnotationTarget(annotation, cdsDefs, "@Core.LongDescription", no_of_terms);
|
|
1017
|
+
schemaData[0].$Annotations = _replaceSchemaDataAnnotation(vocabAlias, vocabNamespce, JSON.stringify(schemaData[0].$Annotations));
|
|
958
1018
|
|
|
959
|
-
|
|
1019
|
+
Object.entries(schemaData[0].$Annotations).map(annotation => {
|
|
1020
|
+
let no_of_terms;
|
|
1021
|
+
Object.entries(annotation[1]).forEach(anno => {
|
|
1022
|
+
if (vocab.includes(anno[0].substring(anno[0].indexOf('@') + 1, anno[0].lastIndexOf('.')))) {
|
|
1023
|
+
if (annotation[1].hasOwnProperty('@Core.Description')) {
|
|
1024
|
+
no_of_terms = true;
|
|
1025
|
+
}
|
|
1026
|
+
if (annotation[1].hasOwnProperty('@Common.FieldControl')) {
|
|
1027
|
+
annotation[1]["@Common.FieldControl"] = { "#": annotation[1]["@Common.FieldControl"] }
|
|
1028
|
+
}
|
|
1029
|
+
if (annotation[1].hasOwnProperty('@Common.IsUpperCase')) {
|
|
1030
|
+
annotation[1]["@Common.IsUpperCase"] = true;
|
|
1031
|
+
}
|
|
1032
|
+
_checkAnnotationTarget(annotation, cdsDefs, anno[0], no_of_terms, vocab, parserContext);
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
960
1035
|
});
|
|
961
1036
|
}
|
|
962
1037
|
}
|
|
@@ -969,7 +1044,6 @@ function _generateLongDescription(annotation, path, no_of_terms) {
|
|
|
969
1044
|
}
|
|
970
1045
|
}
|
|
971
1046
|
|
|
972
|
-
|
|
973
1047
|
function _generateEDMX2JSON(edmx, name_space, parserContext) {
|
|
974
1048
|
return new Promise(function getJson(resolve, reject) {
|
|
975
1049
|
try {
|
|
@@ -136,7 +136,7 @@ function operations(context, csn, input) {
|
|
|
136
136
|
|
|
137
137
|
if (param.explode && param.style !== "form")
|
|
138
138
|
cdsParam["@openapi.explode"] = true;
|
|
139
|
-
|
|
139
|
+
|
|
140
140
|
if (param.explode === false &&
|
|
141
141
|
(param.style === "form" || (!param.style && param.in === "query"))
|
|
142
142
|
)
|
|
@@ -369,11 +369,11 @@ function cdsType(
|
|
|
369
369
|
if (arrayItem && jsonSchema !== "{}") {
|
|
370
370
|
type = anonymousType(context, {
|
|
371
371
|
type: "common.JSON",
|
|
372
|
-
"@
|
|
372
|
+
"@JSON.Schema": jsonSchema,
|
|
373
373
|
});
|
|
374
374
|
} else {
|
|
375
375
|
type.type = "common.JSON";
|
|
376
|
-
if (jsonSchema !== "{}") type["@
|
|
376
|
+
if (jsonSchema !== "{}") type["@JSON.Schema"] = jsonSchema;
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
379
|
break;
|
package/lib/init/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const os = require('os');
|
|
2
2
|
|
|
3
|
-
const MAVEN_ARCHETYPE_VERSION = '1.
|
|
3
|
+
const MAVEN_ARCHETYPE_VERSION = '1.27.0';
|
|
4
4
|
|
|
5
5
|
const constants = {
|
|
6
6
|
IS_WIN: (os.platform() === 'win32'),
|
|
@@ -16,6 +16,9 @@ const constants = {
|
|
|
16
16
|
OPTION_XSUAA: 'xsuaa',
|
|
17
17
|
OPTION_MTA: 'mta',
|
|
18
18
|
OPTION_MTX: 'mtx',
|
|
19
|
+
OPTION_MULTITENANCY: 'multitenancy',
|
|
20
|
+
OPTION_TOGGLES: 'toggles',
|
|
21
|
+
OPTION_EXTENSIBILITY: 'extensibility',
|
|
19
22
|
OPTION_AUDITLOG: 'auditlog',
|
|
20
23
|
OPTION_APPROUTER: 'approuter',
|
|
21
24
|
OPTION_KIBANA_LOGGING: 'kibana-logging',
|
|
@@ -68,9 +71,12 @@ constants.OPTIONS_PRIORITY = [
|
|
|
68
71
|
constants.OPTION_PIPELINE,
|
|
69
72
|
constants.OPTION_MTA,
|
|
70
73
|
constants.OPTION_CF_MANIFEST,
|
|
71
|
-
constants.OPTION_HANA,
|
|
72
|
-
constants.OPTION_XSUAA,
|
|
73
74
|
constants.OPTION_MTX,
|
|
75
|
+
constants.OPTION_MULTITENANCY,
|
|
76
|
+
constants.OPTION_TOGGLES,
|
|
77
|
+
constants.OPTION_EXTENSIBILITY,
|
|
78
|
+
constants.OPTION_XSUAA,
|
|
79
|
+
constants.OPTION_HANA,
|
|
74
80
|
constants.OPTION_AUDITLOG,
|
|
75
81
|
constants.OPTION_APPROUTER,
|
|
76
82
|
constants.OPTION_SAMPLES,
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
// Registry of sequence matchers in mta.yaml files
|
|
2
|
+
|
|
3
|
+
const srvNode = {
|
|
4
|
+
ref: 'srv',
|
|
5
|
+
in: 'modules',
|
|
6
|
+
where: [{
|
|
7
|
+
property: 'type',
|
|
8
|
+
isEqualTo: 'nodejs'
|
|
9
|
+
}],
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const srvJava = {
|
|
13
|
+
ref: 'srv',
|
|
14
|
+
in: 'modules',
|
|
15
|
+
where: [{
|
|
16
|
+
property: 'type',
|
|
17
|
+
isEqualTo: 'java'
|
|
18
|
+
}],
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const approuter = {
|
|
22
|
+
ref: 'approuter',
|
|
23
|
+
in: 'modules',
|
|
24
|
+
where: [{
|
|
25
|
+
property: 'type',
|
|
26
|
+
isEqualTo: 'approuter.nodejs'
|
|
27
|
+
}]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const xsuaa = {
|
|
31
|
+
ref: 'uaa-resource',
|
|
32
|
+
in: 'resources',
|
|
33
|
+
where: [{
|
|
34
|
+
property: 'type',
|
|
35
|
+
isEqualTo: 'org.cloudfoundry.managed-service',
|
|
36
|
+
}, {
|
|
37
|
+
property: 'parameters.service',
|
|
38
|
+
isEqualTo: 'xsuaa',
|
|
39
|
+
}, {
|
|
40
|
+
property: 'parameters.service-plan',
|
|
41
|
+
isEqualTo: 'application'
|
|
42
|
+
}]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const auditlog = {
|
|
46
|
+
ref: 'auditlog-resource',
|
|
47
|
+
in: 'resources',
|
|
48
|
+
where: [{
|
|
49
|
+
property: 'type',
|
|
50
|
+
isEqualTo: 'org.cloudfoundry.managed-service',
|
|
51
|
+
}, {
|
|
52
|
+
property: 'parameters.service',
|
|
53
|
+
isEqualTo: 'auditlog-api',
|
|
54
|
+
}]
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const kibanaLogging = {
|
|
58
|
+
ref: 'cf-logging',
|
|
59
|
+
in: 'resources',
|
|
60
|
+
where: [{
|
|
61
|
+
property: 'type',
|
|
62
|
+
isEqualTo: 'org.cloudfoundry.managed-service',
|
|
63
|
+
}, {
|
|
64
|
+
property: 'parameters.service',
|
|
65
|
+
isEqualTo: 'application-logs',
|
|
66
|
+
}, {
|
|
67
|
+
property: 'parameters.service-plan',
|
|
68
|
+
isEqualTo: 'lite',
|
|
69
|
+
}]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const hdbDeployer = {
|
|
73
|
+
ref: 'deployer',
|
|
74
|
+
in: 'modules',
|
|
75
|
+
where: [{
|
|
76
|
+
property: 'type',
|
|
77
|
+
isEqualTo: 'hdb'
|
|
78
|
+
}]
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const hdiContainer = {
|
|
82
|
+
ref: 'hdi-container-resource',
|
|
83
|
+
in: 'resources',
|
|
84
|
+
where: [{
|
|
85
|
+
property: 'type',
|
|
86
|
+
isEqualTo: 'com.sap.xs.hdi-container',
|
|
87
|
+
}]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const serviceManager = {
|
|
91
|
+
ref: 'service-manager-resource',
|
|
92
|
+
in: 'resources',
|
|
93
|
+
where: [{
|
|
94
|
+
property: 'type',
|
|
95
|
+
isEqualTo: 'org.cloudfoundry.managed-service',
|
|
96
|
+
}, {
|
|
97
|
+
property: 'parameters.service',
|
|
98
|
+
isEqualTo: 'service-manager',
|
|
99
|
+
}, {
|
|
100
|
+
property: 'parameters.service-plan',
|
|
101
|
+
isEqualTo: 'container'
|
|
102
|
+
}]
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const saasRegistry = {
|
|
106
|
+
ref: 'registry-resource',
|
|
107
|
+
in: 'resources',
|
|
108
|
+
where: [{
|
|
109
|
+
property: 'type',
|
|
110
|
+
isEqualTo: 'org.cloudfoundry.managed-service',
|
|
111
|
+
}, {
|
|
112
|
+
property: 'parameters.service',
|
|
113
|
+
isEqualTo: 'saas-registry',
|
|
114
|
+
}, {
|
|
115
|
+
property: 'parameters.service-plan',
|
|
116
|
+
isEqualTo: 'application'
|
|
117
|
+
}]
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const srvAPI = {
|
|
121
|
+
ref: 'srvAPI',
|
|
122
|
+
in: 'provides',
|
|
123
|
+
where: [{
|
|
124
|
+
property: 'name',
|
|
125
|
+
isEqualTo: 'srv-api'
|
|
126
|
+
}, {
|
|
127
|
+
property: 'properties.srv-url',
|
|
128
|
+
isEqualTo: '${default-url}'
|
|
129
|
+
}]
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const mtxSidecar = {
|
|
133
|
+
ref: 'sidecar',
|
|
134
|
+
in: 'modules',
|
|
135
|
+
where: [{
|
|
136
|
+
property: 'type',
|
|
137
|
+
isEqualTo: `nodejs`
|
|
138
|
+
}, {
|
|
139
|
+
property: 'path',
|
|
140
|
+
isEqualTo: `mtx/sidecar`
|
|
141
|
+
}]
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const providedMtxAPI = {
|
|
145
|
+
ref: 'provided-mtx-api',
|
|
146
|
+
in: 'provides',
|
|
147
|
+
where: [{
|
|
148
|
+
property: 'name',
|
|
149
|
+
isEqualTo: 'mtx-api'
|
|
150
|
+
}, {
|
|
151
|
+
property: 'properties.mtx-url',
|
|
152
|
+
isEqualTo: '${default-url}'
|
|
153
|
+
}]
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const requiredMtxAPI = {
|
|
157
|
+
ref: 'required-mtx-api',
|
|
158
|
+
in: [approuter, 'requires'],
|
|
159
|
+
where: [{
|
|
160
|
+
property: 'properties.name',
|
|
161
|
+
isEqualTo: 'mtx-api'
|
|
162
|
+
}, {
|
|
163
|
+
property: 'properties.url',
|
|
164
|
+
isEqualTo: '~{mtx-url}'
|
|
165
|
+
}]
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const providedAppAPI = {
|
|
169
|
+
ref: 'provided-app-api',
|
|
170
|
+
in: [approuter, 'provides'],
|
|
171
|
+
where: [{
|
|
172
|
+
property: 'name',
|
|
173
|
+
isEqualTo: 'app-api'
|
|
174
|
+
}, {
|
|
175
|
+
property: 'properties.app-protocol',
|
|
176
|
+
isEqualTo: '${protocol}'
|
|
177
|
+
}, {
|
|
178
|
+
property: 'properties.app-uri',
|
|
179
|
+
isEqualTo: '${default-uri}'
|
|
180
|
+
}],
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const requiredAppAPI = {
|
|
184
|
+
ref: 'required-app-api',
|
|
185
|
+
in: [srvNode, 'requires'],
|
|
186
|
+
where: [{
|
|
187
|
+
property: 'name',
|
|
188
|
+
isEqualTo: 'app-api'
|
|
189
|
+
}, {
|
|
190
|
+
property: 'properties.SUBSCRIPTION_URL',
|
|
191
|
+
isEqualTo: '~{app-protocol}://\\${tenant_subdomain}-~{app-uri}'
|
|
192
|
+
}]
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const providedMtxSidecarAPI = {
|
|
196
|
+
ref: 'provided-mtx-sidecar-api',
|
|
197
|
+
in: [mtxSidecar, 'provides'],
|
|
198
|
+
where: [{
|
|
199
|
+
property: 'properties.url',
|
|
200
|
+
isEqualTo: '${default-url}'
|
|
201
|
+
}]
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const requiredMtxSidecarAPI = {
|
|
205
|
+
ref: 'required-mtx-sidecar-api',
|
|
206
|
+
in: [srvJava, 'requires'],
|
|
207
|
+
where: [{
|
|
208
|
+
property: 'properties.CDS_MULTITENANCY_SIDECAR_URL',
|
|
209
|
+
isEqualTo: '~{url}'
|
|
210
|
+
}]
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const requiredJavaApprouterAPI = {
|
|
214
|
+
ref: 'required-java-approuter-api',
|
|
215
|
+
in: [srvJava, 'requires'],
|
|
216
|
+
where: [{
|
|
217
|
+
property: 'properties.CDS_MULTITENANCY_APPUI_URL',
|
|
218
|
+
isEqualTo: '~{url}'
|
|
219
|
+
}]
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const providedJavaApprouterAPI = {
|
|
223
|
+
ref: 'provided-java-approuter-api',
|
|
224
|
+
in: [approuter, 'requires'],
|
|
225
|
+
where: [{
|
|
226
|
+
property: 'properties.url',
|
|
227
|
+
isEqualTo: '${default-url}'
|
|
228
|
+
}]
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const approuterExtensibility = {
|
|
232
|
+
ref: 'approuter-extensibility',
|
|
233
|
+
in: 'routes',
|
|
234
|
+
where: [{
|
|
235
|
+
property: 'source',
|
|
236
|
+
isEqualTo: '^/extend/(.*)'
|
|
237
|
+
}, {
|
|
238
|
+
property: 'destination',
|
|
239
|
+
isEqualTo: 'mtx-api',
|
|
240
|
+
}, {
|
|
241
|
+
property: 'target',
|
|
242
|
+
isEqualTo: '$1',
|
|
243
|
+
}, {
|
|
244
|
+
property: 'authenticationType',
|
|
245
|
+
isEqualTo: 'none',
|
|
246
|
+
}]
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const approuterExtensibilityJava = {
|
|
250
|
+
ref: 'approuter-extensibility-java',
|
|
251
|
+
in: 'routes',
|
|
252
|
+
where: [{
|
|
253
|
+
property: 'source',
|
|
254
|
+
isEqualTo: '^/extend/(.*)'
|
|
255
|
+
}, {
|
|
256
|
+
property: 'destination',
|
|
257
|
+
isEqualTo: 'mtx-api',
|
|
258
|
+
}, {
|
|
259
|
+
property: 'target',
|
|
260
|
+
isEqualTo: '$1',
|
|
261
|
+
}, {
|
|
262
|
+
property: 'authenticationType',
|
|
263
|
+
isEqualTo: 'none',
|
|
264
|
+
}]
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
module.exports = {
|
|
268
|
+
srvNode,
|
|
269
|
+
srvJava,
|
|
270
|
+
approuter,
|
|
271
|
+
xsuaa,
|
|
272
|
+
auditlog,
|
|
273
|
+
hdbDeployer,
|
|
274
|
+
hdiContainer,
|
|
275
|
+
serviceManager,
|
|
276
|
+
saasRegistry,
|
|
277
|
+
srvAPI,
|
|
278
|
+
mtxSidecar,
|
|
279
|
+
providedMtxAPI,
|
|
280
|
+
requiredMtxAPI,
|
|
281
|
+
providedMtxSidecarAPI,
|
|
282
|
+
requiredMtxSidecarAPI,
|
|
283
|
+
providedAppAPI,
|
|
284
|
+
requiredAppAPI,
|
|
285
|
+
requiredJavaApprouterAPI,
|
|
286
|
+
providedJavaApprouterAPI,
|
|
287
|
+
kibanaLogging,
|
|
288
|
+
approuterExtensibility,
|
|
289
|
+
approuterExtensibilityJava
|
|
290
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
1
|
const { join } = require('path')
|
|
3
2
|
const TemplateBase = require('../templateBase')
|
|
4
3
|
const ProjectReader = require('../../util/projectReader')
|
|
@@ -9,7 +8,7 @@ const {
|
|
|
9
8
|
requiredMtxAPI, requiredJavaApprouterAPI, providedJavaApprouterAPI, // APIs
|
|
10
9
|
requiredAppAPI, providedAppAPI,
|
|
11
10
|
approuterExtensibility, approuterExtensibilityJava // xs-app.json config
|
|
12
|
-
} = require('../_merging/
|
|
11
|
+
} = require('../_merging/registry-mta')
|
|
13
12
|
|
|
14
13
|
module.exports = class ApprouterTemplate extends TemplateBase {
|
|
15
14
|
|
|
@@ -24,50 +23,41 @@ module.exports = class ApprouterTemplate extends TemplateBase {
|
|
|
24
23
|
|
|
25
24
|
async runDependentMerging() {
|
|
26
25
|
const projectDescriptor = await this.projectReader.read(this.options)
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
if (
|
|
26
|
+
const { isNodejs, isJava, isExtensible, isMultitenant, hasMtaDeployment } = projectDescriptor.cap
|
|
27
|
+
|
|
28
|
+
if (hasMtaDeployment) {
|
|
30
29
|
const srv = isNodejs ? srvNode : srvJava
|
|
31
30
|
const apis = isJava ? [requiredJavaApprouterAPI, providedJavaApprouterAPI] : []
|
|
32
31
|
if (isNodejs && isMultitenant) apis.push(requiredMtxAPI, requiredAppAPI, providedAppAPI)
|
|
33
32
|
if (isJava && isMultitenant) apis.push(requiredMtxAPI)
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
existenceKeyPath: ["name"],
|
|
47
|
-
}, {
|
|
48
|
-
in: approuter,
|
|
49
|
-
inKeyPath: ["requires"],
|
|
50
|
-
into: "name",
|
|
51
|
-
existences: [xsuaa],
|
|
52
|
-
existenceKeyPath: ["name"],
|
|
53
|
-
}],
|
|
54
|
-
}
|
|
55
|
-
)
|
|
33
|
+
const additions = [srv, approuter, xsuaa, ...apis]
|
|
34
|
+
const mtaYAMLPath = join(this.projectPath, 'mta.yaml')
|
|
35
|
+
await this.templateUtil.mergeYAML(mtaYAMLPath, `${__dirname}/files/mta.yaml.hbs`, projectDescriptor, {
|
|
36
|
+
additions,
|
|
37
|
+
relationships: [{
|
|
38
|
+
insert: [xsuaa, 'name'],
|
|
39
|
+
into: [srv, 'requires', 'name']
|
|
40
|
+
}, {
|
|
41
|
+
insert: [xsuaa, 'name'],
|
|
42
|
+
into: [approuter, 'requires', 'name']
|
|
43
|
+
}],
|
|
44
|
+
})
|
|
56
45
|
}
|
|
57
46
|
|
|
58
47
|
const appPath = join(this.projectPath, projectDescriptor.ui.appPath || 'app')
|
|
59
|
-
const
|
|
60
|
-
|
|
48
|
+
const additions = isExtensible && isJava ? [approuterExtensibilityJava] :
|
|
49
|
+
isExtensible && isNodejs ? [approuterExtensibility] : []
|
|
61
50
|
await this.templateUtil.mergeJSON(
|
|
62
51
|
`${appPath}/xs-app.json`,
|
|
63
52
|
`${__dirname}/files/xs-app.json.hbs`,
|
|
64
53
|
projectDescriptor,
|
|
65
|
-
{
|
|
54
|
+
{ additions }
|
|
66
55
|
)
|
|
67
56
|
}
|
|
68
57
|
|
|
69
58
|
async run() {
|
|
70
59
|
const projectDescriptor = await this.projectReader.read(this.options)
|
|
60
|
+
const { for: forProfile } = projectDescriptor.cap
|
|
71
61
|
const appPath = join(this.projectPath, projectDescriptor.ui.appPath || 'app')
|
|
72
62
|
const appPackageJSONPath = join(appPath, 'package.json')
|
|
73
63
|
|
|
@@ -83,14 +73,14 @@ module.exports = class ApprouterTemplate extends TemplateBase {
|
|
|
83
73
|
switch (projectType) {
|
|
84
74
|
case PROJECT_TYPE.java: {
|
|
85
75
|
const cdsrcJSONPath = join(this.projectPath, '.cdsrc.json')
|
|
86
|
-
const cdsTemplateFile =
|
|
76
|
+
const cdsTemplateFile = forProfile ? 'cds.cdsrc.json.hbs' : 'cds.cdsrc.json'
|
|
87
77
|
const cdsPackageJSONPath = join(__dirname, 'files', cdsTemplateFile)
|
|
88
78
|
await this.templateUtil.mergeJSON(cdsrcJSONPath, cdsPackageJSONPath, projectDescriptor)
|
|
89
79
|
break
|
|
90
80
|
}
|
|
91
81
|
case PROJECT_TYPE.nodejs: {
|
|
92
82
|
const packageJSONPath = join(this.projectPath, 'package.json')
|
|
93
|
-
const cdsTemplateFile =
|
|
83
|
+
const cdsTemplateFile = forProfile ? 'cds.package.json.hbs' : 'cds.package.json'
|
|
94
84
|
const cdsPackageJSONPath = join(__dirname, 'files', cdsTemplateFile)
|
|
95
85
|
await this.templateUtil.mergeJSON(packageJSONPath, cdsPackageJSONPath, projectDescriptor)
|
|
96
86
|
break
|
|
@@ -2,7 +2,7 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const TemplateBase = require('../templateBase');
|
|
4
4
|
const ProjectReader = require('../../util/projectReader');
|
|
5
|
-
const { srvNode, srvJava, auditlog } = require('../_merging/
|
|
5
|
+
const { srvNode, srvJava, auditlog } = require('../_merging/registry-mta');
|
|
6
6
|
|
|
7
7
|
module.exports = class AuditlogTemplate extends TemplateBase {
|
|
8
8
|
constructor(projectPath, generator) {
|
|
@@ -12,22 +12,20 @@ module.exports = class AuditlogTemplate extends TemplateBase {
|
|
|
12
12
|
|
|
13
13
|
async runDependentMerging() {
|
|
14
14
|
const projectDescriptor = await this.projectReader.read(this.options);
|
|
15
|
+
const { isNodejs } = projectDescriptor.cap;
|
|
15
16
|
const mtaYAMLPath = path.join(this.projectPath, 'mta.yaml');
|
|
16
17
|
if (!fs.existsSync(mtaYAMLPath)) return;
|
|
17
|
-
const srv =
|
|
18
|
+
const srv = isNodejs ? srvNode : srvJava
|
|
18
19
|
await this.templateUtil.mergeYAML(
|
|
19
20
|
mtaYAMLPath,
|
|
20
21
|
`${__dirname}/files/mta.yaml.hbs`,
|
|
21
22
|
projectDescriptor,
|
|
22
23
|
{
|
|
23
|
-
|
|
24
|
+
additions: [srv, auditlog],
|
|
24
25
|
relationships: [{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
existences: [auditlog],
|
|
29
|
-
existenceKeyPath: ["name"],
|
|
30
|
-
}],
|
|
26
|
+
insert: [auditlog, 'name'],
|
|
27
|
+
into: [srv, 'requires', 'name']
|
|
28
|
+
}]
|
|
31
29
|
}
|
|
32
30
|
);
|
|
33
31
|
}
|