@finos/legend-application-studio 18.0.0 → 18.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/lib/components/editor/edit-panel/FunctionEditor.d.ts.map +1 -1
  2. package/lib/components/editor/edit-panel/FunctionEditor.js +3 -3
  3. package/lib/components/editor/edit-panel/FunctionEditor.js.map +1 -1
  4. package/lib/components/editor/edit-panel/connection-editor/post-processor-editor/MapperPostProcessorEditor.js +1 -1
  5. package/lib/components/editor/edit-panel/connection-editor/post-processor-editor/MapperPostProcessorEditor.js.map +1 -1
  6. package/lib/components/editor/edit-panel/mapping-editor/PropertyMappingsEditor.d.ts.map +1 -1
  7. package/lib/components/editor/edit-panel/mapping-editor/PropertyMappingsEditor.js +39 -27
  8. package/lib/components/editor/edit-panel/mapping-editor/PropertyMappingsEditor.js.map +1 -1
  9. package/lib/components/editor/edit-panel/uml-editor/AssociationEditor.d.ts.map +1 -1
  10. package/lib/components/editor/edit-panel/uml-editor/AssociationEditor.js +2 -2
  11. package/lib/components/editor/edit-panel/uml-editor/AssociationEditor.js.map +1 -1
  12. package/lib/components/editor/edit-panel/uml-editor/ClassEditor.d.ts.map +1 -1
  13. package/lib/components/editor/edit-panel/uml-editor/ClassEditor.js +3 -3
  14. package/lib/components/editor/edit-panel/uml-editor/ClassEditor.js.map +1 -1
  15. package/lib/index.css +2 -2
  16. package/lib/index.css.map +1 -1
  17. package/lib/package.json +1 -1
  18. package/lib/stores/editor-state/element-editor-state/mapping/MappingElementDecorator.d.ts.map +1 -1
  19. package/lib/stores/editor-state/element-editor-state/mapping/MappingElementDecorator.js +22 -26
  20. package/lib/stores/editor-state/element-editor-state/mapping/MappingElementDecorator.js.map +1 -1
  21. package/lib/stores/editor-state/element-editor-state/service/ServiceRegistrationState.d.ts.map +1 -1
  22. package/lib/stores/editor-state/element-editor-state/service/ServiceRegistrationState.js +12 -2
  23. package/lib/stores/editor-state/element-editor-state/service/ServiceRegistrationState.js.map +1 -1
  24. package/lib/stores/graphModifier/DSL_Mapping_GraphModifierHelper.d.ts +2 -1
  25. package/lib/stores/graphModifier/DSL_Mapping_GraphModifierHelper.d.ts.map +1 -1
  26. package/lib/stores/graphModifier/DSL_Mapping_GraphModifierHelper.js +4 -1
  27. package/lib/stores/graphModifier/DSL_Mapping_GraphModifierHelper.js.map +1 -1
  28. package/package.json +5 -5
  29. package/src/components/editor/edit-panel/FunctionEditor.tsx +2 -3
  30. package/src/components/editor/edit-panel/connection-editor/post-processor-editor/MapperPostProcessorEditor.tsx +1 -1
  31. package/src/components/editor/edit-panel/mapping-editor/PropertyMappingsEditor.tsx +217 -112
  32. package/src/components/editor/edit-panel/uml-editor/AssociationEditor.tsx +4 -2
  33. package/src/components/editor/edit-panel/uml-editor/ClassEditor.tsx +5 -3
  34. package/src/stores/editor-state/element-editor-state/mapping/MappingElementDecorator.ts +44 -52
  35. package/src/stores/editor-state/element-editor-state/service/ServiceRegistrationState.ts +39 -0
  36. package/src/stores/graphModifier/DSL_Mapping_GraphModifierHelper.ts +12 -1
@@ -70,7 +70,7 @@ import {
70
70
  enumMapping_setEnumValueMappings,
71
71
  enumValueMapping_addSourceValue,
72
72
  enumValueMapping_setSourceValues,
73
- mapping_setPropertyMappings,
73
+ instanceSetImpl_setPropertyMappings,
74
74
  operationMapping_setParameters,
75
75
  pureInstanceSetImpl_setPropertyMappings,
76
76
  purePropertyMapping_setTransformer,
@@ -208,14 +208,8 @@ export class MappingElementDecorator implements SetImplementationVisitor<void> {
208
208
  propertyType instanceof Unit ||
209
209
  propertyType instanceof Measure
210
210
  ) {
211
- // only allow one property mapping per primitive property
212
- assertTrue(
213
- !existingPropertyMappings.length ||
214
- existingPropertyMappings.length === 1,
215
- 'Only one property mapping should exist per simple type (e.g. primitive, measure, unit) property',
216
- );
217
211
  return existingPropertyMappings.length
218
- ? [existingPropertyMappings[0] as PurePropertyMapping]
212
+ ? existingPropertyMappings
219
213
  : [
220
214
  new PurePropertyMapping(
221
215
  setImplementation,
@@ -226,14 +220,8 @@ export class MappingElementDecorator implements SetImplementationVisitor<void> {
226
220
  ),
227
221
  ];
228
222
  } else if (propertyType instanceof Enumeration) {
229
- // only allow one property mapping per enumeration property
230
- assertTrue(
231
- !existingPropertyMappings.length ||
232
- existingPropertyMappings.length === 1,
233
- 'Only one property mapping should exist per enumeration type property',
234
- );
235
223
  const enumerationPropertyMapping = existingPropertyMappings.length
236
- ? [existingPropertyMappings[0] as PurePropertyMapping]
224
+ ? existingPropertyMappings
237
225
  : [
238
226
  new PurePropertyMapping(
239
227
  setImplementation,
@@ -323,10 +311,15 @@ export class MappingElementDecorator implements SetImplementationVisitor<void> {
323
311
  pureInstanceSetImpl_setPropertyMappings(
324
312
  setImplementation,
325
313
  decoratedPropertyMappings.concat(
326
- propertyMappingsBeforeDecoration.filter(
327
- (propertyMapping) =>
328
- !decoratedPropertyMappings.includes(propertyMapping),
329
- ),
314
+ propertyMappingsBeforeDecoration
315
+ .filter(
316
+ (propertyMapping) =>
317
+ !isStubbed_RawLambda(propertyMapping.transform),
318
+ )
319
+ .filter(
320
+ (propertyMapping) =>
321
+ !decoratedPropertyMappings.includes(propertyMapping),
322
+ ),
330
323
  ),
331
324
  this.editorStore.changeDetectionState.observerContext,
332
325
  );
@@ -355,14 +348,8 @@ export class MappingElementDecorator implements SetImplementationVisitor<void> {
355
348
  propertyType instanceof Unit ||
356
349
  propertyType instanceof Measure
357
350
  ) {
358
- // only allow one property mapping per primitive property
359
- assertTrue(
360
- !existingPropertyMappings.length ||
361
- existingPropertyMappings.length === 1,
362
- 'Only one property mapping should exist per simple type (e.g. primitive, measure, unit) property',
363
- );
364
351
  return existingPropertyMappings.length
365
- ? [existingPropertyMappings[0] as FlatDataPropertyMapping]
352
+ ? existingPropertyMappings
366
353
  : [
367
354
  new FlatDataPropertyMapping(
368
355
  setImplementation,
@@ -439,13 +426,20 @@ export class MappingElementDecorator implements SetImplementationVisitor<void> {
439
426
  setImplementation,
440
427
  decoratePropertyMapping,
441
428
  );
442
- mapping_setPropertyMappings(
429
+ instanceSetImpl_setPropertyMappings(
443
430
  setImplementation,
444
431
  decoratedPropertyMappings.concat(
445
- propertyMappingsBeforeDecoration.filter(
446
- (propertyMapping) =>
447
- !decoratedPropertyMappings.includes(propertyMapping),
448
- ),
432
+ propertyMappingsBeforeDecoration
433
+ .filter(
434
+ (propertyMapping) =>
435
+ (propertyMapping instanceof FlatDataPropertyMapping &&
436
+ !isStubbed_RawLambda(propertyMapping.transform)) ||
437
+ propertyMapping instanceof EmbeddedFlatDataPropertyMapping,
438
+ )
439
+ .filter(
440
+ (propertyMapping) =>
441
+ !decoratedPropertyMappings.includes(propertyMapping),
442
+ ),
449
443
  ),
450
444
  this.editorStore.changeDetectionState.observerContext,
451
445
  );
@@ -486,15 +480,9 @@ export class MappingElementDecorator implements SetImplementationVisitor<void> {
486
480
  propertyType instanceof Unit ||
487
481
  propertyType instanceof Measure
488
482
  ) {
489
- // only allow one property mapping per primitive property
490
- assertTrue(
491
- !existingPropertyMappings.length ||
492
- existingPropertyMappings.length === 1,
493
- 'Only one property mapping should exist per simple type (e.g. primitive, measure, unit) property',
494
- );
495
483
  if (existingPropertyMappings.length) {
496
484
  // TODO?: do we want to check the type of the property mapping here?
497
- return [existingPropertyMappings[0] as PropertyMapping];
485
+ return existingPropertyMappings;
498
486
  }
499
487
  const newPropertyMapping = new RelationalPropertyMapping(
500
488
  setImplementation,
@@ -506,16 +494,10 @@ export class MappingElementDecorator implements SetImplementationVisitor<void> {
506
494
  stub_RawRelationalOperationElement();
507
495
  return [newPropertyMapping];
508
496
  } else if (propertyType instanceof Enumeration) {
509
- // only allow one property mapping per enumeration property
510
- assertTrue(
511
- !existingPropertyMappings.length ||
512
- existingPropertyMappings.length === 1,
513
- 'Only one property mapping should exist per enumeration type property',
514
- );
515
497
  let ePropertyMapping: PropertyMapping[] = [];
516
498
  if (existingPropertyMappings.length) {
517
499
  // TODO?: do we want to check the type of the property mapping here?
518
- ePropertyMapping = [existingPropertyMappings[0] as PropertyMapping];
500
+ ePropertyMapping = existingPropertyMappings;
519
501
  } else {
520
502
  const newPropertyMapping = new RelationalPropertyMapping(
521
503
  setImplementation,
@@ -613,13 +595,23 @@ export class MappingElementDecorator implements SetImplementationVisitor<void> {
613
595
  setImplementation,
614
596
  decoratePropertyMapping,
615
597
  );
616
- mapping_setPropertyMappings(
598
+ instanceSetImpl_setPropertyMappings(
617
599
  setImplementation,
618
600
  decoratedPropertyMappings.concat(
619
- propertyMappingsBeforeDecoration.filter(
620
- (propertyMapping) =>
621
- !decoratedPropertyMappings.includes(propertyMapping),
622
- ),
601
+ propertyMappingsBeforeDecoration
602
+ .filter(
603
+ (propertyMapping) =>
604
+ (propertyMapping instanceof RelationalPropertyMapping &&
605
+ !isStubbed_RawRelationalOperationElement(
606
+ propertyMapping.relationalOperation,
607
+ )) ||
608
+ propertyMapping instanceof
609
+ EmbeddedRelationalInstanceSetImplementation,
610
+ )
611
+ .filter(
612
+ (propertyMapping) =>
613
+ !decoratedPropertyMappings.includes(propertyMapping),
614
+ ),
623
615
  ),
624
616
  this.editorStore.changeDetectionState.observerContext,
625
617
  );
@@ -708,7 +700,7 @@ export class MappingElementDecorationCleaner
708
700
  visit_PureInstanceSetImplementation(
709
701
  setImplementation: PureInstanceSetImplementation,
710
702
  ): void {
711
- mapping_setPropertyMappings(
703
+ instanceSetImpl_setPropertyMappings(
712
704
  setImplementation,
713
705
  setImplementation.propertyMappings.filter(
714
706
  (propertyMapping) => !isStubbed_RawLambda(propertyMapping.transform),
@@ -722,7 +714,7 @@ export class MappingElementDecorationCleaner
722
714
  | FlatDataInstanceSetImplementation
723
715
  | EmbeddedFlatDataPropertyMapping,
724
716
  ): void {
725
- mapping_setPropertyMappings(
717
+ instanceSetImpl_setPropertyMappings(
726
718
  setImplementation,
727
719
  setImplementation.propertyMappings.filter(
728
720
  (propertyMapping) =>
@@ -29,13 +29,20 @@ import {
29
29
  getNullableFirstElement,
30
30
  assertTrue,
31
31
  URL_SEPARATOR,
32
+ filterByType,
32
33
  } from '@finos/legend-shared';
33
34
  import { LEGEND_STUDIO_APP_EVENT } from '../../../LegendStudioAppEvent.js';
34
35
  import { Version } from '@finos/legend-server-sdlc';
35
36
  import {
36
37
  type Service,
37
38
  type ServiceRegistrationResult,
39
+ type PureExecution,
38
40
  ServiceExecutionMode,
41
+ buildLambdaVariableExpressions,
42
+ VariableExpression,
43
+ TYPICAL_MULTIPLICITY_TYPE,
44
+ generateMultiplicityString,
45
+ multiplicityComparator,
39
46
  } from '@finos/legend-graph';
40
47
  import { ServiceRegistrationEnvironmentConfig } from '../../../../application/LegendStudioApplicationConfig.js';
41
48
  import {
@@ -314,5 +321,37 @@ export class ServiceRegistrationState {
314
321
  'Service version can not be empty in Semi-interactive and Prod service type',
315
322
  );
316
323
  }
324
+
325
+ // validate service parameter multiplicities
326
+ const supportedServiceParamMultiplicties = [
327
+ TYPICAL_MULTIPLICITY_TYPE.ONE,
328
+ TYPICAL_MULTIPLICITY_TYPE.ZEROMANY,
329
+ TYPICAL_MULTIPLICITY_TYPE.ZEROONE,
330
+ ].map((p) =>
331
+ this.editorStore.graphManagerState.graph.getTypicalMultiplicity(p),
332
+ );
333
+ const invalidParams = buildLambdaVariableExpressions(
334
+ (this.service.execution as PureExecution).func,
335
+ this.editorStore.graphManagerState,
336
+ )
337
+ .filter(filterByType(VariableExpression))
338
+ .filter(
339
+ (p) =>
340
+ !supportedServiceParamMultiplicties.some((m) =>
341
+ multiplicityComparator(m, p.multiplicity),
342
+ ),
343
+ );
344
+ assertTrue(
345
+ invalidParams.length === 0,
346
+ `Parameter(s)${invalidParams.map(
347
+ (p) =>
348
+ ` ${p.name}: [${generateMultiplicityString(
349
+ p.multiplicity.lowerBound,
350
+ p.multiplicity.upperBound,
351
+ )}]`,
352
+ )} has/have unsupported multiplicity. Supported multiplicities include ${supportedServiceParamMultiplicties.map(
353
+ (m) => ` [${generateMultiplicityString(m.lowerBound, m.upperBound)}]`,
354
+ )}.`,
355
+ );
317
356
  }
318
357
  }
@@ -86,7 +86,7 @@ import {
86
86
  } from '@finos/legend-shared';
87
87
  import { action } from 'mobx';
88
88
 
89
- export const mapping_setPropertyMappings = action(
89
+ export const instanceSetImpl_setPropertyMappings = action(
90
90
  (
91
91
  si: InstanceSetImplementation,
92
92
  pm: PropertyMapping[],
@@ -97,6 +97,17 @@ export const mapping_setPropertyMappings = action(
97
97
  );
98
98
  },
99
99
  );
100
+
101
+ export const instanceSetImpl_deletePropertyMapping = action(
102
+ (si: InstanceSetImplementation, pm: PropertyMapping): void => {
103
+ deleteEntry(
104
+ si.propertyMappings,
105
+ pm,
106
+ (p1, p2) => p1.property._UUID === p2.property._UUID,
107
+ );
108
+ },
109
+ );
110
+
100
111
  export const setImpl_setRoot = action(
101
112
  (owner: SetImplementation, val: boolean): void => {
102
113
  owner.root.value = val;