@sap/cds-compiler 2.15.2 → 3.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 +66 -1590
- package/bin/cdsc.js +42 -46
- package/doc/CHANGELOG_ARCHIVE.md +1592 -0
- package/doc/CHANGELOG_BETA.md +3 -4
- package/doc/CHANGELOG_DEPRECATED.md +35 -1
- package/doc/{DeprecatedOptions.md → DeprecatedOptions_v2.md} +3 -1
- package/doc/Versioning.md +20 -1
- package/lib/api/.eslintrc.json +2 -2
- package/lib/api/main.js +312 -143
- package/lib/api/options.js +15 -85
- package/lib/api/validate.js +6 -10
- package/lib/base/keywords.js +280 -110
- package/lib/base/message-registry.js +80 -24
- package/lib/base/messages.js +103 -52
- package/lib/base/model.js +44 -2
- package/lib/base/optionProcessorHelper.js +53 -21
- package/lib/checks/actionsFunctions.js +7 -5
- package/lib/checks/annotationsOData.js +1 -1
- package/lib/checks/cdsPersistence.js +1 -0
- package/lib/checks/elements.js +6 -6
- package/lib/checks/invalidTarget.js +1 -1
- package/lib/checks/nonexpandableStructured.js +1 -1
- package/lib/checks/queryNoDbArtifacts.js +2 -1
- package/lib/checks/selectItems.js +5 -1
- package/lib/checks/types.js +4 -2
- package/lib/checks/utils.js +2 -2
- package/lib/checks/validator.js +2 -1
- package/lib/compiler/assert-consistency.js +15 -10
- package/lib/compiler/builtins.js +127 -10
- package/lib/compiler/define.js +6 -4
- package/lib/compiler/extend.js +63 -12
- package/lib/compiler/finalize-parse-cdl.js +20 -9
- package/lib/compiler/index.js +25 -11
- package/lib/compiler/moduleLayers.js +7 -0
- package/lib/compiler/populate.js +16 -14
- package/lib/compiler/propagator.js +3 -3
- package/lib/compiler/resolve.js +194 -222
- package/lib/compiler/shared.js +56 -76
- package/lib/compiler/tweak-assocs.js +9 -10
- package/lib/compiler/utils.js +7 -2
- package/lib/edm/annotations/genericTranslation.js +60 -6
- package/lib/edm/annotations/preprocessAnnotations.js +10 -11
- package/lib/edm/csn2edm.js +39 -41
- package/lib/edm/edm.js +22 -15
- package/lib/edm/edmPreprocessor.js +66 -69
- package/lib/edm/edmUtils.js +12 -62
- package/lib/gen/Dictionary.json +8 -6
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +8 -30
- package/lib/gen/language.tokens +105 -114
- package/lib/gen/languageLexer.interp +1 -34
- package/lib/gen/languageLexer.js +889 -1007
- package/lib/gen/languageLexer.tokens +95 -106
- package/lib/gen/languageParser.js +20717 -22376
- package/lib/json/from-csn.js +73 -68
- package/lib/json/to-csn.js +13 -10
- package/lib/language/antlrParser.js +2 -2
- package/lib/language/docCommentParser.js +61 -38
- package/lib/language/errorStrategy.js +52 -40
- package/lib/language/genericAntlrParser.js +333 -259
- package/lib/language/language.g4 +600 -645
- package/lib/language/multiLineStringParser.js +14 -42
- package/lib/language/textUtils.js +44 -0
- package/lib/main.d.ts +27 -42
- package/lib/main.js +104 -81
- package/lib/model/csnRefs.js +2 -1
- package/lib/model/csnUtils.js +183 -285
- package/lib/model/revealInternalProperties.js +32 -9
- package/lib/model/sortViews.js +32 -31
- package/lib/optionProcessor.js +64 -57
- package/lib/render/.eslintrc.json +1 -1
- package/lib/render/DuplicateChecker.js +4 -7
- package/lib/render/manageConstraints.js +70 -2
- package/lib/render/toCdl.js +334 -339
- package/lib/render/toHdbcds.js +20 -16
- package/lib/render/toRename.js +44 -22
- package/lib/render/toSql.js +60 -54
- package/lib/render/utils/common.js +15 -1
- package/lib/render/utils/sql.js +20 -19
- package/lib/sql-identifier.js +6 -0
- package/lib/transform/db/.eslintrc.json +3 -2
- package/lib/transform/db/cdsPersistence.js +5 -15
- package/lib/transform/db/constraints.js +1 -1
- package/lib/transform/db/expansion.js +7 -6
- package/lib/transform/db/flattening.js +18 -19
- package/lib/transform/db/views.js +3 -3
- package/lib/transform/draft/.eslintrc.json +2 -2
- package/lib/transform/draft/db.js +6 -6
- package/lib/transform/draft/odata.js +6 -7
- package/lib/transform/forHanaNew.js +19 -22
- package/lib/transform/forOdataNew.js +13 -15
- package/lib/transform/localized.js +35 -25
- package/lib/transform/odata/toFinalBaseType.js +11 -9
- package/lib/transform/odata/typesExposure.js +3 -3
- package/lib/transform/odata/utils.js +1 -38
- package/lib/transform/transformUtilsNew.js +63 -77
- package/lib/transform/translateAssocsToJoins.js +6 -2
- package/lib/transform/universalCsn/.eslintrc.json +2 -2
- package/lib/transform/universalCsn/coreComputed.js +11 -6
- package/lib/transform/universalCsn/universalCsnEnricher.js +33 -5
- package/lib/utils/file.js +31 -21
- package/lib/utils/timetrace.js +20 -21
- package/package.json +34 -4
- package/share/messages/syntax-expected-integer.md +9 -8
- package/doc/ApiMigration.md +0 -237
- package/doc/CommandLineMigration.md +0 -58
- package/doc/ErrorMessages.md +0 -175
- package/doc/FioriAnnotations.md +0 -94
- package/doc/ODataTransformation.md +0 -273
- package/lib/backends.js +0 -529
- package/lib/fix_antlr4-8_warning.js +0 -56
package/lib/edm/csn2edm.js
CHANGED
|
@@ -14,7 +14,7 @@ const { cloneCsnNonDict, isEdmPropertyRendered, isBuiltinType } = require('../mo
|
|
|
14
14
|
const { checkCSNVersion } = require('../json/csnVersion');
|
|
15
15
|
const { makeMessageFunction } = require('../base/messages');
|
|
16
16
|
const { EdmTypeFacetMap, EdmTypeFacetNames, EdmPrimitiveTypeMap, getEdm } = require('./edm.js');
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
/*
|
|
19
19
|
OData V2 spec 06/01/2017 PDF version is available from here:
|
|
20
20
|
https://msdn.microsoft.com/en-us/library/dd541474.aspx
|
|
@@ -330,11 +330,12 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
330
330
|
Entity starts with 'localserviceNameized.' or ends with '_localized'
|
|
331
331
|
*/
|
|
332
332
|
edmUtils.foreach(schemaCsn.definitions,
|
|
333
|
-
a =>
|
|
333
|
+
a => a.kind === 'entity' && !a.abstract && a.name.startsWith(schemaNamePrefix),
|
|
334
334
|
createEntityTypeAndSet
|
|
335
335
|
);
|
|
336
336
|
// create unbound actions/functions
|
|
337
|
-
edmUtils.foreach(schemaCsn.definitions,
|
|
337
|
+
edmUtils.foreach(schemaCsn.definitions,
|
|
338
|
+
a => (a.kind === 'action' || a.kind === 'function') && a.name.startsWith(schemaNamePrefix),
|
|
338
339
|
(options.isV4()) ? createActionV4 : createActionV2);
|
|
339
340
|
|
|
340
341
|
// create the complex types
|
|
@@ -346,7 +347,7 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
346
347
|
{
|
|
347
348
|
edmUtils.foreach(schemaCsn.definitions,
|
|
348
349
|
artifact => edmUtils.isDerivedType(artifact) &&
|
|
349
|
-
!
|
|
350
|
+
!artifact.target &&
|
|
350
351
|
artifact.name.startsWith(schemaNamePrefix),
|
|
351
352
|
createTypeDefinition);
|
|
352
353
|
}
|
|
@@ -395,14 +396,14 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
395
396
|
{
|
|
396
397
|
const EntityTypeName = entityCsn.name.replace(schemaNamePrefix, '');
|
|
397
398
|
const EntitySetName = edmUtils.getBaseName(entityCsn.$entitySetName || entityCsn.name);
|
|
398
|
-
|
|
399
|
+
const isSingleton = edmUtils.isSingleton(entityCsn) && options.isV4();
|
|
399
400
|
const [ properties, hasStream ] = createProperties(entityCsn);
|
|
400
401
|
|
|
401
402
|
const loc = ['definitions', entityCsn.name];
|
|
402
403
|
const type = `${schema.name}.${EntityTypeName}`;
|
|
403
404
|
if(properties.length === 0)
|
|
404
405
|
warning(null, loc, { type }, 'EDM EntityType $(TYPE) has no properties');
|
|
405
|
-
else if(entityCsn.$edmKeyPaths.length === 0)
|
|
406
|
+
else if(entityCsn.$edmKeyPaths.length === 0 && !isSingleton)
|
|
406
407
|
message('odata-spec-violation-no-key', loc);
|
|
407
408
|
|
|
408
409
|
if(!edmUtils.isODataSimpleIdentifier(EntityTypeName))
|
|
@@ -414,14 +415,14 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
414
415
|
if(p._edmAttributes.Name === EntityTypeName)
|
|
415
416
|
warning('odata-spec-violation-property-name', pLoc, { kind: entityCsn.kind });
|
|
416
417
|
|
|
417
|
-
if(options.isV2() && p._isCollection && !
|
|
418
|
+
if(options.isV2() && p._isCollection && !p._csn.target)
|
|
418
419
|
warning('odata-spec-violation-array', pLoc, { version: '2.0' });
|
|
419
420
|
|
|
420
421
|
if(!edmUtils.isODataSimpleIdentifier(p._edmAttributes.Name))
|
|
421
422
|
message('odata-spec-violation-id', pLoc, { id: p._edmAttributes.Name });
|
|
422
423
|
else if (options.isV2() && /^(_|[0-9])/.test(p._edmAttributes.Name)) {
|
|
423
424
|
// FIXME: Rewrite signalIllegalIdentifier function to be more flexible
|
|
424
|
-
|
|
425
|
+
message('odata-spec-violation-id', pLoc,
|
|
425
426
|
{ prop: p._edmAttributes.Name[0], id: p._edmAttributes.Name, version: '2.0', '#': 'v2firstchar' });
|
|
426
427
|
}
|
|
427
428
|
});
|
|
@@ -461,7 +462,7 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
461
462
|
}
|
|
462
463
|
|
|
463
464
|
// put actions behind entity types in Schema/EntityContainer
|
|
464
|
-
|
|
465
|
+
entityCsn.actions && Object.entries(entityCsn.actions).forEach(([ n, a ]) => {
|
|
465
466
|
(options.isV4()) ? createActionV4(a, n, entityCsn)
|
|
466
467
|
: createActionV2(a, n, entityCsn)
|
|
467
468
|
});
|
|
@@ -522,7 +523,7 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
522
523
|
}
|
|
523
524
|
|
|
524
525
|
// Parameter Nodes
|
|
525
|
-
|
|
526
|
+
actionCsn.params && Object.entries(actionCsn.params).forEach(([parameterName, parameterCsn]) => {
|
|
526
527
|
const p = new Edm.Parameter(v, { Name: parameterName }, parameterCsn );
|
|
527
528
|
const pLoc = [ ...loc, 'params', p._edmAttributes.Name ];
|
|
528
529
|
if(!edmUtils.isODataSimpleIdentifier(parameterName))
|
|
@@ -573,7 +574,7 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
573
574
|
if(rt) // add EntitySet attribute only if return type is an entity
|
|
574
575
|
{
|
|
575
576
|
const defintion = schemaCsn.definitions[rt];
|
|
576
|
-
if(defintion &&
|
|
577
|
+
if(defintion && defintion.kind === 'entity')
|
|
577
578
|
{
|
|
578
579
|
functionImport.setEdmAttribute('EntitySet', rt.replace(schemaNamePrefix, ''));
|
|
579
580
|
}
|
|
@@ -597,7 +598,7 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
597
598
|
// Binding Parameter: Primary Keys at first position in sequence, this is decisive!
|
|
598
599
|
// V2 XML: Nullable=false is set because we reuse the primary key property for the parameter
|
|
599
600
|
edmUtils.foreach(entityCsn.elements,
|
|
600
|
-
elementCsn => elementCsn.key && !
|
|
601
|
+
elementCsn => elementCsn.key && !elementCsn.target,
|
|
601
602
|
(elementCsn, elementName) => {
|
|
602
603
|
functionImport.append(new Edm.Parameter(v, { Name: elementName }, elementCsn, 'In' ));
|
|
603
604
|
}
|
|
@@ -605,7 +606,7 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
605
606
|
}
|
|
606
607
|
|
|
607
608
|
// is this still required?
|
|
608
|
-
|
|
609
|
+
Object.entries(actionCsn).forEach(([p, v]) => {
|
|
609
610
|
if (p.match(/^@sap\./))
|
|
610
611
|
functionImport.setXml( { ['sap:' + p.slice(5).replace(/\./g, '-')] : v });
|
|
611
612
|
});
|
|
@@ -613,7 +614,7 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
613
614
|
// V2 XML: Parameters that are not explicitly marked as Nullable or NotNullable in the CSN must become Nullable=true
|
|
614
615
|
// V2 XML spec does only mention default Nullable=true for Properties not for Parameters so omitting Nullable=true let
|
|
615
616
|
// the client assume that Nullable is false.... Correct Nullable Handling is done inside Parameter constructor
|
|
616
|
-
|
|
617
|
+
actionCsn.params && Object.entries(actionCsn.params).forEach(([parameterName, parameterCsn]) => {
|
|
617
618
|
const pLoc = [...loc, 'params', parameterName];
|
|
618
619
|
const param = new Edm.Parameter(v, { Name: parameterName }, parameterCsn, 'In' );
|
|
619
620
|
edmTypeCompatibilityCheck(param, pLoc);
|
|
@@ -621,9 +622,9 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
621
622
|
message('odata-spec-violation-id', pLoc, { id: parameterName });
|
|
622
623
|
|
|
623
624
|
// only scalar or structured type in V2 (not entity)
|
|
624
|
-
if(param._type &&
|
|
625
|
-
!param._type.startsWith('Edm.') &&
|
|
626
|
-
csn.definitions[param._type] &&
|
|
625
|
+
if(param._type &&
|
|
626
|
+
!param._type.startsWith('Edm.') &&
|
|
627
|
+
csn.definitions[param._type] &&
|
|
627
628
|
!edmUtils.isStructuredType(csn.definitions[param._type]))
|
|
628
629
|
warning('odata-spec-violation-param', pLoc, { version: '2.0' });
|
|
629
630
|
|
|
@@ -683,14 +684,12 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
683
684
|
let hasStream = false;
|
|
684
685
|
const streamProps = [];
|
|
685
686
|
|
|
686
|
-
|
|
687
|
+
elementsCsn.elements && Object.entries(elementsCsn.elements).forEach(([elementName, elementCsn]) =>
|
|
687
688
|
{
|
|
688
689
|
if(elementCsn._edmParentCsn == undefined)
|
|
689
690
|
setProp(elementCsn, '_edmParentCsn', edmParentCsn);
|
|
690
691
|
|
|
691
|
-
if(
|
|
692
|
-
if(edmUtils.isAssociationOrComposition(elementCsn))
|
|
693
|
-
{
|
|
692
|
+
if(elementCsn.target) {
|
|
694
693
|
// Foreign keys are part of the generic elementCsn.elements property creation
|
|
695
694
|
|
|
696
695
|
// This is the V4 edmx:NavigationProperty
|
|
@@ -698,36 +697,35 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
698
697
|
|
|
699
698
|
// suppress navprop creation only if @odata.navigable:false is not annotated.
|
|
700
699
|
// (undefined !== false) still evaluates to true
|
|
701
|
-
|
|
700
|
+
if (!elementCsn._target.abstract && elementCsn['@odata.navigable'] !== false)
|
|
702
701
|
{
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
702
|
+
const navProp = new Edm.NavigationProperty(v, {
|
|
703
|
+
Name: elementName,
|
|
704
|
+
Type: elementCsn._target.name
|
|
705
|
+
}, elementCsn);
|
|
706
|
+
props.push(navProp);
|
|
708
707
|
// save the navProp in the global array for late constraint building
|
|
709
|
-
|
|
710
|
-
}
|
|
708
|
+
navigationProperties.push(navProp);
|
|
711
709
|
}
|
|
710
|
+
}
|
|
712
711
|
// render ordinary property if element is NOT ...
|
|
713
712
|
// 1) ... annotated @cds.api.ignore
|
|
714
713
|
// 2) ... annotated @odata.foreignKey4 and odataFormat: structured
|
|
715
714
|
|
|
716
|
-
|
|
715
|
+
else if(isEdmPropertyRendered(elementCsn, options))
|
|
717
716
|
{
|
|
718
717
|
// CDXCORE-CDXCORE-173
|
|
719
718
|
// V2: filter @Core.MediaType
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
719
|
+
if ( options.isV2() && elementCsn['@Core.MediaType']) {
|
|
720
|
+
hasStream = elementCsn['@Core.MediaType'];
|
|
721
|
+
delete elementCsn['@Core.MediaType'];
|
|
723
722
|
// CDXCORE-CDXCORE-177:
|
|
724
723
|
// V2: don't render element but add attribute 'm:HasStream="true' to EntityType
|
|
725
724
|
// V4: render property type 'Edm.Stream'
|
|
726
|
-
|
|
725
|
+
streamProps.push(elementName);
|
|
727
726
|
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
}
|
|
727
|
+
} else {
|
|
728
|
+
props.push(new Edm.Property(v, { Name: elementName }, elementCsn));
|
|
731
729
|
}
|
|
732
730
|
}
|
|
733
731
|
|
|
@@ -772,10 +770,10 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
772
770
|
message('odata-spec-violation-id', pLoc, { id: p._edmAttributes.Name });
|
|
773
771
|
|
|
774
772
|
if(options.isV2()) {
|
|
775
|
-
if(p._isCollection && !
|
|
773
|
+
if(p._isCollection && !p._csn.target)
|
|
776
774
|
warning('odata-spec-violation-array', pLoc, { version: '2.0' });
|
|
777
775
|
|
|
778
|
-
if(
|
|
776
|
+
if(p._csn.target)
|
|
779
777
|
warning('odata-spec-violation-assoc', pLoc, { version: '2.0' });
|
|
780
778
|
}
|
|
781
779
|
});
|
|
@@ -933,7 +931,7 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
933
931
|
|
|
934
932
|
// generate the Edm.Annotations tree and append it to the corresponding schema
|
|
935
933
|
function addAnnotations() {
|
|
936
|
-
let { annos, usedVocabularies } = translate.csn2annotationEdm(
|
|
934
|
+
let { annos, usedVocabularies } = translate.csn2annotationEdm(reqDefs, serviceCsn.name, Edm, options, messageFunctions);
|
|
937
935
|
// distribute edm:Annotations into the schemas
|
|
938
936
|
// Distribute each anno into Schema
|
|
939
937
|
annos.forEach(anno => {
|
|
@@ -990,7 +988,7 @@ function csn2edmAll(_csn, _options, serviceNames=undefined) {
|
|
|
990
988
|
});
|
|
991
989
|
}
|
|
992
990
|
else {
|
|
993
|
-
message('odata-spec-violation-type-unknown', pLoc,
|
|
991
|
+
message('odata-spec-violation-type-unknown', pLoc,
|
|
994
992
|
{ type:edmType });
|
|
995
993
|
}
|
|
996
994
|
}
|
package/lib/edm/edm.js
CHANGED
|
@@ -54,7 +54,7 @@ const EdmPrimitiveTypeMap = {
|
|
|
54
54
|
'Edm.GeometryMultiLineString': { v4: true, SRID: true, desc: 'Collection of line strings in a flat-earth coordinate system' },
|
|
55
55
|
'Edm.GeometryMultiPolygon': { v4: true, SRID: true, desc: 'Collection of polygons in a flat-earth coordinate system' },
|
|
56
56
|
'Edm.GeometryCollection': { v4: true, SRID: true, desc: 'Collection of arbitrary Geometry values' },
|
|
57
|
-
|
|
57
|
+
'Edm.PrimitiveType': { v4: true, desc: 'Abstract meta type' },
|
|
58
58
|
//'Edm.Untyped': { v4: true, desc: 'Abstract void type' },
|
|
59
59
|
};
|
|
60
60
|
|
|
@@ -239,7 +239,7 @@ function getEdm(options, messageFunctions) {
|
|
|
239
239
|
if(csn)
|
|
240
240
|
{
|
|
241
241
|
const attr = (useSetAttributes ? csn._SetAttributes : csn);
|
|
242
|
-
|
|
242
|
+
attr && Object.entries(attr).forEach(([p, v]) => {
|
|
243
243
|
if (p.match(/^@sap./))
|
|
244
244
|
this.setXml( { ['sap:' + p.slice(5).replace(/\./g, '-')] : v } );
|
|
245
245
|
});
|
|
@@ -332,7 +332,7 @@ function getEdm(options, messageFunctions) {
|
|
|
332
332
|
if(what==='metadata' || what==='all')
|
|
333
333
|
{
|
|
334
334
|
xml += super.innerXML(indent);
|
|
335
|
-
|
|
335
|
+
this._actions && Object.values(this._actions).forEach(actionArray => {
|
|
336
336
|
actionArray.forEach(action => {
|
|
337
337
|
xml += action.toXML(indent, what) + '\n'; });
|
|
338
338
|
});
|
|
@@ -350,7 +350,7 @@ function getEdm(options, messageFunctions) {
|
|
|
350
350
|
// no $Namespace
|
|
351
351
|
toJSONattributes(json)
|
|
352
352
|
{
|
|
353
|
-
|
|
353
|
+
this._edmAttributes && Object.entries(this._edmAttributes).forEach(([p, v]) => {
|
|
354
354
|
if (p !== 'Name' && p !== 'Namespace')
|
|
355
355
|
json[p[0] === '@' ? p : '$' + p] = v;
|
|
356
356
|
});
|
|
@@ -371,7 +371,7 @@ function getEdm(options, messageFunctions) {
|
|
|
371
371
|
if(Object.keys(json_Annotations).length)
|
|
372
372
|
json['$Annotations'] = json_Annotations;
|
|
373
373
|
}
|
|
374
|
-
|
|
374
|
+
this._actions && Object.entries(this._actions).forEach(([actionName, actionArray]) => {
|
|
375
375
|
json[actionName] = [];
|
|
376
376
|
actionArray.forEach(action => {
|
|
377
377
|
json[actionName].push(action.toJSON());
|
|
@@ -737,7 +737,7 @@ function getEdm(options, messageFunctions) {
|
|
|
737
737
|
if(this._type !== 'Edm.String' && this._type) // Edm.String is default)
|
|
738
738
|
json['$'+this._typeName] = this._type;
|
|
739
739
|
|
|
740
|
-
|
|
740
|
+
this._edmAttributes && Object.entries(this._edmAttributes).forEach(([p, v]) => {
|
|
741
741
|
if (p !== 'Name' && p !== this._typeName
|
|
742
742
|
// remove this line if Nullable=true becomes default
|
|
743
743
|
&& !(p === 'Nullable' && v == false))
|
|
@@ -840,8 +840,8 @@ function getEdm(options, messageFunctions) {
|
|
|
840
840
|
super(v, attributes, csn);
|
|
841
841
|
|
|
842
842
|
// array of enum not yet allowed
|
|
843
|
-
|
|
844
|
-
|
|
843
|
+
const enumValues = /*(csn.items && csn.items.enum) ||*/ csn.enum;
|
|
844
|
+
enumValues && Object.entries(enumValues).forEach(([en, e]) => {
|
|
845
845
|
this.append(new Member(v, { Name: en, Value: e.val } ));
|
|
846
846
|
});
|
|
847
847
|
}
|
|
@@ -1177,9 +1177,10 @@ function getEdm(options, messageFunctions) {
|
|
|
1177
1177
|
_constraints = this._csn._constraints._partnerCsn._constraints;
|
|
1178
1178
|
[i,j] = [1,0];
|
|
1179
1179
|
}
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1180
|
+
_constraints.constraints && Object.values(_constraints.constraints).forEach(c =>
|
|
1181
|
+
this.append(new ReferentialConstraint(this._v,
|
|
1182
|
+
{ Property: c[i].join(options.pathDelimiter), ReferencedProperty: c[j].join(options.pathDelimiter) } ) )
|
|
1183
|
+
);
|
|
1183
1184
|
}
|
|
1184
1185
|
}
|
|
1185
1186
|
|
|
@@ -1223,9 +1224,15 @@ function getEdm(options, messageFunctions) {
|
|
|
1223
1224
|
// short form: key: value
|
|
1224
1225
|
const inlineConstExpr =
|
|
1225
1226
|
[ 'Edm.Binary', 'Edm.Boolean', 'Edm.Byte', 'Edm.Date', 'Edm.DateTimeOffset', 'Edm.Decimal', 'Edm.Double', 'Edm.Duration', 'Edm.Guid',
|
|
1226
|
-
'Edm.Int16', 'Edm.Int32', 'Edm.Int64', 'Edm.SByte','Edm.Single',
|
|
1227
|
+
'Edm.Int16', 'Edm.Int32', 'Edm.Int64', 'Edm.SByte','Edm.Single', 'Edm.Stream', 'Edm.String', 'Edm.TimeOfDay',
|
|
1228
|
+
// Edm.Geo* according to https://issues.oasis-open.org/browse/ODATA-1323
|
|
1229
|
+
/* 'Edm.Geography', 'Edm.GeographyPoint', 'Edm.GeographyLineString', 'Edm.GeographyPolygon', 'Edm.GeographyMultiPoint',
|
|
1230
|
+
'Edm.GeographyMultiLineString', 'Edm.GeographyMultiPolygon', 'Edm.GeographyCollection', 'Edm.Geometry', 'Edm.GeometryPoint',
|
|
1231
|
+
'Edm.GeometryLineString', 'Edm.GeometryPolygon', 'Edm.GeometryMultiPoint', 'Edm.GeometryMultiLineString', 'Edm.GeometryMultiPolygon',
|
|
1232
|
+
'Edm.GeometryCollection',
|
|
1233
|
+
*/
|
|
1227
1234
|
/* UI.xml: defines Annotations with generic type 'Edm.PrimitiveType' */
|
|
1228
|
-
'Edm.PrimitiveType', 'Bool',
|
|
1235
|
+
'Edm.PrimitiveType', 'Edm.Untyped', 'Bool',
|
|
1229
1236
|
// Official JSON V4.01 Spec defines these paths as constant inline expression:
|
|
1230
1237
|
'AnnotationPath', 'ModelElementPath', 'NavigationPropertyPath', 'PropertyPath',
|
|
1231
1238
|
];
|
|
@@ -1496,7 +1503,7 @@ function getEdm(options, messageFunctions) {
|
|
|
1496
1503
|
}
|
|
1497
1504
|
toJSONattributes(json) {
|
|
1498
1505
|
super.toJSONattributes(json);
|
|
1499
|
-
|
|
1506
|
+
this._jsonOnlyAttributes && Object.entries(this._jsonOnlyAttributes).forEach(([p, v]) => {
|
|
1500
1507
|
json[p[0] === '@' ? p : '$' + p] = v;
|
|
1501
1508
|
});
|
|
1502
1509
|
return json;
|
|
@@ -1600,7 +1607,7 @@ function getEdm(options, messageFunctions) {
|
|
|
1600
1607
|
node._d = new Dependent(v, { Role: from } );
|
|
1601
1608
|
node._p = new Principal(v, { Role: to } );
|
|
1602
1609
|
|
|
1603
|
-
|
|
1610
|
+
c && Object.values(c).forEach(cv => {
|
|
1604
1611
|
node._d.append(new PropertyRef(v, cv[0].join(options.pathDelimiter)));
|
|
1605
1612
|
node._p.append(new PropertyRef(v, cv[1].join(options.pathDelimiter)));
|
|
1606
1613
|
});
|