@sap/cds-compiler 5.1.2 → 5.2.0
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 +26 -0
- package/bin/cdsc.js +2 -2
- package/bin/cdshi.js +24 -17
- package/bin/cdsse.js +17 -18
- package/lib/api/main.js +19 -2
- package/lib/api/options.js +4 -1
- package/lib/base/builtins.js +1 -0
- package/lib/base/message-registry.js +16 -3
- package/lib/base/model.js +0 -10
- package/lib/checks/actionsFunctions.js +0 -12
- package/lib/checks/structuredAnnoExpressions.js +10 -14
- package/lib/compiler/assert-consistency.js +19 -11
- package/lib/compiler/builtins.js +1 -1
- package/lib/compiler/define.js +3 -3
- package/lib/compiler/extend.js +5 -5
- package/lib/compiler/populate.js +9 -9
- package/lib/compiler/propagator.js +1 -0
- package/lib/compiler/resolve.js +29 -34
- package/lib/compiler/shared.js +7 -8
- package/lib/compiler/tweak-assocs.js +155 -64
- package/lib/compiler/utils.js +1 -1
- package/lib/compiler/xpr-rewrite.js +4 -3
- package/lib/edm/annotations/genericTranslation.js +13 -9
- package/lib/edm/csn2edm.js +26 -2
- package/lib/edm/edm.js +23 -8
- package/lib/edm/edmInboundChecks.js +5 -7
- package/lib/edm/edmPreprocessor.js +43 -30
- package/lib/gen/BaseParser.js +720 -0
- package/lib/gen/CdlParser.js +4421 -0
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +1 -1
- package/lib/gen/languageParser.js +4006 -4001
- package/lib/language/antlrParser.js +62 -0
- package/lib/language/genericAntlrParser.js +28 -0
- package/lib/model/csnUtils.js +2 -0
- package/lib/model/revealInternalProperties.js +2 -0
- package/lib/modelCompare/utils/filter.js +70 -42
- package/lib/optionProcessor.js +9 -3
- package/lib/parsers/AstBuildingParser.js +1172 -0
- package/lib/parsers/CdlGrammar.g4 +1940 -0
- package/lib/parsers/Lexer.js +239 -0
- package/lib/render/toCdl.js +23 -27
- package/lib/render/toSql.js +5 -5
- package/lib/transform/db/applyTransformations.js +54 -16
- package/lib/transform/draft/odata.js +10 -11
- package/lib/transform/effective/flattening.js +10 -14
- package/lib/transform/odata/flattening.js +42 -31
- package/lib/transform/odata/toFinalBaseType.js +7 -6
- package/lib/transform/universalCsn/universalCsnEnricher.js +1 -0
- package/package.json +2 -2
- package/share/messages/redirected-to-ambiguous.md +5 -4
|
@@ -355,7 +355,7 @@ function xprRewriteFns( model ) {
|
|
|
355
355
|
// On select items, use navigation elements or table alias
|
|
356
356
|
// TODO: Expand/inline paths don't have a `_navigation` property on their last
|
|
357
357
|
// path step, yet. We need to implement expand/inline.
|
|
358
|
-
const isSimpleSelectItem = target.value?.path && target._main?.query && !target.
|
|
358
|
+
const isSimpleSelectItem = target.value?.path && target._main?.query && !target._columnParent;
|
|
359
359
|
if (isSimpleSelectItem) {
|
|
360
360
|
const isSelfPath = (expr.path[0]?._navigation?.kind === '$self');
|
|
361
361
|
if (isSelfPath) {
|
|
@@ -665,8 +665,9 @@ function xprRewriteFns( model ) {
|
|
|
665
665
|
}
|
|
666
666
|
|
|
667
667
|
const item = expr.path[index];
|
|
668
|
-
//
|
|
669
|
-
if
|
|
668
|
+
// If the artifact is already in the same definition, we must not check the query.
|
|
669
|
+
// Or if it is not a query -> no $navElement -> use `elements`
|
|
670
|
+
if (item._artifact._main === env || !env.query && env.kind !== 'select') {
|
|
670
671
|
if (env.elements?.[item.id])
|
|
671
672
|
return [ env.elements[item.id], index ];
|
|
672
673
|
return [ null, expr.path.length ];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { isEdmPropertyRendered,
|
|
3
|
+
const { isEdmPropertyRendered, transformAnnotationExpression } = require('../../model/csnUtils');
|
|
4
4
|
const { isBuiltinType, isMagicVariable } = require('../../base/builtins');
|
|
5
5
|
const edmUtils = require('../edmUtils.js');
|
|
6
6
|
const oDataDictionary = require('../../gen/Dictionary.json');
|
|
@@ -131,7 +131,7 @@ function csn2annotationEdm( reqDefs, reqDefsUtils, csnVocabularies, serviceName,
|
|
|
131
131
|
const knownAnnos = filterKnownAnnotations(carrier);
|
|
132
132
|
knownAnnos.forEach((pn) => {
|
|
133
133
|
scopeCheck.anno = pn;
|
|
134
|
-
|
|
134
|
+
transformAnnotationExpression(carrier, pn, scopeCheck, carrier.$path);
|
|
135
135
|
});
|
|
136
136
|
});
|
|
137
137
|
}
|
|
@@ -141,7 +141,7 @@ function csn2annotationEdm( reqDefs, reqDefsUtils, csnVocabularies, serviceName,
|
|
|
141
141
|
const knownAnnos = filterKnownAnnotations(obj);
|
|
142
142
|
knownAnnos.forEach((pn) => {
|
|
143
143
|
scopeCheck.anno = pn;
|
|
144
|
-
|
|
144
|
+
transformAnnotationExpression(obj, pn, scopeCheck, obj.$path);
|
|
145
145
|
});
|
|
146
146
|
};
|
|
147
147
|
if (def.$isParamEntity && def._origin) {
|
|
@@ -171,7 +171,7 @@ function csn2annotationEdm( reqDefs, reqDefsUtils, csnVocabularies, serviceName,
|
|
|
171
171
|
if (innerAnnotation)
|
|
172
172
|
newAnno += `.@${innerAnnotation}`;
|
|
173
173
|
edmUtils.assignAnnotation(def, newAnno, def._origin[attr]);
|
|
174
|
-
|
|
174
|
+
transformAnnotationExpression(def._origin, attr, scopeCheck, def._origin.$path);
|
|
175
175
|
if (paramAnnoParts.length > 1)
|
|
176
176
|
delete def._origin[attr];
|
|
177
177
|
}
|
|
@@ -419,7 +419,7 @@ function csn2annotationEdm( reqDefs, reqDefsUtils, csnVocabularies, serviceName,
|
|
|
419
419
|
|
|
420
420
|
knownAnnos.forEach((knownAnno) => {
|
|
421
421
|
if (knownAnno.search(/\.\$edmJson\./g) < 0) {
|
|
422
|
-
|
|
422
|
+
transformAnnotationExpression(carrier, knownAnno, {
|
|
423
423
|
ref: (elemref, prop, xpr, csnPath) => {
|
|
424
424
|
if (options.isV2() && elemref.$bparam) {
|
|
425
425
|
error('odata-anno-xpr-ref', ctx.location, {
|
|
@@ -842,8 +842,8 @@ function csn2annotationEdm( reqDefs, reqDefsUtils, csnVocabularies, serviceName,
|
|
|
842
842
|
* */
|
|
843
843
|
let newAnno;
|
|
844
844
|
const omissions = { 'Aggregation.default': 1 };
|
|
845
|
-
const nullList = { 'Core.OperationAvailable': 1 };
|
|
846
|
-
if (annoValue
|
|
845
|
+
const nullList = { 'Core.OperationAvailable': 1, 'Core.OptionalParameter': 1 };
|
|
846
|
+
if (annoValue != null && !omissions[termName] || nullList[termName]) {
|
|
847
847
|
// termName may contain a qualifier: @UI.FieldGroup#shippingStatus
|
|
848
848
|
// -> remove qualifier from termName and set Qualifier attribute in newAnno
|
|
849
849
|
const i = termName.indexOf('#');
|
|
@@ -989,6 +989,7 @@ function csn2annotationEdm( reqDefs, reqDefsUtils, csnVocabularies, serviceName,
|
|
|
989
989
|
else {
|
|
990
990
|
const res = handleSimpleValue(cAnnoValue, dTypeName, msg);
|
|
991
991
|
if (((oTermName === 'Core.OperationAvailable' && dTypeName === 'Edm.Boolean') ||
|
|
992
|
+
(oTermName === 'Core.OptionalParameter' && dTypeName === 'Edm.String') ||
|
|
992
993
|
(oTermName === 'Validation.AllowedValues' && dTypeName === 'Edm.PrimitiveType')) &&
|
|
993
994
|
cAnnoValue === null) {
|
|
994
995
|
oTarget.append(new Edm.ValueThing(v, 'Null'));
|
|
@@ -1230,7 +1231,10 @@ function csn2annotationEdm( reqDefs, reqDefsUtils, csnVocabularies, serviceName,
|
|
|
1230
1231
|
}
|
|
1231
1232
|
}
|
|
1232
1233
|
else if (value === null) {
|
|
1233
|
-
if ((resolvedType == null ||
|
|
1234
|
+
if ((resolvedType == null ||
|
|
1235
|
+
resolvedType === 'Edm.PrimitiveType' ||
|
|
1236
|
+
resolvedType === 'Edm.String') &&
|
|
1237
|
+
typeName === 'String') {
|
|
1234
1238
|
resolvedType = 'Edm.String';
|
|
1235
1239
|
}
|
|
1236
1240
|
else {
|
|
@@ -1589,7 +1593,7 @@ function csn2annotationEdm( reqDefs, reqDefsUtils, csnVocabularies, serviceName,
|
|
|
1589
1593
|
|
|
1590
1594
|
function filterKnownAnnotations( carrier ) {
|
|
1591
1595
|
const annoNames = Object.keys(carrier).filter( x => x[0] === '@' );
|
|
1592
|
-
const nullWhitelist = [ '@Core.OperationAvailable' ];
|
|
1596
|
+
const nullWhitelist = [ '@Core.OperationAvailable', '@Core.OptionalParameter.DefaultValue' ];
|
|
1593
1597
|
const knownAnnosP = annoNames.filter((n) => {
|
|
1594
1598
|
const tns = whatsMyTermNamespace(n);
|
|
1595
1599
|
return tns &&
|
package/lib/edm/csn2edm.js
CHANGED
|
@@ -266,8 +266,19 @@ function csn2edmAll( _csn, _options, serviceNames, messageFunctions ) {
|
|
|
266
266
|
});
|
|
267
267
|
}
|
|
268
268
|
});
|
|
269
|
+
if (!options.odataNoCreator) {
|
|
270
|
+
// remove unqualified @Core.Links and #CAP
|
|
271
|
+
Object.keys(serviceCsn).forEach((key) => {
|
|
272
|
+
if (key === '@Core.Links' || key.startsWith('@Core.Links.') ||
|
|
273
|
+
key === '@Core.Links#CAP' || key.startsWith('@Core.Links#CAP.'))
|
|
274
|
+
delete serviceCsn[key];
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
|
|
269
278
|
// Create annotations and distribute into Schemas, merge vocabulary cross refs into xServiceRefs
|
|
270
|
-
|
|
279
|
+
addAnnotationsAndXServiceRefs();
|
|
280
|
+
if (!options.odataNoCreator)
|
|
281
|
+
LeadSchema.prepend(waterMark());
|
|
271
282
|
|
|
272
283
|
// Finally add cross service references into the EDM and extract the targetSchemaNames
|
|
273
284
|
// for the type cross check
|
|
@@ -308,6 +319,18 @@ function csn2edmAll( _csn, _options, serviceNames, messageFunctions ) {
|
|
|
308
319
|
|
|
309
320
|
return edm;
|
|
310
321
|
|
|
322
|
+
function waterMark() {
|
|
323
|
+
const rel = new Edm.PropertyValue(v, 'rel');
|
|
324
|
+
rel._xmlOnlyAttributes.String = 'author';
|
|
325
|
+
rel._jsonOnlyAttributes['Edm.String'] = 'author';
|
|
326
|
+
const href = new Edm.PropertyValue(v, 'href');
|
|
327
|
+
href._xmlOnlyAttributes.String = 'https://cap.cloud.sap';
|
|
328
|
+
href._jsonOnlyAttributes['Edm.String'] = 'https://cap.cloud.sap';
|
|
329
|
+
const watermark = new Edm.Annotation(v, 'Core.Links', new Edm.Collection(v, new Edm.Record(v, rel, href)));
|
|
330
|
+
// watermark._edmAttributes['Qualifier'] = 'CAP';
|
|
331
|
+
return watermark;
|
|
332
|
+
}
|
|
333
|
+
|
|
311
334
|
// Sort definitions into their schema container
|
|
312
335
|
function populateSchemas( schemas ) {
|
|
313
336
|
forEach(reqDefs.definitions, ( fqName, art ) => {
|
|
@@ -1099,8 +1122,9 @@ function csn2edmAll( _csn, _options, serviceNames, messageFunctions ) {
|
|
|
1099
1122
|
}
|
|
1100
1123
|
|
|
1101
1124
|
// generate the Edm.Annotations tree and append it to the corresponding schema
|
|
1102
|
-
function
|
|
1125
|
+
function addAnnotationsAndXServiceRefs( ) {
|
|
1103
1126
|
options.getFinalTypeInfo = csnUtils.getFinalTypeInfo;
|
|
1127
|
+
|
|
1104
1128
|
const { annos, usedVocabularies, xrefs } = translate.csn2annotationEdm(reqDefs, csnUtils, csn.vocabularies, serviceCsn.name, Edm, options, messageFunctions, mergedVocabularies);
|
|
1105
1129
|
// distribute edm:Annotations into the schemas
|
|
1106
1130
|
// Distribute each anno into Schema
|
package/lib/edm/edm.js
CHANGED
|
@@ -111,8 +111,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
111
111
|
json.$Kind = this.kind;
|
|
112
112
|
|
|
113
113
|
this.toJSONattributes(json);
|
|
114
|
-
this.toJSONchildren(json);
|
|
115
|
-
return json;
|
|
114
|
+
return this.toJSONchildren(json);
|
|
116
115
|
}
|
|
117
116
|
|
|
118
117
|
// virtual
|
|
@@ -131,6 +130,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
131
130
|
this._children.filter(c => c._edmAttributes.Name).forEach((c) => {
|
|
132
131
|
json[c._edmAttributes.Name] = c.toJSON();
|
|
133
132
|
});
|
|
133
|
+
return json;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
// virtual
|
|
@@ -325,7 +325,12 @@ function getEdm( options, messageFunctions ) {
|
|
|
325
325
|
|
|
326
326
|
toJSONchildren(json) {
|
|
327
327
|
// 'edmx:DataServices' should not appear in JSON
|
|
328
|
-
|
|
328
|
+
// Annotations first
|
|
329
|
+
this._children.filter(c => c._edmAttributes.Term).forEach((c) => {
|
|
330
|
+
json = { ...json, ...c.toJSON() };
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
json = super.toJSONchildren(json);
|
|
329
334
|
if (this._annotations.length > 0) {
|
|
330
335
|
this._annotations.filter(a => a._edmAttributes.Term).forEach((a) => {
|
|
331
336
|
Object.entries(a.toJSON()).forEach(([ n, v ]) => {
|
|
@@ -445,8 +450,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
445
450
|
json.$Reference = referenceJson;
|
|
446
451
|
|
|
447
452
|
this._service.toJSONattributes(json);
|
|
448
|
-
this._service.toJSONchildren(json);
|
|
449
|
-
return json;
|
|
453
|
+
return this._service.toJSONchildren(json);
|
|
450
454
|
}
|
|
451
455
|
|
|
452
456
|
// all(default), metadata, annotations
|
|
@@ -1154,8 +1158,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1154
1158
|
toJSON() {
|
|
1155
1159
|
const json = Object.create(null);
|
|
1156
1160
|
this.toJSONattributes(json);
|
|
1157
|
-
this.toJSONchildren(json);
|
|
1158
|
-
return json;
|
|
1161
|
+
return this.toJSONchildren(json);
|
|
1159
1162
|
}
|
|
1160
1163
|
|
|
1161
1164
|
getConstantExpressionValue() {
|
|
@@ -1226,6 +1229,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1226
1229
|
json[n] = v;
|
|
1227
1230
|
});
|
|
1228
1231
|
});
|
|
1232
|
+
return json;
|
|
1229
1233
|
}
|
|
1230
1234
|
}
|
|
1231
1235
|
|
|
@@ -1242,8 +1246,9 @@ function getEdm( options, messageFunctions ) {
|
|
|
1242
1246
|
// since it was discovered, that in JSON the EnumMember type must be
|
|
1243
1247
|
// transported this is no longer the case....
|
|
1244
1248
|
class Annotation extends AnnotationBase {
|
|
1245
|
-
constructor(version, termName) {
|
|
1249
|
+
constructor(version, termName, ...children) {
|
|
1246
1250
|
super(version, { Term: termName } );
|
|
1251
|
+
this.append(...children);
|
|
1247
1252
|
}
|
|
1248
1253
|
|
|
1249
1254
|
toJSON() {
|
|
@@ -1263,6 +1268,11 @@ function getEdm( options, messageFunctions ) {
|
|
|
1263
1268
|
}
|
|
1264
1269
|
|
|
1265
1270
|
class Collection extends AnnotationBase {
|
|
1271
|
+
constructor(version, ...children) {
|
|
1272
|
+
super(version);
|
|
1273
|
+
this.append(...children);
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1266
1276
|
toJSON() {
|
|
1267
1277
|
// EDM JSON doesn't mention annotations on collections
|
|
1268
1278
|
return this._children.map(a => a.toJSON());
|
|
@@ -1270,6 +1280,10 @@ function getEdm( options, messageFunctions ) {
|
|
|
1270
1280
|
}
|
|
1271
1281
|
|
|
1272
1282
|
class Record extends AnnotationBase {
|
|
1283
|
+
constructor(version, ...children) {
|
|
1284
|
+
super(version);
|
|
1285
|
+
this.append(...children);
|
|
1286
|
+
}
|
|
1273
1287
|
toJSONattributes(json) {
|
|
1274
1288
|
if (this._jsonOnlyAttributes.Type)
|
|
1275
1289
|
json['@type'] = this._jsonOnlyAttributes.Type;
|
|
@@ -1300,6 +1314,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1300
1314
|
error(null, `Pease debug me: Unhandled Record child: ${c.kind}`);
|
|
1301
1315
|
}
|
|
1302
1316
|
});
|
|
1317
|
+
return json;
|
|
1303
1318
|
}
|
|
1304
1319
|
}
|
|
1305
1320
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const { setProp, isBetaEnabled } = require('../base/model');
|
|
4
4
|
const {
|
|
5
5
|
forEachDefinition, forEachMemberRecursively, getUtils,
|
|
6
|
-
|
|
6
|
+
transformAnnotationExpression,
|
|
7
7
|
} = require('../model/csnUtils');
|
|
8
8
|
const { isBuiltinType } = require('../base/builtins');
|
|
9
9
|
const { assignAnnotation } = require('./edmUtils.js');
|
|
@@ -144,14 +144,12 @@ function inboundQualificationChecks( csn, options, messageFunctions,
|
|
|
144
144
|
parent.$bparam = true;
|
|
145
145
|
},
|
|
146
146
|
};
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
transformExpression(action, pn, markBindingParam, loc);
|
|
147
|
+
Object.keys(action).filter(pn => pn[0] === '@').forEach((pn) => {
|
|
148
|
+
transformAnnotationExpression(action, pn, markBindingParam, loc);
|
|
150
149
|
});
|
|
151
150
|
forEachMemberRecursively(action, (member, _memberName, _prop, path, _parent) => {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
transformExpression(member, pn, markBindingParam, path);
|
|
151
|
+
Object.keys(member).filter(pn => pn[0] === '@').forEach((pn) => {
|
|
152
|
+
transformAnnotationExpression(member, pn, markBindingParam, path);
|
|
155
153
|
});
|
|
156
154
|
}, loc);
|
|
157
155
|
}
|
|
@@ -5,7 +5,7 @@ const { setProp, isDeprecatedEnabled, isBetaEnabled } = require('../base/model')
|
|
|
5
5
|
const {
|
|
6
6
|
forEachDefinition, forEachGeneric, forEachMemberRecursively,
|
|
7
7
|
isEdmPropertyRendered, getUtils,
|
|
8
|
-
applyTransformations,
|
|
8
|
+
applyTransformations, transformAnnotationExpression, findAnnotationExpression,
|
|
9
9
|
cardinality2str,
|
|
10
10
|
} = require('../model/csnUtils');
|
|
11
11
|
const { isBuiltinType, isMagicVariable } = require('../base/builtins');
|
|
@@ -1890,12 +1890,12 @@ function initializeModel( csn, _options, messageFunctions, requestedServiceNames
|
|
|
1890
1890
|
mapCdsToEdmProp(def.returns);
|
|
1891
1891
|
annotateAllowedValues(def.returns, [ ...defLocation, 'returns' ]);
|
|
1892
1892
|
}
|
|
1893
|
-
forEachMemberRecursively(def, (member, _memberName,
|
|
1893
|
+
forEachMemberRecursively(def, (member, _memberName, prop, location) => {
|
|
1894
1894
|
edmUtils.assignAnnotation(member, '@Core.Description', member.doc);
|
|
1895
1895
|
markCollection(member);
|
|
1896
1896
|
mapCdsToEdmProp(member);
|
|
1897
1897
|
annotateAllowedValues(member, location);
|
|
1898
|
-
ComputedDefaultValue(member);
|
|
1898
|
+
ComputedDefaultValue(member, prop, location);
|
|
1899
1899
|
rewriteAnnotationExpressions(member);
|
|
1900
1900
|
if (member.returns) {
|
|
1901
1901
|
edmUtils.assignAnnotation(member.returns, '@Core.Description', member.returns.doc);
|
|
@@ -2082,8 +2082,6 @@ function initializeModel( csn, _options, messageFunctions, requestedServiceNames
|
|
|
2082
2082
|
parameters appear rightmost.
|
|
2083
2083
|
*/
|
|
2084
2084
|
function annotateOptionalActFuncParams( def, defName ) {
|
|
2085
|
-
if (!isBetaEnabled(options, 'optionalActionFunctionParameters'))
|
|
2086
|
-
return;
|
|
2087
2085
|
// return if there is nothing to do
|
|
2088
2086
|
const loc = [ 'definitions', defName ];
|
|
2089
2087
|
if (def.kind === 'function' || def.kind === 'action')
|
|
@@ -2098,32 +2096,43 @@ function initializeModel( csn, _options, messageFunctions, requestedServiceNames
|
|
|
2098
2096
|
function iterateParams( action, location ) {
|
|
2099
2097
|
let optPns = [];
|
|
2100
2098
|
if (action.params) {
|
|
2101
|
-
Object.
|
|
2099
|
+
Object.entries(action.params).forEach(([ pn, p ]) => {
|
|
2102
2100
|
// user assigned annotation, don't touch it
|
|
2101
|
+
const defT = reqDefs.definitions[p.items?.type || p.type];
|
|
2102
|
+
const isStructType = !!(defT?.items?.elements || defT?.elements);
|
|
2103
|
+
const isItems = !!(p.items || defT?.items);
|
|
2104
|
+
|
|
2103
2105
|
if (Object.keys(p).some(a => a.startsWith('@Core.OptionalParameter') && p[a] !== null)) {
|
|
2104
2106
|
optPns.push(p);
|
|
2105
2107
|
}
|
|
2106
2108
|
// default value automatically makes param optional
|
|
2107
|
-
else if (
|
|
2108
|
-
if (p.default
|
|
2109
|
-
|
|
2110
|
-
|
|
2109
|
+
else if (isBetaEnabled(options, 'optionalActionFunctionParameters')) {
|
|
2110
|
+
if (p.default?.val !== undefined) {
|
|
2111
|
+
if (p.default.val !== null && (isStructType || isItems)) {
|
|
2112
|
+
warning('odata-ignoring-param-default', location.concat(pn), { '#': 'colitem' });
|
|
2113
|
+
}
|
|
2114
|
+
else {
|
|
2115
|
+
edmUtils.assignAnnotation(p, '@Core.OptionalParameter.DefaultValue', p.default.val);
|
|
2116
|
+
optPns.push(p);
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
// if no default is available, nullable makes param optional
|
|
2120
|
+
else if (!p.notNull) {
|
|
2111
2121
|
edmUtils.assignAnnotation(p, '@Core.OptionalParameter.$Type', '');
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2122
|
+
optPns.push(p);
|
|
2123
|
+
}
|
|
2124
|
+
else {
|
|
2125
|
+
// this is a mandatory parameter, warn about all previously collected optional parameters
|
|
2126
|
+
optPns.forEach((op) => {
|
|
2127
|
+
const type = op.items?.type || op.type;
|
|
2128
|
+
if (type !== special$self)
|
|
2129
|
+
error('odata-parameter-order', location.concat(op.name));
|
|
2130
|
+
});
|
|
2131
|
+
optPns = [];
|
|
2132
|
+
}
|
|
2118
2133
|
}
|
|
2119
|
-
else {
|
|
2120
|
-
|
|
2121
|
-
optPns.forEach((op) => {
|
|
2122
|
-
const type = op.items?.type || op.type;
|
|
2123
|
-
if (type !== special$self)
|
|
2124
|
-
error('odata-parameter-order', location.concat(op.name));
|
|
2125
|
-
});
|
|
2126
|
-
optPns = [];
|
|
2134
|
+
else if (p.default) {
|
|
2135
|
+
warning('odata-ignoring-param-default', location.concat(pn));
|
|
2127
2136
|
}
|
|
2128
2137
|
});
|
|
2129
2138
|
}
|
|
@@ -2152,7 +2161,7 @@ function initializeModel( csn, _options, messageFunctions, requestedServiceNames
|
|
|
2152
2161
|
}
|
|
2153
2162
|
}
|
|
2154
2163
|
|
|
2155
|
-
function ComputedDefaultValue( member ) {
|
|
2164
|
+
function ComputedDefaultValue( member, prop, location ) {
|
|
2156
2165
|
if (member.default && !csn['@Core.ComputedDefaultValue']) {
|
|
2157
2166
|
let def = member.default;
|
|
2158
2167
|
let noTailExpr = false;
|
|
@@ -2166,8 +2175,12 @@ function initializeModel( csn, _options, messageFunctions, requestedServiceNames
|
|
|
2166
2175
|
def = def.xpr[i];
|
|
2167
2176
|
}
|
|
2168
2177
|
// it is a computed value if it is not a simple value or an annotation
|
|
2169
|
-
if (!((def.val !== undefined && !noTailExpr) || def['#']))
|
|
2170
|
-
|
|
2178
|
+
if (!((def.val !== undefined && !noTailExpr) || def['#'])) {
|
|
2179
|
+
if (prop === 'params')
|
|
2180
|
+
warning('odata-ignoring-param-default', location, { '#': 'xpr' });
|
|
2181
|
+
else
|
|
2182
|
+
edmUtils.assignAnnotation(member, '@Core.ComputedDefaultValue', true);
|
|
2183
|
+
}
|
|
2171
2184
|
}
|
|
2172
2185
|
}
|
|
2173
2186
|
|
|
@@ -2258,13 +2271,13 @@ function initializeModel( csn, _options, messageFunctions, requestedServiceNames
|
|
|
2258
2271
|
|
|
2259
2272
|
xprANames.forEach((xprAName) => {
|
|
2260
2273
|
isSubTreeSpan = true;
|
|
2261
|
-
|
|
2274
|
+
transformAnnotationExpression(carrier, xprAName, subTreeSpan);
|
|
2262
2275
|
if (isSubTreeSpan) {
|
|
2263
|
-
|
|
2276
|
+
transformAnnotationExpression(carrier, xprAName, relativize);
|
|
2264
2277
|
}
|
|
2265
2278
|
else {
|
|
2266
2279
|
absolutize.scope = scope;
|
|
2267
|
-
|
|
2280
|
+
transformAnnotationExpression(carrier, xprAName, absolutize);
|
|
2268
2281
|
if (!def[proxyDict])
|
|
2269
2282
|
setProp(def, proxyDict, Object.create(null));
|
|
2270
2283
|
let proxyCarrier = def[proxyDict][eltPath];
|