@cratis/event-models 0.184.0 → 0.185.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.
@@ -1,5 +1,6 @@
1
1
  import type { ScenePackageBundle } from '@cratis/scene.react';
2
2
  import type { PersistedUiProfile } from '../../UiProfile/PersistedUiProfile';
3
+ import type { SampleDataSelectionSettings } from '../../UiProfile/SampleDataSelectionSettings';
3
4
  import type { ScreenEditorAppearance } from './ScreenEditorAppearance';
4
5
  import { type ScreenEditorRuntime } from './screenEditorRuntime';
5
- export declare function screenEditorRuntimeForProfile(applied?: PersistedUiProfile, bundles?: ScenePackageBundle[], appearance?: ScreenEditorAppearance): ScreenEditorRuntime;
6
+ export declare function screenEditorRuntimeForProfile(applied?: PersistedUiProfile, bundles?: ScenePackageBundle[], appearance?: ScreenEditorAppearance, sampleData?: SampleDataSelectionSettings): ScreenEditorRuntime;
@@ -0,0 +1,13 @@
1
+ import type { SampleDataMapping } from '@cratis/scene.model';
2
+ /**
3
+ * The sample data an application uses, chosen once in the UI Profile setup and inherited everywhere: the active pack,
4
+ * and the shape to read model mappings that go with it. It is the `sampleData` of Scene's `UiProfile`.
5
+ */
6
+ export interface SampleDataSelectionSettings {
7
+ /** The active pack's identifier - an own pack or a blueprint's - or empty for the generated data. */
8
+ activePack: string;
9
+ /** The shapes the pack names that stand in for a read model of another name. */
10
+ mappings: SampleDataMapping[];
11
+ }
12
+ /** No pack chosen, no mappings: the generated, deterministic data. */
13
+ export declare const noSampleData: SampleDataSelectionSettings;
@@ -1,4 +1,5 @@
1
1
  import { ColorScheme, LayoutMode } from '@cratis/scene.blueprint.default';
2
+ import type { SampleDataSelectionSettings } from './SampleDataSelectionSettings';
2
3
  /**
3
4
  * The choices that make up an application's UI profile - what a draft edits and what applying persists.
4
5
  *
@@ -26,4 +27,9 @@ export interface UiProfileSettings {
26
27
  accent: string;
27
28
  /** The screen template new screens start from, or empty for none. Chosen per level by Cratis/StudioIssues#396. */
28
29
  defaultScreenTemplate: string;
30
+ /**
31
+ * The sample data every preview and run of the application uses: chosen once here (the user's own pack or a blueprint's)
32
+ * and inherited everywhere, never per screen. Absent for a profile stored before sample data existed: generated data.
33
+ */
34
+ sampleData?: SampleDataSelectionSettings;
29
35
  }
@@ -0,0 +1,27 @@
1
+ import type { SampleDataSelection } from '@cratis/scene.model';
2
+ import { SampleDataSelectionSettings } from './SampleDataSelectionSettings';
3
+ import { UiProfileSettings } from './UiProfileSettings';
4
+ /**
5
+ * The sample data choice of settings, which a profile stored before sample data existed does not have.
6
+ *
7
+ * @param settings The settings.
8
+ * @returns The choice; generated data when none was made.
9
+ */
10
+ export declare const sampleDataOf: (settings: Pick<UiProfileSettings, 'sampleData'>) => SampleDataSelectionSettings;
11
+ /**
12
+ * Whether two sample data choices are the same.
13
+ *
14
+ * @param left The first choice.
15
+ * @param right The second choice.
16
+ * @returns `true` when the same pack is active with the same mappings, whatever their order.
17
+ */
18
+ export declare const areSampleDataEqual: (left: SampleDataSelectionSettings, right: SampleDataSelectionSettings) => boolean;
19
+ /**
20
+ * The Scene `sampleData` of a profile for a choice: what Stage, the CLI and the screen editor read to resolve the data, so Studio
21
+ * keeps no separate notion of it. Nothing is returned for the generated data with no mappings - the profile then has no `sampleData`
22
+ * at all, as one declared without it has.
23
+ *
24
+ * @param selection The choice.
25
+ * @returns The Scene selection, or `undefined` when the choice declares nothing.
26
+ */
27
+ export declare const toSceneSampleData: (selection: SampleDataSelectionSettings | undefined) => SampleDataSelection | undefined;
@@ -1,5 +1,6 @@
1
1
  import { UiProfile } from '@cratis/scene.model';
2
2
  import { PersistedUiProfile } from './PersistedUiProfile';
3
+ import type { SampleDataSelectionSettings } from './SampleDataSelectionSettings';
3
4
  /**
4
5
  * Builds the Scene profile a stored UI profile stands for, without needing the package catalog.
5
6
  *
@@ -7,6 +8,7 @@ import { PersistedUiProfile } from './PersistedUiProfile';
7
8
  * Scene `UiProfile`, so the screen editor and anything else rendering a screen agree with the preview.
8
9
  *
9
10
  * @param persisted The stored profile.
11
+ * @param sampleData The application's sample data choice, stored apart from the profile; absent when none was made.
10
12
  * @returns The Scene {@link UiProfile}.
11
13
  */
12
- export declare function toSceneUiProfile(persisted: PersistedUiProfile): UiProfile;
14
+ export declare function toSceneUiProfile(persisted: PersistedUiProfile, sampleData?: SampleDataSelectionSettings): UiProfile;