@cratis/stage.runtime 4.184.0 → 4.186.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.
@@ -21,6 +21,12 @@ export declare function StageTable({ element, slots }: RegisteredProps): import(
21
21
  export { StageCommandForm };
22
22
  /** Executes a modeled command against the route the Stage registered for it. */
23
23
  export declare function StageAction({ element, interactions, slots }: RegisteredProps): import("react").JSX.Element;
24
+ /**
25
+ * The task dialog of a toolbar slice button. Scene's own dialog asks for a text, a number, a switch or a date for each property of
26
+ * the command; a command that takes an enumeration, a record or a collection is asked through the command's own form instead - a choice, a
27
+ * group of fields, a list - and the identity the session acts as (the shopper's basket) is not asked for at all.
28
+ */
29
+ export declare function StageSliceDialog(props: Partial<RegisteredProps>): import("react").JSX.Element;
24
30
  /**
25
31
  * The components the Stage renders a scene with: Scene's own core vocabulary, with the two that have to reach
26
32
  * this running application - the table that reads a modeled query, and the action that executes a modeled
@@ -1,8 +1,14 @@
1
1
  import type React from 'react';
2
2
  import type { BindingExpression } from '@cratis/scene.model';
3
3
  import type { StageRoutes } from './stageRoutes';
4
+ /** Where a session keeps the identity it acts as, one per identifier concept. */
5
+ export declare const sessionIdentifierPrefix = "stage.session.";
4
6
  interface QueryState {
5
7
  name?: string;
8
+ /** The read model's name, under which the rows are published to the binding scope as well - where a summary looks them up. */
9
+ alias?: string;
10
+ /** The rows are always a list in the binding scope, even when there is one: a path reads `0.count`, never `count`. */
11
+ list?: boolean;
6
12
  route: string;
7
13
  rows: Record<string, unknown>[];
8
14
  loading: boolean;
@@ -15,6 +21,10 @@ export interface StageQueryRequest {
15
21
  route?: string;
16
22
  arguments?: Record<string, unknown>;
17
23
  ready?: boolean;
24
+ /** Publishes the rows under this name too: the read model a `data` declaration shows, so a summary finds them by it. */
25
+ alias?: string;
26
+ /** Whether the rows are published to bindings as a list always, so a path such as `0.lineCount` reads the same for one row as for many. */
27
+ list?: boolean;
18
28
  /**
19
29
  * Whether the result is published to the screen's bindings. A query read only to decide something - the item a
20
30
  * guard is evaluated against - is not, so it does not show up twice where the screen reads the same query.
@@ -41,6 +51,10 @@ export interface StageDataState {
41
51
  clearSelection: (scope: string) => void;
42
52
  setState: (key: string, value: unknown) => void;
43
53
  setComponentOutput: (componentId: string, path: string, value: unknown) => void;
54
+ /** Takes what the components of the rendered tree publish (a list's selected row, a search box's text) so bindings and interactions elsewhere on the page read it. */
55
+ publishComponentOutputs: (outputs: Record<string, Record<string, unknown>>) => void;
56
+ /** The rows of every query the page has read, by scope and by query name - what a `queryResult` binding resolves against. */
57
+ queryResults: Record<string, unknown>;
44
58
  refreshQuery: (query?: string) => void;
45
59
  refreshAfterCommand: () => void;
46
60
  resolveBinding: (binding: BindingExpression | string | undefined) => unknown;
@@ -65,7 +79,7 @@ export interface StageDataProviderProps {
65
79
  screen: string;
66
80
  children: React.ReactNode;
67
81
  }
68
- export declare function StageDataProvider({ routes, routesReady, parameters, locale, locales, screen, children }: StageDataProviderProps): React.JSX.Element;
82
+ export declare function StageDataProvider({ routes, routesReady, parameters: addressParameters, locale, locales, screen, children }: StageDataProviderProps): React.JSX.Element;
69
83
  export declare const useStageData: () => StageDataState;
70
84
  export declare function useStageQuery(request: StageQueryRequest): StageQueryResult;
71
85
  export declare function dataChanged(): void;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * What a command's presentation schema says about one property, in the terms a form needs: its scalar type, the
3
+ * values an enumeration declares, the members of a record and the element of a collection.
4
+ */
5
+ export interface SchemaProperty {
6
+ name: string;
7
+ /** The identifier concept of a uuid property (`x-concept`) - `BasketId`; what a session holds one value of. */
8
+ identifier?: string;
9
+ type?: 'text' | 'number' | 'boolean' | 'date';
10
+ required: boolean;
11
+ unsupportedReason?: string;
12
+ /** The values an enumeration declares, in declaration order; the property is presented as a choice among them. */
13
+ options?: string[];
14
+ /** The members of a record (`PostalAddress`); the property is presented as a group of fields. */
15
+ members?: SchemaProperty[];
16
+ /** The element of a collection (`OrderLine[]`); the property is presented as a list of them. */
17
+ item?: SchemaProperty;
18
+ /** Whether a date also carries a time of day. */
19
+ withTime?: boolean;
20
+ }
21
+ /**
22
+ * The properties a command's JSON schema declares, with the type the native form gives each and whether it is required. A toolbar
23
+ * slice's task dialog is built from the same reading, so a command is the same fields wherever it is presented.
24
+ */
25
+ export declare function schemaPropertiesOf(schema: string): SchemaProperty[];
26
+ /** Humanizes a member name the way a field label reads: `postalCode` is “Postal code”. */
27
+ export declare function humanize(name: string): string;
28
+ /**
29
+ * What is missing from a record or collection a form is about to submit: a member the schema requires that holds nothing.
30
+ *
31
+ * @param property The property the value is for.
32
+ * @param value What the form holds for it.
33
+ * @param label How the property reads on the form.
34
+ * @returns The first message, or nothing when the value is complete.
35
+ */
36
+ export declare function missingMember(property: SchemaProperty, value: unknown, label: string): string | undefined;
37
+ /**
38
+ * Brings a value read from the application to the form a command takes it in: an enumeration is the name of its member, however the read
39
+ * model stored it (by name, by case, or by its position), and a record or a collection is the same all the way down.
40
+ *
41
+ * @param property The property the value is for.
42
+ * @param value What a query answered for it.
43
+ * @returns The value as the command takes it.
44
+ */
45
+ export declare function asCommandValue(property: SchemaProperty, value: unknown): unknown;
@@ -0,0 +1,37 @@
1
+ import type { SceneElement } from '@cratis/scene.model';
2
+ /**
3
+ * The names of the queries an element tree binds property values to - `{ kind: 'queryResult', query, path }` - wherever it is
4
+ * placed: a count in the shell's topbar, a figure in a template, a value in a screen.
5
+ *
6
+ * @param element The composed screen, shell included.
7
+ * @returns The distinct query names, in first-use order.
8
+ */
9
+ export declare function queryBindingNames(element: SceneElement): string[];
10
+ /** A modeled `data` declaration: the read model a screen shows, the query that reads it and the parameter that query is read by. */
11
+ export interface StageDataSource {
12
+ typeName: string;
13
+ query: string;
14
+ by?: string;
15
+ route?: string;
16
+ }
17
+ /**
18
+ * The `data` declarations of an element tree - `data BasketSize via query GetBasketSize by id` - that a table or summary shows a read model through.
19
+ *
20
+ * @param element The composed screen.
21
+ * @returns One source for each read model, in first-use order.
22
+ */
23
+ export declare function dataSourcesOf(element: SceneElement): StageDataSource[];
24
+ /**
25
+ * Runs the queries that element properties are bound to.
26
+ *
27
+ * A table reads its own read model; a property bound to a query result - the basket count of a storefront's topbar - and a summary
28
+ * of a `data` declaration have no table to read it, so without this they would stay empty. Each distinct query is read once, follows
29
+ * the refresh a command triggers (so the count changes after an add to basket), and publishes its rows next to every other query's;
30
+ * a `data` declaration's rows are published under the read model's name, as a list.
31
+ *
32
+ * @param props.element The composed screen.
33
+ * @returns Nothing visible.
34
+ */
35
+ export declare function StageQueryBindings({ element }: {
36
+ element: SceneElement;
37
+ }): import("react").JSX.Element;
@@ -2,8 +2,8 @@ import type { SliceCommandField, SliceInvoker } from '@cratis/scene.react';
2
2
  import type { StageCommandOutcome } from './StageCommandOutcome';
3
3
  /**
4
4
  * The fields of a command, for the task dialog a toolbar slice button opens. They are what the command's schema declares -
5
- * the same reading the native command form uses - so the dialog asks for exactly what the command takes. A property the form
6
- * cannot present (a collection, an object) is left out rather than shown as a field that cannot be filled.
5
+ * the same reading the native command form uses - so the dialog asks for exactly what the command takes. A property the dialog
6
+ * cannot present (a collection, a record) is left out rather than shown as a field that cannot be filled.
7
7
  *
8
8
  * @param schemas The JSON schema of every modeled command, by command name.
9
9
  * @returns The fields of a command; none for a command the application does not describe.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/stage.runtime",
3
- "version": "4.184.0",
3
+ "version": "4.186.0",
4
4
  "description": "The Cratis Stage application runtime for Arc and Scene",
5
5
  "type": "module",
6
6
  "license": "MIT",