@sap/cds-compiler 5.8.2 → 5.9.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 +31 -0
- package/bin/cds_remove_invalid_whitespace.js +5 -3
- package/bin/cds_update_identifiers.js +9 -6
- package/bin/cdsc.js +79 -59
- package/bin/cdsse.js +14 -10
- package/bin/cdsv2m.js +3 -1
- package/lib/api/options.js +28 -6
- package/lib/base/message-registry.js +15 -4
- package/lib/checks/validator.js +3 -0
- package/lib/compiler/base.js +1 -1
- package/lib/compiler/checks.js +70 -50
- package/lib/compiler/extend.js +1 -1
- package/lib/compiler/generate.js +8 -2
- package/lib/compiler/index.js +1 -1
- package/lib/compiler/lsp-api.js +1 -1
- package/lib/compiler/propagator.js +2 -2
- package/lib/compiler/resolve.js +78 -31
- package/lib/compiler/shared.js +3 -3
- package/lib/compiler/tweak-assocs.js +1 -1
- package/lib/compiler/utils.js +10 -0
- package/lib/compiler/xpr-rewrite.js +1 -1
- package/lib/edm/annotations/edmJson.js +42 -39
- package/lib/edm/annotations/genericTranslation.js +55 -55
- package/lib/edm/annotations/preprocessAnnotations.js +5 -5
- package/lib/edm/csn2edm.js +21 -16
- package/lib/edm/edm.js +62 -62
- package/lib/edm/edmAnnoPreprocessor.js +2 -2
- package/lib/edm/edmInboundChecks.js +1 -1
- package/lib/edm/edmPreprocessor.js +32 -32
- package/lib/edm/edmUtils.js +8 -8
- package/lib/gen/CdlGrammar.checksum +1 -1
- package/lib/gen/CdlParser.js +77 -81
- package/lib/gen/Dictionary.json +3062 -3072
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +1 -1
- package/lib/gen/languageParser.js +1238 -1236
- package/lib/json/from-csn.js +1 -1
- package/lib/json/to-csn.js +30 -3
- package/lib/language/genericAntlrParser.js +16 -0
- package/lib/main.d.ts +79 -1
- package/lib/model/csnRefs.js +12 -5
- package/lib/model/xprAsTree.js +71 -0
- package/lib/modelCompare/utils/filter.js +1 -1
- package/lib/optionProcessor.js +46 -32
- package/lib/parsers/CdlGrammar.g4 +33 -28
- package/lib/parsers/Lexer.js +1 -1
- package/lib/parsers/XprTree.js +25 -16
- package/lib/render/toCdl.js +902 -414
- package/lib/render/toHdbcds.js +1 -1
- package/lib/render/toSql.js +8 -0
- package/lib/render/utils/common.js +2 -2
- package/lib/render/utils/operators.js +160 -0
- package/lib/render/utils/pretty.js +337 -0
- package/lib/sql-identifier.js +7 -9
- package/lib/transform/addTenantFields.js +39 -41
- package/lib/transform/db/applyTransformations.js +4 -4
- package/lib/transform/db/assertUnique.js +6 -5
- package/lib/transform/db/associations.js +3 -3
- package/lib/transform/db/assocsToQueries/transformExists.js +13 -13
- package/lib/transform/db/assocsToQueries/utils.js +8 -0
- package/lib/transform/db/backlinks.js +19 -14
- package/lib/transform/db/constraints.js +6 -6
- package/lib/transform/db/expansion.js +1 -1
- package/lib/transform/db/flattening.js +2 -2
- package/lib/transform/db/groupByOrderBy.js +1 -1
- package/lib/transform/db/processSqlServices.js +3 -3
- package/lib/transform/db/rewriteCalculatedElements.js +2 -2
- package/lib/transform/db/temporal.js +7 -9
- package/lib/transform/db/views.js +6 -6
- package/lib/transform/draft/odata.js +2 -0
- package/lib/transform/effective/annotations.js +1 -1
- package/lib/transform/effective/associations.js +1 -1
- package/lib/transform/effective/main.js +1 -0
- package/lib/transform/effective/service.js +2 -2
- package/lib/transform/forRelationalDB.js +11 -5
- package/lib/transform/localized.js +2 -0
- package/lib/transform/odata/adaptAnnotationRefs.js +10 -9
- package/lib/transform/parseExpr.js +2 -2
- package/lib/transform/transformUtils.js +9 -7
- package/lib/transform/translateAssocsToJoins.js +0 -2
- package/lib/transform/universalCsn/coreComputed.js +2 -2
- package/lib/utils/moduleResolve.js +7 -5
- package/package.json +1 -1
- package/share/messages/def-upcoming-virtual-change.md +55 -0
- package/share/messages/file-unexpected-case-mismatch.md +61 -0
- package/share/messages/message-explanations.json +2 -0
- package/lib/transform/braceExpression.js +0 -77
package/lib/edm/edm.js
CHANGED
|
@@ -21,7 +21,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
21
21
|
if (!attributes || typeof attributes !== 'object')
|
|
22
22
|
error(null, 'Debug me: attributes must be a dictionary');
|
|
23
23
|
if (!Array.isArray(version))
|
|
24
|
-
error(null, `Debug me: v is either undefined or not an array: ${version}`);
|
|
24
|
+
error(null, `Debug me: v is either undefined or not an array: ${ version }`);
|
|
25
25
|
if (version.filter(v => v).length !== 1)
|
|
26
26
|
error(null, 'Debug me: exactly one version must be set');
|
|
27
27
|
|
|
@@ -131,7 +131,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
131
131
|
toJSONattributes(json, withHints = true) {
|
|
132
132
|
forEach(this._edmAttributes, (p, v) => {
|
|
133
133
|
if (p !== 'Name')
|
|
134
|
-
json[p[0] === '@' ? p : `$${p}`] = v;
|
|
134
|
+
json[p[0] === '@' ? p : `$${ p }`] = v;
|
|
135
135
|
});
|
|
136
136
|
return (withHints ? this.toOpenApiHints(json) : json);
|
|
137
137
|
}
|
|
@@ -139,7 +139,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
139
139
|
toOpenApiHints(json) {
|
|
140
140
|
if (options.odataOpenapiHints && this._openApiHints) {
|
|
141
141
|
Object.entries(this._openApiHints).forEach(([ p, v ]) => {
|
|
142
|
-
json[p[0] === '@' ? p : `$${p}`] = v;
|
|
142
|
+
json[p[0] === '@' ? p : `$${ p }`] = v;
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
return json;
|
|
@@ -158,24 +158,24 @@ function getEdm( options, messageFunctions ) {
|
|
|
158
158
|
// virtual
|
|
159
159
|
toXML(indent = '', what = 'all') {
|
|
160
160
|
const { kind } = this;
|
|
161
|
-
let head = `${indent}<${kind}`;
|
|
161
|
+
let head = `${ indent }<${ kind }`;
|
|
162
162
|
|
|
163
163
|
if (kind === 'Parameter' && this._edmAttributes.Collection) {
|
|
164
164
|
delete this._edmAttributes.Collection;
|
|
165
|
-
this._edmAttributes.Type = `Collection(${this._edmAttributes.Type})`;
|
|
165
|
+
this._edmAttributes.Type = `Collection(${ this._edmAttributes.Type })`;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
head += this.toXMLattributes();
|
|
169
169
|
|
|
170
|
-
const inner = this.innerXML(`${indent} `, what);
|
|
170
|
+
const inner = this.innerXML(`${ indent } `, what);
|
|
171
171
|
if (inner.length < 1)
|
|
172
172
|
head += '/>';
|
|
173
173
|
|
|
174
174
|
else if (inner.length < 77 && inner.indexOf('<') < 0)
|
|
175
|
-
head += `>${inner.slice(indent.length + 1, -1)}</${kind}>`;
|
|
175
|
+
head += `>${ inner.slice(indent.length + 1, -1) }</${ kind }>`;
|
|
176
176
|
|
|
177
177
|
else
|
|
178
|
-
head += `>\n${inner}${indent}</${kind}>`;
|
|
178
|
+
head += `>\n${ inner }${ indent }</${ kind }>`;
|
|
179
179
|
|
|
180
180
|
return head;
|
|
181
181
|
}
|
|
@@ -185,11 +185,11 @@ function getEdm( options, messageFunctions ) {
|
|
|
185
185
|
let tmpStr = '';
|
|
186
186
|
forEach(this._edmAttributes, (p, v) => {
|
|
187
187
|
if (v !== undefined && typeof v !== 'object')
|
|
188
|
-
tmpStr += ` ${p}="${edmUtils.escapeStringForAttributeValue(v)}"`;
|
|
188
|
+
tmpStr += ` ${ p }="${ edmUtils.escapeStringForAttributeValue(v) }"`;
|
|
189
189
|
});
|
|
190
190
|
forEach(this._xmlOnlyAttributes, (p, v) => {
|
|
191
191
|
if (v !== undefined && typeof v !== 'object')
|
|
192
|
-
tmpStr += ` ${p}="${edmUtils.escapeStringForAttributeValue(v)}"`;
|
|
192
|
+
tmpStr += ` ${ p }="${ edmUtils.escapeStringForAttributeValue(v) }"`;
|
|
193
193
|
});
|
|
194
194
|
return tmpStr;
|
|
195
195
|
}
|
|
@@ -199,7 +199,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
199
199
|
let xml = '';
|
|
200
200
|
|
|
201
201
|
this._children.forEach((e) => {
|
|
202
|
-
xml += `${e.toXML(indent, what)}\n`;
|
|
202
|
+
xml += `${ e.toXML(indent, what) }\n`;
|
|
203
203
|
});
|
|
204
204
|
return xml;
|
|
205
205
|
}
|
|
@@ -211,7 +211,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
211
211
|
if (attr) {
|
|
212
212
|
Object.entries(attr).forEach(([ p, v ]) => {
|
|
213
213
|
if (p.match(/^@sap./))
|
|
214
|
-
this.setXml( { [`sap:${p.slice(5).replace(/\./g, '-')}`]: v } );
|
|
214
|
+
this.setXml( { [`sap:${ p.slice(5).replace(/\./g, '-') }`]: v } );
|
|
215
215
|
});
|
|
216
216
|
}
|
|
217
217
|
}
|
|
@@ -324,17 +324,17 @@ function getEdm( options, messageFunctions ) {
|
|
|
324
324
|
if (this._actions) {
|
|
325
325
|
Object.values(this._actions).forEach((actionArray) => {
|
|
326
326
|
actionArray.forEach((action) => {
|
|
327
|
-
xml += `${action.toXML(indent, what)}\n`;
|
|
327
|
+
xml += `${ action.toXML(indent, what) }\n`;
|
|
328
328
|
});
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
332
|
if ((what === 'annotations' || what === 'all') && this._annotations.length > 0) {
|
|
333
333
|
this._annotations.filter(a => a._edmAttributes.Term).forEach((a) => {
|
|
334
|
-
xml += `${a.toXML(indent)}\n`;
|
|
334
|
+
xml += `${ a.toXML(indent) }\n`;
|
|
335
335
|
});
|
|
336
336
|
this._annotations.filter(a => a._edmAttributes.Target).forEach((a) => {
|
|
337
|
-
xml += `${a.toXML(indent)}\n`;
|
|
337
|
+
xml += `${ a.toXML(indent) }\n`;
|
|
338
338
|
});
|
|
339
339
|
}
|
|
340
340
|
return xml;
|
|
@@ -345,7 +345,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
345
345
|
if (this._edmAttributes) {
|
|
346
346
|
Object.entries(this._edmAttributes).forEach(([ p, v ]) => {
|
|
347
347
|
if (p !== 'Name' && p !== 'Namespace')
|
|
348
|
-
json[p[0] === '@' ? p : `$${p}`] = v;
|
|
348
|
+
json[p[0] === '@' ? p : `$${ p }`] = v;
|
|
349
349
|
});
|
|
350
350
|
}
|
|
351
351
|
return this.toOpenApiHints(json);
|
|
@@ -464,7 +464,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
464
464
|
|
|
465
465
|
const json = Object.create(null);
|
|
466
466
|
json.$Version = this._edmAttributes.Version;
|
|
467
|
-
json.$EntityContainer = `${schema._edmAttributes.Namespace}.${schema._ec._edmAttributes.Name}`;
|
|
467
|
+
json.$EntityContainer = `${ schema._edmAttributes.Namespace }.${ schema._ec._edmAttributes.Name }`;
|
|
468
468
|
|
|
469
469
|
const referenceJson = Object.create(null);
|
|
470
470
|
this._defaultRefs.forEach((r) => {
|
|
@@ -483,7 +483,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
483
483
|
|
|
484
484
|
// all(default), metadata, annotations
|
|
485
485
|
toXML(what = 'all') {
|
|
486
|
-
return `<?xml version="1.0" encoding="utf-8"?>\n${super.toXML('', what)}`;
|
|
486
|
+
return `<?xml version="1.0" encoding="utf-8"?>\n${ super.toXML('', what) }`;
|
|
487
487
|
}
|
|
488
488
|
|
|
489
489
|
innerXML(indent, what) {
|
|
@@ -491,13 +491,13 @@ function getEdm( options, messageFunctions ) {
|
|
|
491
491
|
|
|
492
492
|
if (this.v4 || (this.v2 && (what === 'all' || what === 'annotations'))) {
|
|
493
493
|
this._defaultRefs.forEach((r) => {
|
|
494
|
-
xml += `${r.toXML(indent)}\n`;
|
|
494
|
+
xml += `${ r.toXML(indent) }\n`;
|
|
495
495
|
});
|
|
496
496
|
}
|
|
497
497
|
this._children.forEach((e) => {
|
|
498
|
-
xml += `${e.toXML(indent)}\n`;
|
|
498
|
+
xml += `${ e.toXML(indent) }\n`;
|
|
499
499
|
});
|
|
500
|
-
xml += `${this._service.toXML(indent, what)}\n`;
|
|
500
|
+
xml += `${ this._service.toXML(indent, what) }\n`;
|
|
501
501
|
return xml;
|
|
502
502
|
}
|
|
503
503
|
}
|
|
@@ -509,7 +509,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
509
509
|
if (p === 'EntityType') // it's $Type in json
|
|
510
510
|
json.$Type = v;
|
|
511
511
|
else
|
|
512
|
-
json[p[0] === '@' ? p : `$${p}`] = v;
|
|
512
|
+
json[p[0] === '@' ? p : `$${ p }`] = v;
|
|
513
513
|
}
|
|
514
514
|
});
|
|
515
515
|
return json;
|
|
@@ -527,7 +527,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
527
527
|
}
|
|
528
528
|
|
|
529
529
|
getDuplicateMessage() {
|
|
530
|
-
return `EntityType "${this._edmAttributes.EntityType}"`;
|
|
530
|
+
return `EntityType "${ this._edmAttributes.EntityType }"`;
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
533
|
|
|
@@ -586,7 +586,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
586
586
|
innerXML(indent) {
|
|
587
587
|
let xml = super.innerXML(indent);
|
|
588
588
|
if (this._returnType !== undefined)
|
|
589
|
-
xml += `${this._returnType.toXML(indent)}\n`;
|
|
589
|
+
xml += `${ this._returnType.toXML(indent) }\n`;
|
|
590
590
|
return xml;
|
|
591
591
|
}
|
|
592
592
|
|
|
@@ -617,12 +617,12 @@ function getEdm( options, messageFunctions ) {
|
|
|
617
617
|
*/
|
|
618
618
|
class FunctionImport extends Node {
|
|
619
619
|
getDuplicateMessage() {
|
|
620
|
-
return `Function "${this._edmAttributes.Name}"`;
|
|
620
|
+
return `Function "${ this._edmAttributes.Name }"`;
|
|
621
621
|
}
|
|
622
622
|
} // ActionFunctionBase {}
|
|
623
623
|
class ActionImport extends Node {
|
|
624
624
|
getDuplicateMessage() {
|
|
625
|
-
return `Action "${this._edmAttributes.Name}"`;
|
|
625
|
+
return `Action "${ this._edmAttributes.Name }"`;
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
628
|
|
|
@@ -685,10 +685,10 @@ function getEdm( options, messageFunctions ) {
|
|
|
685
685
|
if (td[facetName] !== undefined &&
|
|
686
686
|
(facet.v2 === this.v2 ||
|
|
687
687
|
facet.v4 === this.v4)) {
|
|
688
|
-
if (this.v2 && facetName === 'Scale' && csn[`@odata.${facetName}`] === 'variable')
|
|
688
|
+
if (this.v2 && facetName === 'Scale' && csn[`@odata.${ facetName }`] === 'variable')
|
|
689
689
|
this.setXml({ [facet.extra]: true });
|
|
690
690
|
else
|
|
691
|
-
this.setEdmAttribute(facetName, csn[`@odata.${facetName}`]);
|
|
691
|
+
this.setEdmAttribute(facetName, csn[`@odata.${ facetName }`]);
|
|
692
692
|
}
|
|
693
693
|
});
|
|
694
694
|
}
|
|
@@ -702,28 +702,28 @@ function getEdm( options, messageFunctions ) {
|
|
|
702
702
|
if (options.whatsMySchemaName && this._edmAttributes[typeName]) {
|
|
703
703
|
const schemaName = options.whatsMySchemaName(this._edmAttributes[typeName]);
|
|
704
704
|
if (schemaName && schemaName !== options.serviceName)
|
|
705
|
-
this._edmAttributes[typeName] = this._edmAttributes[typeName].replace(`${options.serviceName}.`, '');
|
|
705
|
+
this._edmAttributes[typeName] = this._edmAttributes[typeName].replace(`${ options.serviceName }.`, '');
|
|
706
706
|
}
|
|
707
707
|
|
|
708
708
|
// store undecorated type for JSON
|
|
709
709
|
this._type = this._edmAttributes[typeName];
|
|
710
710
|
// decorate for XML (not for Complex/EntityType)
|
|
711
711
|
if (this.$isCollection && this._edmAttributes[typeName])
|
|
712
|
-
this._edmAttributes[typeName] = `Collection(${this._edmAttributes[typeName]})`;
|
|
712
|
+
this._edmAttributes[typeName] = `Collection(${ this._edmAttributes[typeName] })`;
|
|
713
713
|
}
|
|
714
714
|
|
|
715
715
|
toJSONattributes(json) {
|
|
716
716
|
// $Type Edm.String, $Nullable=false MAY be omitted
|
|
717
717
|
// @ property and parameter for performance reasons
|
|
718
718
|
if (this._type !== 'Edm.String' && this._type) // Edm.String is default)
|
|
719
|
-
json[`$${this._typeName}`] = this._type;
|
|
719
|
+
json[`$${ this._typeName }`] = this._type;
|
|
720
720
|
|
|
721
721
|
if (this._edmAttributes) {
|
|
722
722
|
Object.entries(this._edmAttributes).forEach(([ p, v ]) => {
|
|
723
723
|
if (p !== 'Name' && p !== this._typeName &&
|
|
724
724
|
// remove this line if Nullable=true becomes default
|
|
725
725
|
!(p === 'Nullable' && !v))
|
|
726
|
-
json[p[0] === '@' ? p : `$${p}`] = v;
|
|
726
|
+
json[p[0] === '@' ? p : `$${ p }`] = v;
|
|
727
727
|
});
|
|
728
728
|
}
|
|
729
729
|
|
|
@@ -765,12 +765,12 @@ function getEdm( options, messageFunctions ) {
|
|
|
765
765
|
// Limit Key length to 32 characters
|
|
766
766
|
if (c > 0) {
|
|
767
767
|
if (alias.length > 28)
|
|
768
|
-
alias = `${alias.substr(0, 13)}__${alias.substr(alias.length - 13, alias.length)}`;
|
|
768
|
+
alias = `${ alias.substr(0, 13) }__${ alias.substr(alias.length - 13, alias.length) }`;
|
|
769
769
|
|
|
770
|
-
alias = `${alias}_${c.toString().padStart(3, '0')}`;
|
|
770
|
+
alias = `${ alias }_${ c.toString().padStart(3, '0') }`;
|
|
771
771
|
}
|
|
772
772
|
else if (alias.length > 32) {
|
|
773
|
-
alias = `${alias.substr(0, 15)}__${alias.substr(alias.length - 15, alias.length)}`;
|
|
773
|
+
alias = `${ alias.substr(0, 15) }__${ alias.substr(alias.length - 15, alias.length) }`;
|
|
774
774
|
}
|
|
775
775
|
p[1] = alias;
|
|
776
776
|
}
|
|
@@ -792,7 +792,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
792
792
|
innerXML(indent) {
|
|
793
793
|
let xml = '';
|
|
794
794
|
if (this._keys)
|
|
795
|
-
xml += `${this._keys.toXML(indent)}\n`;
|
|
795
|
+
xml += `${ this._keys.toXML(indent) }\n`;
|
|
796
796
|
return xml + super.innerXML(indent);
|
|
797
797
|
}
|
|
798
798
|
|
|
@@ -800,7 +800,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
800
800
|
super.toJSONattributes(json);
|
|
801
801
|
if (this._jsonOnlyAttributes) {
|
|
802
802
|
Object.entries(this._jsonOnlyAttributes).forEach(([ p, v ]) => {
|
|
803
|
-
json[p[0] === '@' ? p : `$${p}`] = v;
|
|
803
|
+
json[p[0] === '@' ? p : `$${ p }`] = v;
|
|
804
804
|
});
|
|
805
805
|
}
|
|
806
806
|
if (this._keys)
|
|
@@ -939,7 +939,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
939
939
|
// translate the following @sap annos as xml attributes to the Property
|
|
940
940
|
forEach(csn, (p, v) => {
|
|
941
941
|
if (p in Property.SAP_Annotation_Attributes)
|
|
942
|
-
this.setXml( { [`sap:${p.slice(5).replace(/\./g, '-')}`]: v });
|
|
942
|
+
this.setXml( { [`sap:${ p.slice(5).replace(/\./g, '-') }`]: v });
|
|
943
943
|
});
|
|
944
944
|
}
|
|
945
945
|
|
|
@@ -967,7 +967,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
967
967
|
Reason: Fiori UI5 expects 'Default' under extension namespace 'sap:'
|
|
968
968
|
Additionally: The attribute is named 'Default' in V2 and 'DefaultValue' in V4
|
|
969
969
|
*/
|
|
970
|
-
this._edmAttributes[`Default${this.v4 ? 'Value' : ''}`] = defVal;
|
|
970
|
+
this._edmAttributes[`Default${ this.v4 ? 'Value' : '' }`] = defVal;
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
973
|
}
|
|
@@ -1022,7 +1022,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1022
1022
|
|
|
1023
1023
|
innerXML(indent) {
|
|
1024
1024
|
if (this._d && this._p)
|
|
1025
|
-
return `${this._p.toXML(indent)}\n${this._d.toXML(indent)}\n`;
|
|
1025
|
+
return `${ this._p.toXML(indent) }\n${ this._d.toXML(indent) }\n`;
|
|
1026
1026
|
|
|
1027
1027
|
return super.innerXML(indent);
|
|
1028
1028
|
}
|
|
@@ -1044,7 +1044,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1044
1044
|
|
|
1045
1045
|
// either csn has multiplicity or we have to use the multiplicity of the backlink
|
|
1046
1046
|
if (this.$isCollection) {
|
|
1047
|
-
this._edmAttributes.Type = `Collection(${attributes.Type})`;
|
|
1047
|
+
this._edmAttributes.Type = `Collection(${ attributes.Type })`;
|
|
1048
1048
|
// attribute Nullable is not allowed in combination with Collection (see Spec)
|
|
1049
1049
|
// Even if min cardinality is > 0, remove Nullable, because the implicit OData contract
|
|
1050
1050
|
// is that a navigation property must either return an empty collection or all collection
|
|
@@ -1142,7 +1142,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1142
1142
|
json.$OnDelete = c._edmAttributes.Action;
|
|
1143
1143
|
break;
|
|
1144
1144
|
default:
|
|
1145
|
-
error(null, `Debug me: Unhandled NavProp child: ${c.kind}`);
|
|
1145
|
+
error(null, `Debug me: Unhandled NavProp child: ${ c.kind }`);
|
|
1146
1146
|
}
|
|
1147
1147
|
});
|
|
1148
1148
|
// TODO Annotations
|
|
@@ -1220,7 +1220,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1220
1220
|
// without filtering non-spec-compliant constExpr
|
|
1221
1221
|
const json = Object.create(null);
|
|
1222
1222
|
Object.entries(dict).forEach(([ k, v ]) => {
|
|
1223
|
-
json[`$${k}`] = v;
|
|
1223
|
+
json[`$${ k }`] = v;
|
|
1224
1224
|
});
|
|
1225
1225
|
return json;
|
|
1226
1226
|
}
|
|
@@ -1246,7 +1246,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1246
1246
|
toJSONattributes(json) {
|
|
1247
1247
|
forEach(this._edmAttributes, (p, v) => {
|
|
1248
1248
|
if (p !== 'Target')
|
|
1249
|
-
json[p[0] === '@' ? p : `$${p}`] = v;
|
|
1249
|
+
json[p[0] === '@' ? p : `$${ p }`] = v;
|
|
1250
1250
|
});
|
|
1251
1251
|
return json;
|
|
1252
1252
|
}
|
|
@@ -1291,7 +1291,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1291
1291
|
}
|
|
1292
1292
|
|
|
1293
1293
|
getJsonFQTermName() {
|
|
1294
|
-
return `@${this._edmAttributes.Term}${this._edmAttributes.Qualifier ? `#${this._edmAttributes.Qualifier}` : ''}`;
|
|
1294
|
+
return `@${ this._edmAttributes.Term }${ this._edmAttributes.Qualifier ? `#${ this._edmAttributes.Qualifier }` : '' }`;
|
|
1295
1295
|
}
|
|
1296
1296
|
}
|
|
1297
1297
|
|
|
@@ -1317,7 +1317,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1317
1317
|
json['@type'] = this._jsonOnlyAttributes.Type;
|
|
1318
1318
|
const keys = Object.keys(this._edmAttributes).filter(k => k !== 'Type');
|
|
1319
1319
|
for (const key of keys)
|
|
1320
|
-
json[`$${key}`] = this._edmAttributes[key];
|
|
1320
|
+
json[`$${ key }`] = this._edmAttributes[key];
|
|
1321
1321
|
return json;
|
|
1322
1322
|
}
|
|
1323
1323
|
|
|
@@ -1340,7 +1340,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1340
1340
|
break;
|
|
1341
1341
|
}
|
|
1342
1342
|
default:
|
|
1343
|
-
error(null, `Pease debug me: Unhandled Record child: ${c.kind}`);
|
|
1343
|
+
error(null, `Pease debug me: Unhandled Record child: ${ c.kind }`);
|
|
1344
1344
|
}
|
|
1345
1345
|
});
|
|
1346
1346
|
return json;
|
|
@@ -1384,8 +1384,8 @@ function getEdm( options, messageFunctions ) {
|
|
|
1384
1384
|
|
|
1385
1385
|
toXML(indent = '') {
|
|
1386
1386
|
const { kind } = this;
|
|
1387
|
-
let xml = `${indent}<${kind}${this.toXMLattributes()}`;
|
|
1388
|
-
xml += (this._value !== undefined ? `>${edmUtils.escapeStringForText(this._value)}</${kind}>` : '/>');
|
|
1387
|
+
let xml = `${ indent }<${ kind }${ this.toXMLattributes() }`;
|
|
1388
|
+
xml += (this._value !== undefined ? `>${ edmUtils.escapeStringForText(this._value) }</${ kind }>` : '/>');
|
|
1389
1389
|
return xml;
|
|
1390
1390
|
}
|
|
1391
1391
|
|
|
@@ -1403,10 +1403,10 @@ function getEdm( options, messageFunctions ) {
|
|
|
1403
1403
|
const json = this.mergeJSONAnnotations();
|
|
1404
1404
|
const e = this._children.filter(c => c.kind !== 'Annotation');
|
|
1405
1405
|
if (e.length === 1)
|
|
1406
|
-
json[`$${this.kind}`] = e[0].toJSON();
|
|
1406
|
+
json[`$${ this.kind }`] = e[0].toJSON();
|
|
1407
1407
|
|
|
1408
1408
|
else
|
|
1409
|
-
json[`$${this.kind}`] = e.map(c => c.toJSON());
|
|
1409
|
+
json[`$${ this.kind }`] = e.map(c => c.toJSON());
|
|
1410
1410
|
|
|
1411
1411
|
return json;
|
|
1412
1412
|
}
|
|
@@ -1418,14 +1418,14 @@ function getEdm( options, messageFunctions ) {
|
|
|
1418
1418
|
}
|
|
1419
1419
|
toJSON() {
|
|
1420
1420
|
const json = this.mergeJSONAnnotations();
|
|
1421
|
-
json[`$${this.kind}`] = null;
|
|
1421
|
+
json[`$${ this.kind }`] = null;
|
|
1422
1422
|
return json;
|
|
1423
1423
|
}
|
|
1424
1424
|
}
|
|
1425
1425
|
class Apply extends AnnotationBase {
|
|
1426
1426
|
toJSON() {
|
|
1427
1427
|
const json = this.mergeJSONAnnotations();
|
|
1428
|
-
json[`$${this.kind}`] = this._children.filter(c => c.kind !== 'Annotation').map(c => c.toJSON());
|
|
1428
|
+
json[`$${ this.kind }`] = this._children.filter(c => c.kind !== 'Annotation').map(c => c.toJSON());
|
|
1429
1429
|
return this.toJSONattributes(json);
|
|
1430
1430
|
}
|
|
1431
1431
|
}
|
|
@@ -1433,7 +1433,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1433
1433
|
toXMLattributes() {
|
|
1434
1434
|
if (this._jsonOnlyAttributes.Collection) {
|
|
1435
1435
|
const ot = this._edmAttributes.Type;
|
|
1436
|
-
this._edmAttributes.Type = `Collection(${ot})`;
|
|
1436
|
+
this._edmAttributes.Type = `Collection(${ ot })`;
|
|
1437
1437
|
const str = super.toXMLattributes();
|
|
1438
1438
|
this._edmAttributes.Type = ot;
|
|
1439
1439
|
return str;
|
|
@@ -1444,14 +1444,14 @@ function getEdm( options, messageFunctions ) {
|
|
|
1444
1444
|
const json = this.mergeJSONAnnotations();
|
|
1445
1445
|
// first expression only, if any
|
|
1446
1446
|
const children = this._children.filter(child => child.kind !== 'Annotation');
|
|
1447
|
-
json[`$${this.kind}`] = children.length ? children[0].toJSON() : {};
|
|
1447
|
+
json[`$${ this.kind }`] = children.length ? children[0].toJSON() : {};
|
|
1448
1448
|
return this.toJSONattributes(json);
|
|
1449
1449
|
}
|
|
1450
1450
|
toJSONattributes(json) {
|
|
1451
1451
|
super.toJSONattributes(json);
|
|
1452
1452
|
if (this._jsonOnlyAttributes) {
|
|
1453
1453
|
Object.entries(this._jsonOnlyAttributes).forEach(([ p, v ]) => {
|
|
1454
|
-
json[p[0] === '@' ? p : `$${p}`] = v;
|
|
1454
|
+
json[p[0] === '@' ? p : `$${ p }`] = v;
|
|
1455
1455
|
});
|
|
1456
1456
|
}
|
|
1457
1457
|
return json;
|
|
@@ -1462,7 +1462,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1462
1462
|
class If extends AnnotationBase {
|
|
1463
1463
|
toJSON() {
|
|
1464
1464
|
const json = this.mergeJSONAnnotations();
|
|
1465
|
-
json[`$${this.kind}`] = this._children.filter(c => c.kind !== 'Annotation').map(c => c.toJSON());
|
|
1465
|
+
json[`$${ this.kind }`] = this._children.filter(c => c.kind !== 'Annotation').map(c => c.toJSON());
|
|
1466
1466
|
return json;
|
|
1467
1467
|
}
|
|
1468
1468
|
}
|
|
@@ -1471,13 +1471,13 @@ function getEdm( options, messageFunctions ) {
|
|
|
1471
1471
|
const json = this.mergeJSONAnnotations();
|
|
1472
1472
|
// first expression only, if any
|
|
1473
1473
|
const children = this._children.filter(child => child.kind !== 'Annotation');
|
|
1474
|
-
json[`$${this.kind}`] = children.length ? children[0].toJSON() : '';
|
|
1474
|
+
json[`$${ this.kind }`] = children.length ? children[0].toJSON() : '';
|
|
1475
1475
|
return this.toJSONattributes(json);
|
|
1476
1476
|
}
|
|
1477
1477
|
|
|
1478
1478
|
toJSONattributes(json) { // including Name
|
|
1479
1479
|
forEach(this._edmAttributes, (p, v) => {
|
|
1480
|
-
json[p[0] === '@' ? p : `$${p}`] = v;
|
|
1480
|
+
json[p[0] === '@' ? p : `$${ p }`] = v;
|
|
1481
1481
|
});
|
|
1482
1482
|
return json;
|
|
1483
1483
|
}
|
|
@@ -1493,7 +1493,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1493
1493
|
const json = this.mergeJSONAnnotations();
|
|
1494
1494
|
// first expression only, if any
|
|
1495
1495
|
const children = this._children.filter(child => child.kind !== 'Annotation');
|
|
1496
|
-
json[`$${this.kind}`] = children.length ? children[0].toJSON() : {};
|
|
1496
|
+
json[`$${ this.kind }`] = children.length ? children[0].toJSON() : {};
|
|
1497
1497
|
return json;
|
|
1498
1498
|
}
|
|
1499
1499
|
}
|
|
@@ -1520,7 +1520,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1520
1520
|
innerXML(indent) {
|
|
1521
1521
|
let xml = '';
|
|
1522
1522
|
this._end.forEach((e) => {
|
|
1523
|
-
xml += `${e.toXML(indent)}\n`;
|
|
1523
|
+
xml += `${ e.toXML(indent) }\n`;
|
|
1524
1524
|
});
|
|
1525
1525
|
xml += super.innerXML(indent);
|
|
1526
1526
|
return xml;
|
|
@@ -1536,7 +1536,7 @@ function getEdm( options, messageFunctions ) {
|
|
|
1536
1536
|
);
|
|
1537
1537
|
}
|
|
1538
1538
|
getDuplicateMessage() {
|
|
1539
|
-
return `Association "${this._edmAttributes.Association}"`;
|
|
1539
|
+
return `Association "${ this._edmAttributes.Association }"`;
|
|
1540
1540
|
}
|
|
1541
1541
|
}
|
|
1542
1542
|
|
|
@@ -111,7 +111,7 @@ function applyAppSpecificLateCsnTransformationOnElement( options, element, struc
|
|
|
111
111
|
|
|
112
112
|
// respect flattened annotation $value
|
|
113
113
|
Object.entries(dict).forEach(([ k, v ]) => {
|
|
114
|
-
dict[`${k}.$value`] = v;
|
|
114
|
+
dict[`${ k }.$value`] = v;
|
|
115
115
|
});
|
|
116
116
|
return dict;
|
|
117
117
|
}
|
|
@@ -202,7 +202,7 @@ function applyAppSpecificLateCsnTransformationOnStructure( options, struct, erro
|
|
|
202
202
|
|
|
203
203
|
// respect flattened annotation $value
|
|
204
204
|
Object.keys(dict).forEach((k) => {
|
|
205
|
-
dict[`${k}.$value`] = dict[k];
|
|
205
|
+
dict[`${ k }.$value`] = dict[k];
|
|
206
206
|
});
|
|
207
207
|
|
|
208
208
|
return dict;
|
|
@@ -87,7 +87,7 @@ function inboundQualificationChecks( csn, options, messageFunctions,
|
|
|
87
87
|
if (path[1] === defName)
|
|
88
88
|
assignAnnotation(elt, anno, true);
|
|
89
89
|
else if (elt[anno] == null)
|
|
90
|
-
warning('odata-key-uuid-default-anno', path, { type: type.type, anno, id: `${defName}:${eltPath.join('.')}` });
|
|
90
|
+
warning('odata-key-uuid-default-anno', path, { type: type.type, anno, id: `${ defName }:${ eltPath.join('.') }` });
|
|
91
91
|
}
|
|
92
92
|
else {
|
|
93
93
|
const elements = type.items?.elements || type.elements;
|