@sap/cds-compiler 2.11.4 → 2.13.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/CHANGELOG.md +159 -1
  2. package/bin/cds_update_identifiers.js +7 -7
  3. package/bin/cdsc.js +22 -23
  4. package/bin/cdsse.js +2 -2
  5. package/doc/CHANGELOG_ARCHIVE.md +1 -1
  6. package/doc/CHANGELOG_BETA.md +25 -6
  7. package/doc/CHANGELOG_DEPRECATED.md +22 -6
  8. package/doc/NameResolution.md +21 -16
  9. package/lib/api/main.js +30 -63
  10. package/lib/api/options.js +5 -5
  11. package/lib/api/validate.js +0 -5
  12. package/lib/backends.js +15 -23
  13. package/lib/base/dictionaries.js +0 -8
  14. package/lib/base/error.js +26 -0
  15. package/lib/base/keywords.js +7 -17
  16. package/lib/base/location.js +9 -4
  17. package/lib/base/message-registry.js +52 -2
  18. package/lib/base/messages.js +16 -26
  19. package/lib/base/model.js +2 -62
  20. package/lib/base/optionProcessorHelper.js +246 -183
  21. package/lib/checks/.eslintrc.json +2 -0
  22. package/lib/checks/actionsFunctions.js +2 -1
  23. package/lib/checks/annotationsOData.js +1 -1
  24. package/lib/checks/cdsPersistence.js +2 -1
  25. package/lib/checks/enricher.js +17 -1
  26. package/lib/checks/foreignKeys.js +4 -4
  27. package/lib/checks/invalidTarget.js +3 -1
  28. package/lib/checks/managedInType.js +4 -4
  29. package/lib/checks/managedWithoutKeys.js +3 -1
  30. package/lib/checks/queryNoDbArtifacts.js +1 -3
  31. package/lib/checks/selectItems.js +4 -4
  32. package/lib/checks/sql-snippets.js +94 -0
  33. package/lib/checks/types.js +1 -1
  34. package/lib/checks/validator.js +12 -7
  35. package/lib/compiler/assert-consistency.js +10 -6
  36. package/lib/compiler/base.js +0 -1
  37. package/lib/compiler/builtins.js +8 -6
  38. package/lib/compiler/checks.js +46 -12
  39. package/lib/compiler/cycle-detector.js +1 -1
  40. package/lib/compiler/define.js +1103 -0
  41. package/lib/compiler/extend.js +983 -0
  42. package/lib/compiler/finalize-parse-cdl.js +231 -0
  43. package/lib/compiler/index.js +33 -14
  44. package/lib/compiler/kick-start.js +190 -0
  45. package/lib/compiler/moduleLayers.js +4 -4
  46. package/lib/compiler/populate.js +1226 -0
  47. package/lib/compiler/propagator.js +113 -47
  48. package/lib/compiler/resolve.js +1433 -0
  49. package/lib/compiler/shared.js +76 -38
  50. package/lib/compiler/tweak-assocs.js +529 -0
  51. package/lib/compiler/utils.js +204 -33
  52. package/lib/edm/.eslintrc.json +5 -0
  53. package/lib/edm/annotations/genericTranslation.js +38 -25
  54. package/lib/edm/annotations/preprocessAnnotations.js +3 -3
  55. package/lib/edm/csn2edm.js +10 -9
  56. package/lib/edm/edm.js +19 -20
  57. package/lib/edm/edmPreprocessor.js +166 -95
  58. package/lib/edm/edmUtils.js +127 -34
  59. package/lib/gen/Dictionary.json +92 -43
  60. package/lib/gen/language.checksum +1 -1
  61. package/lib/gen/language.interp +11 -1
  62. package/lib/gen/language.tokens +86 -82
  63. package/lib/gen/languageLexer.interp +18 -1
  64. package/lib/gen/languageLexer.js +925 -847
  65. package/lib/gen/languageLexer.tokens +78 -74
  66. package/lib/gen/languageParser.js +5434 -4298
  67. package/lib/json/from-csn.js +59 -17
  68. package/lib/json/to-csn.js +143 -71
  69. package/lib/language/antlrParser.js +3 -3
  70. package/lib/language/docCommentParser.js +3 -3
  71. package/lib/language/genericAntlrParser.js +144 -54
  72. package/lib/language/language.g4 +424 -203
  73. package/lib/language/multiLineStringParser.js +536 -0
  74. package/lib/main.d.ts +472 -61
  75. package/lib/main.js +38 -11
  76. package/lib/model/api.js +3 -1
  77. package/lib/model/csnRefs.js +321 -204
  78. package/lib/model/csnUtils.js +224 -263
  79. package/lib/model/enrichCsn.js +97 -40
  80. package/lib/model/revealInternalProperties.js +27 -6
  81. package/lib/model/sortViews.js +2 -1
  82. package/lib/modelCompare/compare.js +17 -12
  83. package/lib/optionProcessor.js +7 -6
  84. package/lib/render/DuplicateChecker.js +1 -1
  85. package/lib/render/manageConstraints.js +36 -33
  86. package/lib/render/toCdl.js +174 -275
  87. package/lib/render/toHdbcds.js +201 -115
  88. package/lib/render/toRename.js +7 -10
  89. package/lib/render/toSql.js +149 -75
  90. package/lib/render/utils/common.js +22 -8
  91. package/lib/render/utils/sql.js +10 -7
  92. package/lib/render/utils/stringEscapes.js +111 -0
  93. package/lib/sql-identifier.js +1 -1
  94. package/lib/transform/.eslintrc.json +5 -0
  95. package/lib/transform/braceExpression.js +4 -2
  96. package/lib/transform/db/.eslintrc.json +2 -0
  97. package/lib/transform/db/applyTransformations.js +35 -12
  98. package/lib/transform/db/assertUnique.js +1 -1
  99. package/lib/transform/db/associations.js +187 -0
  100. package/lib/transform/db/cdsPersistence.js +150 -0
  101. package/lib/transform/db/constraints.js +61 -56
  102. package/lib/transform/db/expansion.js +50 -29
  103. package/lib/transform/db/flattening.js +552 -105
  104. package/lib/transform/db/groupByOrderBy.js +3 -1
  105. package/lib/transform/db/temporal.js +236 -0
  106. package/lib/transform/db/transformExists.js +94 -28
  107. package/lib/transform/db/views.js +5 -4
  108. package/lib/transform/draft/.eslintrc.json +38 -0
  109. package/lib/transform/{db/draft.js → draft/db.js} +9 -7
  110. package/lib/transform/draft/odata.js +227 -0
  111. package/lib/transform/forHanaNew.js +94 -801
  112. package/lib/transform/forOdataNew.js +22 -175
  113. package/lib/transform/localized.js +36 -32
  114. package/lib/transform/odata/generateForeignKeyElements.js +3 -3
  115. package/lib/transform/odata/referenceFlattener.js +95 -89
  116. package/lib/transform/odata/structureFlattener.js +1 -1
  117. package/lib/transform/odata/toFinalBaseType.js +86 -12
  118. package/lib/transform/odata/typesExposure.js +5 -5
  119. package/lib/transform/odata/utils.js +2 -2
  120. package/lib/transform/transformUtilsNew.js +47 -33
  121. package/lib/transform/translateAssocsToJoins.js +10 -27
  122. package/lib/transform/universalCsn/.eslintrc.json +36 -0
  123. package/lib/transform/universalCsn/coreComputed.js +170 -0
  124. package/lib/transform/universalCsn/universalCsnEnricher.js +715 -0
  125. package/lib/transform/universalCsn/utils.js +63 -0
  126. package/lib/utils/file.js +2 -1
  127. package/lib/utils/objectUtils.js +30 -0
  128. package/lib/utils/timetrace.js +8 -2
  129. package/package.json +1 -1
  130. package/share/messages/README.md +26 -0
  131. package/lib/compiler/definer.js +0 -2340
  132. package/lib/compiler/resolver.js +0 -2988
  133. package/lib/transform/universalCsnEnricher.js +0 -67
@@ -1,4 +1,4 @@
1
- const { forEachRef } = require('../../model/csnUtils');
1
+ const { applyTransformations } = require('../../model/csnUtils');
2
2
  const { setProp } = require('../../base/model');
3
3
  const { implicitAs } = require('../../model/csnRefs');
4
4
  const { structuralPath } = require('./structuralPath');
@@ -52,32 +52,34 @@ class ReferenceFlattener {
52
52
  * @param {*} isStructured Callback function checking of an artifact is a structured element.
53
53
  */
54
54
  resolveAllReferences(csn, inspectRef, isStructured) {
55
- forEachRef(csn, (_ref, node, path) => {
56
- if (!path) return;
57
- let resolved;
58
- try {
59
- resolved = inspectRef(path);
60
- } catch (ex) {
61
- return; // TODO: fix tests: throw Error("Could not inspectRef: " + path.join("/"));
62
- }
63
- if (!resolved)
64
- return; // TODO: fix tests: throw Error("Could not resolve: " + path.join("/"));
65
- if (!resolved.links)
66
- return; // TODO: fix tests: throw Error("Could not resolve links: " + path.join("/"));
67
- let paths = [];
68
- resolved.links.forEach((element) => {
69
- if (!element.art)
70
- paths = undefined; // not resolved -> no paths
71
- if (paths) {
72
- paths.push(element.art.$path);
55
+ applyTransformations(csn, {
56
+ ref: (node, prop, _ref, path) => {
57
+ if (!path) return;
58
+ let resolved;
59
+ try {
60
+ resolved = inspectRef(path);
61
+ } catch (ex) {
62
+ return; // TODO: fix tests: throw Error("Could not inspectRef: " + path.join("/"));
73
63
  }
74
- });
75
- if (paths)
76
- setProp(node, '$paths', paths);
77
- // cache if structured or not
78
- let structured = resolved.links.map(link => link.art ? (isStructured(link.art)) : undefined);
79
- this.structuredReference[path.join('/')] = structured;
80
- });
64
+ if (!resolved)
65
+ return; // TODO: fix tests: throw Error("Could not resolve: " + path.join("/"));
66
+ if (!resolved.links)
67
+ return; // TODO: fix tests: throw Error("Could not resolve links: " + path.join("/"));
68
+ let paths = [];
69
+ resolved.links.forEach((element) => {
70
+ if (!element.art)
71
+ paths = undefined; // not resolved -> no paths
72
+ if (paths) {
73
+ paths.push(element.art.$path);
74
+ }
75
+ });
76
+ if (paths)
77
+ setProp(node, '$paths', paths);
78
+ // cache if structured or not
79
+ let structured = resolved.links.map(link => link.art ? (isStructured(link.art)) : undefined);
80
+ this.structuredReference[path.join('/')] = structured;
81
+ }
82
+ })
81
83
  }
82
84
 
83
85
  /**
@@ -172,80 +174,84 @@ class ReferenceFlattener {
172
174
  * @param {*} csn
173
175
  */
174
176
  flattenAllReferences(csn) {
175
- forEachRef(csn, (ref, node, path) => {
176
- if (node.$paths) {
177
- let newRef = []; // flattened reference
178
- let flattenWithPrevious = false;
179
- let lastFlattenedID = null; // The variable will be set to the index of the last flattened path
180
- node.$paths.forEach((path, i) => {
181
- if (path === undefined || !ref[i]) return;
182
- let spath = path.join('/');
183
- let movedTo = this.elementTransitions[spath]; // detect element transition
184
- let flattened = this.flattenedElementPaths[spath];
185
- if (flattenWithPrevious) {
186
- newRef[newRef.length - 1] = newRef[newRef.length - 1] + '_' + (ref[i].id || ref[i]);
187
- // if we have a filter or args in an assoc, it needs to be kept, therefore
188
- // the id of the ref is updated with the flattened version
189
- if (ref[i].id) {
190
- ref[i].id = newRef[newRef.length - 1];
191
- newRef[newRef.length - 1] = ref[i];
177
+ applyTransformations(csn, {
178
+ ref: (node, prop, ref, path) => {
179
+ if (node.$paths) {
180
+ let newRef = []; // flattened reference
181
+ let flattenWithPrevious = false;
182
+ let lastFlattenedID = null; // The variable will be set to the index of the last flattened path
183
+ node.$paths.forEach((path, i) => {
184
+ if (path === undefined || !ref[i]) return;
185
+ let spath = path.join('/');
186
+ let movedTo = this.elementTransitions[spath]; // detect element transition
187
+ let flattened = this.flattenedElementPaths[spath];
188
+ if (flattenWithPrevious) {
189
+ newRef[newRef.length - 1] = newRef[newRef.length - 1] + '_' + (ref[i].id || ref[i]);
190
+ // if we have a filter or args in an assoc, it needs to be kept, therefore
191
+ // the id of the ref is updated with the flattened version
192
+ if (ref[i].id) {
193
+ ref[i].id = newRef[newRef.length - 1];
194
+ newRef[newRef.length - 1] = ref[i];
195
+ }
196
+ lastFlattenedID = i;
197
+ } else if(movedTo && i===0) { // handle local scope reference which is transitioned - replace first item in reference
198
+ let movedToElementName = movedTo[movedTo.length-1];
199
+ newRef.push(movedToElementName);
200
+ lastFlattenedID = i;
201
+ } else {
202
+ newRef.push(ref[i]);
192
203
  }
193
- lastFlattenedID = i;
194
- } else if(movedTo && i===0) { // handle local scope reference which is transitioned - replace first item in reference
195
- let movedToElementName = movedTo[movedTo.length-1];
196
- newRef.push(movedToElementName);
197
- lastFlattenedID = i;
198
- } else {
199
- newRef.push(ref[i]);
200
- }
201
- flattenWithPrevious = flattened;
202
- });
203
- if (newRef !== undefined && lastFlattenedID !== null) { // make sure the reference changed and only then replace it with the new one
204
- // check if this is a column and add alias if missing
205
- let structural = structuralPath(csn, path);
206
- if (isColumnInSelectOrProjection(structural)) {
207
- if (!node.as && lastFlattenedID === ref.length-1) // attach alias only if there is none and it is the last item in the reference that was flattened
208
- node.as = node.ref[node.ref.length - 1];
209
- }
210
- setProp(newRef, '$path', path.concat('ref'));
211
- if (!node.as) {
212
- if (isPartOfKeysStructure(structural))
213
- node.as = implicitAs(node.ref);
214
- else
215
- setProp(node, 'as', implicitAs(node.ref))
204
+ flattenWithPrevious = flattened;
205
+ });
206
+ if (newRef !== undefined && lastFlattenedID !== null) { // make sure the reference changed and only then replace it with the new one
207
+ // check if this is a column and add alias if missing
208
+ let structural = structuralPath(csn, path);
209
+ if (isColumnInSelectOrProjection(structural)) {
210
+ if (!node.as && lastFlattenedID === ref.length-1) // attach alias only if there is none and it is the last item in the reference that was flattened
211
+ node.as = node.ref[node.ref.length - 1];
212
+ }
213
+ setProp(newRef, '$path', path.concat('ref'));
214
+ if (!node.as) {
215
+ if (isPartOfKeysStructure(structural))
216
+ node.as = implicitAs(node.ref);
217
+ else
218
+ setProp(node, 'as', implicitAs(node.ref))
219
+ }
220
+ node.ref = newRef;
216
221
  }
217
- node.ref = newRef;
218
222
  }
219
223
  }
220
224
  })
221
225
  }
222
226
 
223
227
  applyAliasesInOnCond(csn, inspectRef) {
224
- forEachRef(csn, (ref, node, path) => {
225
- // Process only on-conditions of associations
226
- let structural = structuralPath(csn, path);
227
- if(!isOnCondition(structural)) return;
228
- let { links } = inspectRef(path);
229
- if(!links) return; // $user not resolvable
230
- let keysOfPreviousStepWhenManagedAssoc = undefined;
231
-
232
- let aliasedRef = [...ref];
233
-
234
- for (let idx = 0; idx < ref.length; idx++) {
235
- const currArt = links[idx].art;
236
- if (keysOfPreviousStepWhenManagedAssoc) {
237
- const usedKey = keysOfPreviousStepWhenManagedAssoc.find(key => key.ref[0] === ref[idx]);
238
- if (usedKey && usedKey.as) {
239
- aliasedRef.splice(idx, usedKey.ref.length, usedKey.as);
240
- idx += usedKey.ref.length - 1;
241
- keysOfPreviousStepWhenManagedAssoc = undefined;
228
+ applyTransformations(csn, {
229
+ ref: (node, prop, ref, path) => {
230
+ // Process only on-conditions of associations
231
+ let structural = structuralPath(csn, path);
232
+ if(!isOnCondition(structural)) return;
233
+ let { links } = inspectRef(path);
234
+ if(!links) return; // $user not resolvable
235
+ let keysOfPreviousStepWhenManagedAssoc = undefined;
236
+
237
+ let aliasedRef = [...ref];
238
+
239
+ for (let idx = 0; idx < ref.length; idx++) {
240
+ const currArt = links[idx].art;
241
+ if (keysOfPreviousStepWhenManagedAssoc) {
242
+ const usedKey = keysOfPreviousStepWhenManagedAssoc.find(key => key.ref[0] === ref[idx]);
243
+ if (usedKey && usedKey.as) {
244
+ aliasedRef.splice(idx, usedKey.ref.length, usedKey.as);
245
+ idx += usedKey.ref.length - 1;
246
+ keysOfPreviousStepWhenManagedAssoc = undefined;
247
+ }
248
+ } else {
249
+ keysOfPreviousStepWhenManagedAssoc =
250
+ (currArt.type === 'cds.Association' || currArt.type === 'cds.Composition') && currArt.keys;
242
251
  }
243
- } else {
244
- keysOfPreviousStepWhenManagedAssoc =
245
- (currArt.type === 'cds.Association' || currArt.type === 'cds.Composition') && currArt.keys;
246
252
  }
253
+ node.ref = aliasedRef;
247
254
  }
248
- node.ref = aliasedRef;
249
255
  })
250
256
  }
251
257
  }
@@ -71,7 +71,7 @@ function flattenCSN(csn, csnUtils, options, referenceFlattener, error, isExterna
71
71
  * @param {Function} error
72
72
  */
73
73
  function flattenDefinition(definition, definitionPath, csnUtils, options, referenceFlattener, error) {
74
- if (definition.kind !== 'entity' && definition.kind !== 'view')
74
+ if (definition.kind !== 'entity')
75
75
  return;
76
76
 
77
77
  let { newFlatElements } = flattenStructure(definition.elements, definitionPath, csnUtils, options, error, referenceFlattener);
@@ -2,7 +2,7 @@
2
2
 
3
3
  const {
4
4
  forEachDefinition, forEachMemberRecursively,
5
- isBuiltinType, cloneCsnDictionary,
5
+ isBuiltinType, cloneCsnDictionary, cloneCsn,
6
6
  } = require('../../model/csnUtils');
7
7
  const { isArtifactInSomeService, isArtifactInService } = require('./utils');
8
8
 
@@ -86,21 +86,95 @@ function expandToFinalBaseType(csn, transformers, csnUtils, services, options, i
86
86
  // EDMX at the moment and the reference in the OData CSN is fulfilled.
87
87
  if (node.kind === 'event') return;
88
88
 
89
- if (isExpandable(node, defName) || node.kind === 'type') {
90
- transformers.toFinalBaseType(node);
91
- if (node.type && !isBuiltinType(node.type)) {
92
- // handle array of defined via a named type
93
- // example in actions: 'action act() return Primitive; type Primitive: array of String;'
94
- const currService = csnUtils.getServiceName(defName);
95
- const finalType = csnUtils.getFinalTypeDef(node.type);
96
- if (finalType.items && isBuiltinType(finalType.items.type)) {
97
- if (!isArtifactInService(node.type, currService) || !isV4) {
98
- node.items = finalType.items;
89
+ // elements have precedence over type
90
+ if (node.type && (!isBuiltinType(node.type) &&isExpandable(node, defName) || node.kind === 'type')) {
91
+ // 1. Get the final type of the node (resolve derived type chain)
92
+ const finalType = csnUtils.getFinalBaseType(node.type);
93
+ if (finalType) {
94
+ // The type replacement depends on whether 'node' is a definition or a member[element].
95
+ if (node.kind) {
96
+ // It is a definition and we expand to builtin type and to elements
97
+ // type T: S; --> Integer;
98
+ // type S: X; --> Integer;
99
+ // type X: Integer;
100
+ //
101
+ // type A: B; -> {...}
102
+ // type B: C; -> { ... }
103
+ // type C { .... };
104
+ if (isBuiltinType(finalType)) {
105
+ // use transformUrilsNew::toFinalBaseType for the moment,
106
+ // as it is collects along the chain of types
107
+ // attributes that need to be propagated
108
+ // enum, length, scale, etc.
109
+ transformers.toFinalBaseType(node);
110
+ // node.type = finalType;
111
+ }
112
+ else if (csnUtils.isStructured(finalType)) {
113
+ cloneElements(finalType);
114
+ }
115
+ else if (node.type && node.items)
99
116
  delete node.type;
117
+ }
118
+ else {
119
+ // this is a member and we expand to final base only if builtin
120
+ // type T: S; --> Integer;
121
+ // type S: X; --> Integer;
122
+ // type X: Integer;
123
+ //
124
+ // type {
125
+ // struct_elt: many A; ---> stays the same
126
+ // scalar_elt: T; ---> Integer;
127
+ // type_ref_elt: type of struct_elt;
128
+ // };
129
+ // type A: B; -> {...}
130
+ // type B: C; -> { ... }
131
+ // type C { .... };
132
+ if (isBuiltinType(finalType)) {
133
+ // use transformUrilsNew::toFinalBaseType for the moment,
134
+ // as it is collects along the chain of types
135
+ // attributes that need to be propagated
136
+ // enum, length, scale, etc.
137
+ transformers.toFinalBaseType(node);
138
+ // node.type = finalType;
139
+ }
140
+ else if (node.type && node.type.ref) {
141
+ cloneElements(finalType);
100
142
  }
101
143
  }
102
144
  }
103
145
  }
146
+ if (node.type && !isBuiltinType(node.type)) {
147
+ // handle array of defined via a named type
148
+ // example in actions: 'action act() return Primitive; type Primitive: array of String;'
149
+ const currService = csnUtils.getServiceName(defName);
150
+ const finalType = csnUtils.getFinalTypeDef(node.type);
151
+ if (finalType.items && isBuiltinType(finalType.items.type)) {
152
+ if (!isArtifactInService(node.type, currService) || !isV4) {
153
+ node.items = finalType.items;
154
+ delete node.type;
155
+ }
156
+ }
157
+ }
158
+
159
+ function cloneElements(finalType) {
160
+ // cloneCsn only works correctly if we start "from the top"
161
+ let clone;
162
+ // do the clone only if really needed
163
+ if((finalType.items && !node.items) ||
164
+ (finalType.elements && !node.elements))
165
+ clone = cloneCsn({ definitions: { 'TypeDef': finalType } }, options);
166
+ if (finalType.items) {
167
+ delete node.type;
168
+ if(!node.items)
169
+ Object.assign(node, { items: clone.definitions.TypeDef.items });
170
+ }
171
+ if (finalType.elements) {
172
+ if(!finalType.items)
173
+ delete node.type;
174
+ if(!node.elements)
175
+ Object.assign(node, { elements: clone.definitions.TypeDef.elements });
176
+ }
177
+ }
104
178
  }
105
179
 
106
180
  function isExpandable(node, defName) {
@@ -119,4 +193,4 @@ function expandToFinalBaseType(csn, transformers, csnUtils, services, options, i
119
193
  }
120
194
  }
121
195
 
122
- module.exports = expandToFinalBaseType;
196
+ module.exports = expandToFinalBaseType;
@@ -18,7 +18,7 @@ const { copyAnnotations } = require('../../model/csnUtils');
18
18
  * @param {*} csnUtils
19
19
  * @param {object} message message object with { error } function
20
20
  */
21
- function typesExposure(csn, whatsMyServiceName, options, csnUtils, message) {
21
+ function typesExposure(csn, whatsMyServiceName, autoexposeSchemaName, options, csnUtils, message) {
22
22
  const { error } = message;
23
23
  // are we working with OData proxies or cross-service refs
24
24
  const isMultiSchema = options.toOdata.version === 'v4' && (options.toOdata.odataProxies || options.toOdata.odataXServiceRefs);
@@ -30,9 +30,9 @@ function typesExposure(csn, whatsMyServiceName, options, csnUtils, message) {
30
30
  // we do expose types only for definition from inside services
31
31
  const serviceName = whatsMyServiceName(defName, false);
32
32
  if (serviceName) {
33
- if (['type', 'entity', 'view'].includes(def.kind)) {
33
+ if (def.kind === 'type' || def.kind === 'entity') {
34
34
  forEachMember(def, (element, elementName, propertyName, path) => {
35
- if (['elements', 'params'].includes(propertyName)) {
35
+ if (propertyName === 'elements' || propertyName === 'params') {
36
36
  const artificialtName = `${isMultiSchema ?
37
37
  defNameWithoutServiceOrContextName(defName, serviceName)
38
38
  : defNameWithoutServiceOrContextName(defName, serviceName).replace(/\./g, '_')}_${elementName}`;
@@ -190,7 +190,7 @@ function typesExposure(csn, whatsMyServiceName, options, csnUtils, message) {
190
190
  } else {
191
191
  const typeContext = csnUtils.getContextOfArtifact(typeName);
192
192
  const typeNamespace = csnUtils.getNamespaceOfArtifact(typeName);
193
- const newSchemaName = `${service}.${typeContext || typeNamespace || 'root'}`;
193
+ const newSchemaName = `${service}.${typeContext || typeNamespace || autoexposeSchemaName}`;
194
194
  // new type name without any prefixes
195
195
  const typePlainName = typeContext ? defNameWithoutServiceOrContextName(typeName, typeContext)
196
196
  : typeName.replace(`${typeNamespace}.`, '');
@@ -209,7 +209,7 @@ function typesExposure(csn, whatsMyServiceName, options, csnUtils, message) {
209
209
  */
210
210
  function getAnonymousTypeNameInMultiSchema(typeName, parentName) {
211
211
  let currPrefix = parentName.substring(0, parentName.lastIndexOf('.'));
212
- const newSchemaName = currPrefix || 'root';
212
+ const newSchemaName = currPrefix || autoexposeSchemaName;
213
213
  // new type name without any prefixes
214
214
  const typePlainName = defNameWithoutServiceOrContextName(typeName, newSchemaName);
215
215
 
@@ -18,7 +18,7 @@ function isAssociationOrComposition(artifact) {
18
18
  return isAssociation(artifact) || isComposition(artifact);
19
19
  }
20
20
 
21
- function isManagedAssociationElement(artifact) {
21
+ function isManagedAssociation(artifact) {
22
22
  return artifact.target !== undefined && artifact.on === undefined;
23
23
  }
24
24
 
@@ -94,5 +94,5 @@ module.exports = {
94
94
  isArtifactInSomeService,
95
95
  isAssociationOrComposition,
96
96
  isLocalizedArtifactInService,
97
- isManagedAssociationElement,
97
+ isManagedAssociation,
98
98
  }