@finos/legend-application-studio 22.1.4 → 22.1.6

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 (51) hide show
  1. package/lib/components/DSL_ExternalFormat_LegendStudioApplicationPlugin.d.ts +3 -1
  2. package/lib/components/DSL_ExternalFormat_LegendStudioApplicationPlugin.d.ts.map +1 -1
  3. package/lib/components/DSL_ExternalFormat_LegendStudioApplicationPlugin.js +15 -3
  4. package/lib/components/DSL_ExternalFormat_LegendStudioApplicationPlugin.js.map +1 -1
  5. package/lib/components/editor/edit-panel/GrammarTextEditor.d.ts.map +1 -1
  6. package/lib/components/editor/edit-panel/GrammarTextEditor.js +8 -0
  7. package/lib/components/editor/edit-panel/GrammarTextEditor.js.map +1 -1
  8. package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_ExternalFormatConnectionEditor.d.ts +1 -0
  9. package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_ExternalFormatConnectionEditor.d.ts.map +1 -1
  10. package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_ExternalFormatConnectionEditor.js +4 -0
  11. package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_ExternalFormatConnectionEditor.js.map +1 -1
  12. package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.d.ts.map +1 -1
  13. package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.js +9 -11
  14. package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.js.map +1 -1
  15. package/lib/components/editor/side-bar/CreateNewElementModal.d.ts.map +1 -1
  16. package/lib/components/editor/side-bar/CreateNewElementModal.js +28 -23
  17. package/lib/components/editor/side-bar/CreateNewElementModal.js.map +1 -1
  18. package/lib/index.css +2 -2
  19. package/lib/index.css.map +1 -1
  20. package/lib/package.json +1 -1
  21. package/lib/stores/DSL_Mapping_LegendStudioApplicationPlugin_Extension.d.ts +15 -1
  22. package/lib/stores/DSL_Mapping_LegendStudioApplicationPlugin_Extension.d.ts.map +1 -1
  23. package/lib/stores/editor/NewElementState.d.ts +14 -9
  24. package/lib/stores/editor/NewElementState.d.ts.map +1 -1
  25. package/lib/stores/editor/NewElementState.js +38 -19
  26. package/lib/stores/editor/NewElementState.js.map +1 -1
  27. package/lib/stores/editor-state/FileGenerationState.d.ts.map +1 -1
  28. package/lib/stores/editor-state/FileGenerationState.js +3 -3
  29. package/lib/stores/editor-state/FileGenerationState.js.map +1 -1
  30. package/lib/stores/editor-state/ModelImporterState.js +1 -1
  31. package/lib/stores/editor-state/ModelImporterState.js.map +1 -1
  32. package/lib/stores/editor-state/element-editor-state/external-format/DSL_ExternalFormat_SchemaSetEditorState.d.ts +2 -1
  33. package/lib/stores/editor-state/element-editor-state/external-format/DSL_ExternalFormat_SchemaSetEditorState.d.ts.map +1 -1
  34. package/lib/stores/editor-state/element-editor-state/external-format/DSL_ExternalFormat_SchemaSetEditorState.js +26 -12
  35. package/lib/stores/editor-state/element-editor-state/external-format/DSL_ExternalFormat_SchemaSetEditorState.js.map +1 -1
  36. package/lib/stores/shared/modifier/DSL_Generation_GraphModifierHelper.d.ts +1 -1
  37. package/lib/stores/shared/modifier/DSL_Generation_GraphModifierHelper.d.ts.map +1 -1
  38. package/lib/stores/shared/modifier/DSL_Generation_GraphModifierHelper.js +3 -3
  39. package/lib/stores/shared/modifier/DSL_Generation_GraphModifierHelper.js.map +1 -1
  40. package/package.json +4 -4
  41. package/src/components/DSL_ExternalFormat_LegendStudioApplicationPlugin.tsx +17 -3
  42. package/src/components/editor/edit-panel/GrammarTextEditor.tsx +14 -0
  43. package/src/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_ExternalFormatConnectionEditor.tsx +5 -0
  44. package/src/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.tsx +27 -26
  45. package/src/components/editor/side-bar/CreateNewElementModal.tsx +50 -43
  46. package/src/stores/DSL_Mapping_LegendStudioApplicationPlugin_Extension.ts +19 -1
  47. package/src/stores/editor/NewElementState.ts +57 -28
  48. package/src/stores/editor-state/FileGenerationState.ts +9 -3
  49. package/src/stores/editor-state/ModelImporterState.ts +1 -1
  50. package/src/stores/editor-state/element-editor-state/external-format/DSL_ExternalFormat_SchemaSetEditorState.ts +44 -15
  51. package/src/stores/shared/modifier/DSL_Generation_GraphModifierHelper.ts +10 -9
@@ -23,9 +23,9 @@ import {
23
23
  NewPureModelConnectionDriver,
24
24
  NewFileGenerationDriver,
25
25
  resolvePackageAndElementName,
26
- CONNECTION_TYPE,
27
26
  NewDataElementDriver,
28
27
  NewServiceDriver,
28
+ CONNECTION_TYPE,
29
29
  } from '../../../stores/editor/NewElementState.js';
30
30
  import { Dialog, compareLabelFn, CustomSelectorInput } from '@finos/legend-art';
31
31
  import type { EditorStore } from '../../../stores/EditorStore.js';
@@ -50,6 +50,7 @@ import type { EmbeddedDataTypeOption } from '../../../stores/editor-state/elemen
50
50
  import type { DSL_Data_LegendStudioApplicationPlugin_Extension } from '../../../stores/DSL_Data_LegendStudioApplicationPlugin_Extension.js';
51
51
  import { PACKAGEABLE_ELEMENT_TYPE } from '../../../stores/shared/ModelClassifierUtils.js';
52
52
  import { EmbeddedDataType } from '../../../stores/editor-state/ExternalFormatState.js';
53
+ import type { DSL_Mapping_LegendStudioApplicationPlugin_Extension } from '../../../stores/DSL_Mapping_LegendStudioApplicationPlugin_Extension.js';
53
54
 
54
55
  export const getElementTypeLabel = (
55
56
  editorStore: EditorStore,
@@ -194,31 +195,9 @@ const NewRuntimeDriverEditor = observer(() => {
194
195
  });
195
196
 
196
197
  const NewPureModelConnectionDriverEditor = observer(
197
- (props: {
198
- newConnectionDriver: NewPackageableConnectionDriver;
199
- newConnectionValueDriver: NewPureModelConnectionDriver;
200
- }) => {
201
- const { newConnectionDriver, newConnectionValueDriver } = props;
198
+ (props: { newConnectionValueDriver: NewPureModelConnectionDriver }) => {
199
+ const { newConnectionValueDriver } = props;
202
200
  const editorStore = useEditorStore();
203
- // store
204
- const store = newConnectionDriver.store;
205
- let storeOptions: { label: string; value?: Store | undefined }[] = [
206
- { label: 'ModelStore', value: undefined },
207
- ];
208
- storeOptions = storeOptions.concat(
209
- editorStore.graphManagerState.usableStores
210
- .map(buildElementOption)
211
- .slice()
212
- .sort(compareLabelFn),
213
- );
214
- const selectedStoreOption = {
215
- label: store?.path ?? 'ModelStore',
216
- value: store,
217
- };
218
- const onStoreSelectionChange = (val: {
219
- label: string;
220
- value?: Store;
221
- }): void => newConnectionDriver.setStore(val.value);
222
201
  // class
223
202
  const _class = newConnectionValueDriver.class;
224
203
  const classOptions = editorStore.graphManagerState.usableClasses
@@ -242,18 +221,6 @@ const NewPureModelConnectionDriverEditor = observer(
242
221
  }
243
222
  return (
244
223
  <>
245
- <div className="panel__content__form__section__header__label">
246
- Source Store
247
- </div>
248
- <div className="explorer__new-element-modal__driver">
249
- <CustomSelectorInput
250
- className="explorer__new-element-modal__driver__dropdown"
251
- options={storeOptions}
252
- onChange={onStoreSelectionChange}
253
- value={selectedStoreOption}
254
- darkMode={true}
255
- />
256
- </div>
257
224
  <div className="panel__content__form__section__header__label">
258
225
  Source Class
259
226
  </div>
@@ -283,7 +250,6 @@ const NewConnectionValueDriverEditor = observer(() => {
283
250
  if (newConnectionValueDriver instanceof NewPureModelConnectionDriver) {
284
251
  return (
285
252
  <NewPureModelConnectionDriverEditor
286
- newConnectionDriver={newConnectionDriver}
287
253
  newConnectionValueDriver={newConnectionValueDriver}
288
254
  />
289
255
  );
@@ -302,17 +268,46 @@ const NewConnectionDriverEditor = observer(() => {
302
268
  label: prettyCONSTName(currentConnectionType),
303
269
  value: currentConnectionType,
304
270
  };
305
- const connectionOptions = Object.values(CONNECTION_TYPE).map((e) => ({
306
- label: prettyCONSTName(e),
307
- value: e,
308
- }));
271
+ const extraOptionTypes = editorStore.pluginManager
272
+ .getApplicationPlugins()
273
+ .flatMap(
274
+ (plugin) =>
275
+ (
276
+ plugin as DSL_Mapping_LegendStudioApplicationPlugin_Extension
277
+ ).getExtraConnectionTypeOptions?.() ?? [],
278
+ );
279
+ const connectionOptions = Object.values(CONNECTION_TYPE)
280
+ .map((typeOption) => ({
281
+ label: prettyCONSTName(typeOption),
282
+ value: typeOption.toString(),
283
+ }))
284
+ .concat(extraOptionTypes);
309
285
  const onConnectionChange = (
310
- val: { label: CONNECTION_TYPE; value: CONNECTION_TYPE } | null,
286
+ val: { label: string; value: string } | null,
311
287
  ): void => {
312
288
  if (val?.value && currentConnectionTypeOption.value !== val.value) {
313
289
  newConnectionDriver.changeConnectionState(val.value);
314
290
  }
315
291
  };
292
+
293
+ // store
294
+ const store = newConnectionDriver.store;
295
+ let storeOptions: { label: string; value?: Store | undefined }[] = [
296
+ { label: 'ModelStore', value: undefined },
297
+ ];
298
+ storeOptions = storeOptions.concat(
299
+ editorStore.graphManagerState.usableStores
300
+ .map(buildElementOption)
301
+ .slice()
302
+ .sort(compareLabelFn),
303
+ );
304
+ const selectedStoreOption = {
305
+ label: store.path,
306
+ value: store,
307
+ };
308
+ const onStoreSelectionChange = (val: { label: string; value: Store }): void =>
309
+ newConnectionDriver.setStore(val.value);
310
+
316
311
  return (
317
312
  <>
318
313
  <div className="panel__content__form__section__header__label">
@@ -327,6 +322,18 @@ const NewConnectionDriverEditor = observer(() => {
327
322
  darkMode={true}
328
323
  />
329
324
  </div>
325
+ <div className="panel__content__form__section__header__label">
326
+ Source Store
327
+ </div>
328
+ <div className="explorer__new-element-modal__driver">
329
+ <CustomSelectorInput
330
+ className="explorer__new-element-modal__driver__dropdown"
331
+ options={storeOptions}
332
+ onChange={onStoreSelectionChange}
333
+ value={selectedStoreOption}
334
+ darkMode={true}
335
+ />
336
+ </div>
330
337
  <NewConnectionValueDriverEditor />
331
338
  </>
332
339
  );
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ import type { PureGrammarTextSuggestion } from '@finos/legend-application';
17
18
  import type { DSL_LegendStudioApplicationPlugin_Extension } from './LegendStudioApplicationPlugin.js';
18
19
  import type { ConnectionValueState } from './editor-state/element-editor-state/connection/ConnectionEditorState.js';
19
20
  import type { EditorStore } from './EditorStore.js';
@@ -86,9 +87,16 @@ export type RuntimeConnectionTooltipTextBuilder = (
86
87
 
87
88
  export type NewConnectionDriverCreator = (
88
89
  editorStore: EditorStore,
89
- store: Store,
90
+ typeOrStore: Store | string,
90
91
  ) => NewConnectionValueDriver<Connection> | undefined;
91
92
 
93
+ export type ConnectionTypeOption = {
94
+ value: string;
95
+ label: string;
96
+ };
97
+
98
+ export type NewConnectionSnippetSuggestion = PureGrammarTextSuggestion;
99
+
92
100
  /**
93
101
  * @returns a boolean indicating whether the update has ocurred or not
94
102
  */
@@ -141,6 +149,11 @@ export interface DSL_Mapping_LegendStudioApplicationPlugin_Extension
141
149
  */
142
150
  getExtraMappingElementSourceExtractors?(): MappingElementSourceExtractor[];
143
151
 
152
+ /**
153
+ * Get extra connection type options.
154
+ */
155
+ getExtraConnectionTypeOptions?(): ConnectionTypeOption[];
156
+
144
157
  /**
145
158
  * Get the list of the default connection value builder for a specified store.
146
159
  */
@@ -166,6 +179,11 @@ export interface DSL_Mapping_LegendStudioApplicationPlugin_Extension
166
179
  */
167
180
  getExtraNewConnectionDriverCreators?(): NewConnectionDriverCreator[];
168
181
 
182
+ /**
183
+ * Get the list of creators for connection creation state driver given the store.
184
+ */
185
+ getExtraNewConnectionSnippetSuggestions?(): NewConnectionSnippetSuggestion[];
186
+
169
187
  /**
170
188
  * Get the list of instance set implementation source updaters.
171
189
  */
@@ -228,9 +228,16 @@ export abstract class NewConnectionValueDriver<T extends Connection> {
228
228
  }
229
229
 
230
230
  abstract get isValid(): boolean;
231
+ abstract getConnectionType(): string;
231
232
  abstract createConnection(store: Store): T;
232
233
  }
233
234
 
235
+ export enum CONNECTION_TYPE {
236
+ PURE_MODEL_CONNECTION = 'MODEL_CONNECTION',
237
+ FLAT_DATA_CONNECTION = 'FLAT_DATA_CONNECTION',
238
+ RELATIONAL_CONNECTION = 'RELATIONAL_CONNECTION',
239
+ }
240
+
234
241
  export class NewPureModelConnectionDriver extends NewConnectionValueDriver<PureModelConnection> {
235
242
  class?: Class | undefined;
236
243
 
@@ -257,6 +264,10 @@ export class NewPureModelConnectionDriver extends NewConnectionValueDriver<PureM
257
264
  return Boolean(this.class);
258
265
  }
259
266
 
267
+ getConnectionType(): string {
268
+ return CONNECTION_TYPE.PURE_MODEL_CONNECTION;
269
+ }
270
+
260
271
  createConnection(store: ModelStore): PureModelConnection {
261
272
  return new JsonModelConnection(
262
273
  PackageableElementExplicitReference.create(store),
@@ -280,6 +291,10 @@ export class NewFlatDataConnectionDriver extends NewConnectionValueDriver<FlatDa
280
291
  return true;
281
292
  }
282
293
 
294
+ getConnectionType(): string {
295
+ return CONNECTION_TYPE.FLAT_DATA_CONNECTION;
296
+ }
297
+
283
298
  createConnection(store: FlatData): FlatDataConnection {
284
299
  return new FlatDataConnection(
285
300
  PackageableElementExplicitReference.create(store),
@@ -300,6 +315,10 @@ export class NewRelationalDatabaseConnectionDriver extends NewConnectionValueDri
300
315
  return true;
301
316
  }
302
317
 
318
+ getConnectionType(): string {
319
+ return CONNECTION_TYPE.RELATIONAL_CONNECTION;
320
+ }
321
+
303
322
  createConnection(store: Store): RelationalDatabaseConnection {
304
323
  let selectedStore: Database;
305
324
  if (store instanceof Database) {
@@ -317,22 +336,8 @@ export class NewRelationalDatabaseConnectionDriver extends NewConnectionValueDri
317
336
  }
318
337
  }
319
338
 
320
- export enum CONNECTION_TYPE {
321
- RELATIONAL = 'RELATIONAL',
322
- MODEL_CONNECTION = 'MODEL_CONNECTION',
323
- }
324
-
325
- const getConnectionType = (
326
- val: NewConnectionValueDriver<Connection>,
327
- ): CONNECTION_TYPE => {
328
- if (val instanceof NewPureModelConnectionDriver) {
329
- return CONNECTION_TYPE.MODEL_CONNECTION;
330
- }
331
- return CONNECTION_TYPE.RELATIONAL;
332
- };
333
-
334
339
  export class NewPackageableConnectionDriver extends NewElementDriver<PackageableConnection> {
335
- store?: Store | undefined;
340
+ store: Store;
336
341
  newConnectionValueDriver: NewConnectionValueDriver<Connection>;
337
342
 
338
343
  constructor(editorStore: EditorStore) {
@@ -345,35 +350,59 @@ export class NewPackageableConnectionDriver extends NewElementDriver<Packageable
345
350
  changeConnectionState: action,
346
351
  isValid: computed,
347
352
  });
348
-
353
+ this.store = ModelStore.INSTANCE;
349
354
  this.newConnectionValueDriver =
350
- this.getNewConnectionValueDriverBasedOnStore(undefined);
355
+ this.getNewConnectionValueDriverBasedOnStore(this.store);
351
356
  }
352
357
 
353
- geDriverConnectionType(): CONNECTION_TYPE {
354
- return getConnectionType(this.newConnectionValueDriver);
358
+ geDriverConnectionType(): string {
359
+ return this.newConnectionValueDriver.getConnectionType();
355
360
  }
356
361
 
357
- changeConnectionState(val: CONNECTION_TYPE): void {
362
+ changeConnectionState(val: string): void {
358
363
  switch (val) {
359
- case CONNECTION_TYPE.MODEL_CONNECTION:
364
+ case CONNECTION_TYPE.PURE_MODEL_CONNECTION:
360
365
  this.newConnectionValueDriver = new NewPureModelConnectionDriver(
361
366
  this.editorStore,
362
367
  );
363
368
  return;
364
- case CONNECTION_TYPE.RELATIONAL:
369
+ case CONNECTION_TYPE.FLAT_DATA_CONNECTION:
370
+ this.newConnectionValueDriver = new NewFlatDataConnectionDriver(
371
+ this.editorStore,
372
+ );
373
+ return;
374
+ case CONNECTION_TYPE.RELATIONAL_CONNECTION:
365
375
  this.newConnectionValueDriver =
366
376
  new NewRelationalDatabaseConnectionDriver(this.editorStore);
367
377
  return;
368
- default:
369
- return;
378
+ default: {
379
+ const extraNewConnectionDriverCreators = this.editorStore.pluginManager
380
+ .getApplicationPlugins()
381
+ .flatMap(
382
+ (plugin) =>
383
+ (
384
+ plugin as DSL_Mapping_LegendStudioApplicationPlugin_Extension
385
+ ).getExtraNewConnectionDriverCreators?.() ?? [],
386
+ );
387
+ for (const creator of extraNewConnectionDriverCreators) {
388
+ const driver = creator(this.editorStore, val);
389
+ if (driver) {
390
+ this.newConnectionValueDriver = driver;
391
+ return;
392
+ }
393
+ }
394
+ throw new UnsupportedOperationError(
395
+ `Can't create new connection driver for type: no compatible creator available from plugins`,
396
+ val,
397
+ );
398
+ }
370
399
  }
371
400
  }
372
401
 
373
402
  getNewConnectionValueDriverBasedOnStore(
374
- store: Store | undefined,
403
+ store: Store,
375
404
  ): NewConnectionValueDriver<Connection> {
376
- if (store === undefined) {
405
+ if (store instanceof ModelStore) {
377
406
  return new NewPureModelConnectionDriver(this.editorStore);
378
407
  } else if (store instanceof FlatData) {
379
408
  return new NewFlatDataConnectionDriver(this.editorStore);
@@ -400,7 +429,7 @@ export class NewPackageableConnectionDriver extends NewElementDriver<Packageable
400
429
  );
401
430
  }
402
431
 
403
- setStore(store: Store | undefined): void {
432
+ setStore(store: Store): void {
404
433
  this.store = store;
405
434
  this.newConnectionValueDriver =
406
435
  this.getNewConnectionValueDriverBasedOnStore(store);
@@ -414,7 +443,7 @@ export class NewPackageableConnectionDriver extends NewElementDriver<Packageable
414
443
  const connection = new PackageableConnection(name);
415
444
  packageableConnection_setConnectionValue(
416
445
  connection,
417
- this.newConnectionValueDriver.createConnection(ModelStore.INSTANCE),
446
+ this.newConnectionValueDriver.createConnection(this.store),
418
447
  this.editorStore.changeDetectionState.observerContext,
419
448
  ); // default to model store
420
449
  return connection;
@@ -51,7 +51,7 @@ import {
51
51
  } from '@finos/legend-graph';
52
52
  import {
53
53
  configurationProperty_setValue,
54
- fileGeneration_addConfigurationProperty,
54
+ configurationProperty_addConfigurationProperty,
55
55
  fileGeneration_addScopeElement,
56
56
  fileGeneration_deleteScopeElement,
57
57
  } from '../shared/modifier/DSL_Generation_GraphModifierHelper.js';
@@ -294,7 +294,10 @@ export class FileGenerationState {
294
294
  generationProperty.name,
295
295
  newValue,
296
296
  );
297
- fileGeneration_addConfigurationProperty(fileGeneration, newItem);
297
+ configurationProperty_addConfigurationProperty(
298
+ fileGeneration.configurationProperties,
299
+ newItem,
300
+ );
298
301
  }
299
302
  }
300
303
  } else {
@@ -317,7 +320,10 @@ export class FileGenerationState {
317
320
  generationProperty.name,
318
321
  newConfigValue,
319
322
  );
320
- fileGeneration_addConfigurationProperty(fileGeneration, newItem);
323
+ configurationProperty_addConfigurationProperty(
324
+ fileGeneration.configurationProperties,
325
+ newItem,
326
+ );
321
327
  }
322
328
  } else {
323
329
  fileGeneration.configurationProperties =
@@ -478,7 +478,7 @@ export class ModelImporterState extends EditorState {
478
478
  }
479
479
 
480
480
  override match(tab: EditorState): boolean {
481
- return tab instanceof ModelImporterEditorState;
481
+ return tab instanceof ModelImporterState;
482
482
  }
483
483
 
484
484
  setReplaceFlag(val: boolean): void {
@@ -27,7 +27,6 @@ import {
27
27
  readFileAsText,
28
28
  assertErrorThrown,
29
29
  LogEvent,
30
- addUniqueEntry,
31
30
  deepEqual,
32
31
  guaranteeType,
33
32
  isEmpty,
@@ -55,7 +54,10 @@ import { type EntityChange, EntityChangeType } from '@finos/legend-server-sdlc';
55
54
  import type { EditorStore } from '../../../EditorStore.js';
56
55
  import { ElementEditorState } from '../ElementEditorState.js';
57
56
  import { LEGEND_STUDIO_APP_EVENT } from '../../../LegendStudioAppEvent.js';
58
- import { configurationProperty_setValue } from '../../../shared/modifier/DSL_Generation_GraphModifierHelper.js';
57
+ import {
58
+ configurationProperty_addConfigurationProperty,
59
+ configurationProperty_setValue,
60
+ } from '../../../shared/modifier/DSL_Generation_GraphModifierHelper.js';
59
61
 
60
62
  export enum SCHEMA_SET_TAB_TYPE {
61
63
  SCHEMAS = 'SCHEMAS',
@@ -92,8 +94,9 @@ export class SchemaSetModelGenerationState {
92
94
  setGenerationValue: action,
93
95
  setTargetBindingPath: action,
94
96
  handleTargetBindingPathChange: action,
97
+ updateGenerationParameters: action,
95
98
  canGenerate: computed,
96
- generateModel: flow,
99
+ generate: flow,
97
100
  importGeneratedModelsIntoGraph: flow,
98
101
  getImportEntities: flow,
99
102
  });
@@ -197,7 +200,10 @@ export class SchemaSetModelGenerationState {
197
200
  generationProperty.name,
198
201
  newValue,
199
202
  );
200
- addUniqueEntry(this.configurationProperties, newItem);
203
+ configurationProperty_addConfigurationProperty(
204
+ this.configurationProperties,
205
+ newItem,
206
+ );
201
207
  }
202
208
  }
203
209
  } else {
@@ -208,7 +214,8 @@ export class SchemaSetModelGenerationState {
208
214
  (generationProperty.defaultValue === 'true') ===
209
215
  (newValue as boolean);
210
216
  }
211
- const newConfigValue = useDefaultValue ? undefined : newValue;
217
+ const newConfigValue =
218
+ useDefaultValue && !generationProperty.required ? undefined : newValue;
212
219
  if (newConfigValue !== undefined) {
213
220
  if (configProperty) {
214
221
  configurationProperty_setValue(configProperty, newConfigValue);
@@ -217,7 +224,10 @@ export class SchemaSetModelGenerationState {
217
224
  generationProperty.name,
218
225
  newConfigValue,
219
226
  );
220
- addUniqueEntry(this.configurationProperties, newItem);
227
+ configurationProperty_addConfigurationProperty(
228
+ this.configurationProperties,
229
+ newItem,
230
+ );
221
231
  }
222
232
  } else {
223
233
  this.configurationProperties = this.configurationProperties.filter(
@@ -227,18 +237,37 @@ export class SchemaSetModelGenerationState {
227
237
  }
228
238
  }
229
239
 
230
- *generateModel(): GeneratorFn<boolean> {
240
+ addInferredConfigurationProperties(
241
+ properties: ConfigurationProperty[],
242
+ ): void {
243
+ const modelGenerationProperties = this.modelGenerationProperties;
244
+ const SCHEMA_FORMAT_PROPERTY_NAME = 'format';
245
+ if (!properties.find((e) => e.name === SCHEMA_FORMAT_PROPERTY_NAME)) {
246
+ const genProperty = new ConfigurationProperty(
247
+ SCHEMA_FORMAT_PROPERTY_NAME,
248
+ this.schemaSet.format,
249
+ );
250
+ properties.push(genProperty);
251
+ }
252
+ modelGenerationProperties
253
+ .filter(
254
+ (property) =>
255
+ property.required &&
256
+ property.defaultValue &&
257
+ !properties.find((pv) => pv.name === property.name),
258
+ )
259
+ .forEach((toAdd) => {
260
+ const value = new ConfigurationProperty(toAdd.name, toAdd.defaultValue);
261
+ configurationProperty_addConfigurationProperty(properties, value);
262
+ });
263
+ }
264
+
265
+ *generate(): GeneratorFn<boolean> {
231
266
  this.generatingModelsState.inProgress();
267
+ this.editorStore.applicationStore.setNotification(undefined);
232
268
  try {
233
- const SCHEMA_FORMAT_PROPERTY_NAME = 'format';
234
269
  const properties = [...this.configurationProperties];
235
- if (!properties.find((e) => e.name === SCHEMA_FORMAT_PROPERTY_NAME)) {
236
- const genProperty = new ConfigurationProperty(
237
- SCHEMA_FORMAT_PROPERTY_NAME,
238
- this.schemaSet.format,
239
- );
240
- properties.push(genProperty);
241
- }
270
+ this.addInferredConfigurationProperties(properties);
242
271
  const val =
243
272
  (yield this.editorStore.graphManagerState.graphManager.generateModelFromExternalFormat(
244
273
  this.schemaSet,
@@ -43,18 +43,19 @@ export const configurationProperty_setValue = action(
43
43
  cp.value = value;
44
44
  },
45
45
  );
46
- export const fileGeneration_setType = action(
47
- (fg: FileGenerationSpecification, value: string): void => {
48
- fg.type = value;
46
+
47
+ export const configurationProperty_addConfigurationProperty = action(
48
+ (
49
+ configurationProperties: ConfigurationProperty[],
50
+ cp: ConfigurationProperty,
51
+ ): void => {
52
+ addUniqueEntry(configurationProperties, observe_ConfigurationProperty(cp));
49
53
  },
50
54
  );
51
55
 
52
- export const fileGeneration_addConfigurationProperty = action(
53
- (fg: FileGenerationSpecification, cp: ConfigurationProperty): void => {
54
- addUniqueEntry(
55
- fg.configurationProperties,
56
- observe_ConfigurationProperty(cp),
57
- );
56
+ export const fileGeneration_setType = action(
57
+ (fg: FileGenerationSpecification, value: string): void => {
58
+ fg.type = value;
58
59
  },
59
60
  );
60
61