@elaraai/e3-ui 1.0.11 → 1.0.13

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/experiment/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACH,QAAQ,EACR,WAAW,EACX,SAAS,EACT,UAAU,EACV,WAAW,EACX,UAAU,EAKV,KAAK,QAAQ,EACb,KAAK,kBAAkB,EAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAU,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EACH,oBAAoB,EACpB,oBAAoB,EAEpB,WAAW,EAEX,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACvB,MAAM,YAAY,CAAC;AAIpB,OAAO,EACH,MAAM,EACN,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,cAAc,EACd,cAAc,GACjB,MAAM,YAAY,CAAC;AAOpB;;;;;GAKG;AACH,MAAM,MAAM,cAAc,CAAC,GAAG,SAAS,UAAU,IAC7C,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,oBAAoB,CAAC,EAAE,oBAAoB,CAAC,CAAC;AAK5E,MAAM,MAAM,oBAAoB,CAAC,GAAG,SAAS,UAAU,IACnD,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,oBAAoB,EAAE,oBAAoB,EAA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;QAEnF,4CAA4C;;;;;;QAE5C,kCAAkC;;;;;;;;CAGhC,CAAC"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * `Experiment` component — an interactive causal-experiment surface.
7
+ *
8
+ * @remarks
9
+ * `Experiment` lets a domain expert ask *"did X change Y, and can I trust it?"*
10
+ * against a dataset and read a derived, honest answer — without meeting a
11
+ * statistician's vocabulary. It is a registered extension component
12
+ * (architecturally like {@link Ontology}): the author writes one tag,
13
+ * `Experiment.Root({ … })`; the React renderer lives in
14
+ * `@elaraai/e3-ui-components`.
15
+ *
16
+ * **Generic over the input row, like `Table`.** The author binds the input
17
+ * dataset (`data: BoundValue<ArrayType<Row>>`); the renderer introspects its row
18
+ * struct to drive the treatment / outcome / confounder pickers.
19
+ *
20
+ * **The user edits the config → Apply runs ONE function.** Editing a picker
21
+ * stages a new {@link ExperimentConfigType}; **Apply** calls the single bound
22
+ * `experiment` function (`(rows, config) → ExperimentResult`) and the answer
23
+ * arrives reactively. The result carries the naive vs adjusted effect, balance,
24
+ * overlap, robustness, and an honesty **verdict** — `adjusted` is `none` when the
25
+ * engine refuses. **Commit** appends to the journal.
26
+ *
27
+ * **Visual-first and derived.** Nothing on the result side is hand-authored —
28
+ * every word is a column name the user picked, a number the engine returned, or
29
+ * a status derived by rule from the verdict tag.
30
+ *
31
+ * @packageDocumentation
32
+ */
33
+ import { NullType, BooleanType, ArrayType, StructType, VariantType, OptionType, East, none, some, variant, } from '@elaraai/east';
34
+ import { EastUI } from '@elaraai/east-ui';
35
+ import { DiffBindingType } from '../data.js';
36
+ import { FuncBindingType } from '../func.js';
37
+ import { ExperimentConfigType, ExperimentResultType, DoseResponseType, JournalType, ColumnMetaType, PopulationType, DesignConfigType, ExperimentDesignType, } from './types.js';
38
+ // Re-export the contract types so consumers can reach them from the component
39
+ // module too (the canonical home is `./types`).
40
+ export { CiType, WeightingSchemeType, EstimatorType, TargetUnitsType, BootstrapConfigType, RefuteSpecType, ExperimentConfigType, BalanceRowType, OverlapDiagnosticType, RefutationType, DoseResponseType, ExperimentVerdictType, ExperimentResultType, JournalRowType, JournalType, ColumnMetaType, PopulationType, } from './types.js';
41
+ // ============================================================================
42
+ // Component payload — descriptors only (binding handles + options).
43
+ // ============================================================================
44
+ /** Initial result tab variant — `answer` (default), `trust`, `dose`, or `validate`. */
45
+ export const ExperimentTabType = VariantType({ answer: NullType, trust: NullType, dose: NullType, validate: NullType });
46
+ /**
47
+ * The `Experiment` component payload — binding descriptors + options. Renderers
48
+ * decode this and resolve each binding to a live, reactive value / call handle.
49
+ *
50
+ * @property data - {@link DiffBindingType} for the input dataset — the renderer
51
+ * introspects its row struct for the pickers and passes it to the function.
52
+ * @property config - {@link DiffBindingType} for the staged {@link ExperimentConfigType}.
53
+ * @property experiment - {@link FuncBindingType} for the single `experiment` function.
54
+ * @property population - Optional {@link DiffBindingType} for the staged Step-4
55
+ * population filter ({@link PopulationType}); narrows rows UI-side before the call.
56
+ * @property journal - Optional {@link DiffBindingType} for the committed-experiment journal.
57
+ * @property columnMeta - Optional per-column display metadata.
58
+ * @property readonly - Render without the Apply / Commit / edit affordances.
59
+ * @property defaultTab - Initial result tab ({@link ExperimentTabType}).
60
+ */
61
+ export const ExperimentPayloadType = StructType({
62
+ data: DiffBindingType,
63
+ config: DiffBindingType,
64
+ experiment: FuncBindingType,
65
+ population: OptionType(DiffBindingType),
66
+ journal: OptionType(DiffBindingType),
67
+ /** Optional `design` function → the validation-trial recipe ("Validate" tab). */
68
+ design: OptionType(FuncBindingType),
69
+ columnMeta: OptionType(ColumnMetaType),
70
+ readonly: OptionType(BooleanType),
71
+ defaultTab: OptionType(ExperimentTabType),
72
+ });
73
+ /**
74
+ * Internal {@link EastUI.component} carrier. The React renderer registers
75
+ * against this in `@elaraai/e3-ui-components`.
76
+ */
77
+ export const ExperimentComponent = EastUI.component('Experiment', ExperimentPayloadType, { optional: true });
78
+ /**
79
+ * Build an Experiment surface bound to an input dataset + the single experiment
80
+ * function.
81
+ *
82
+ * @typeParam Row - The input dataset's row struct, inferred from `data`.
83
+ * @param options - {@link ExperimentOptions}. `data`, `config` and `experiment`
84
+ * are required; the rest are optional.
85
+ * @returns An East expression of {@link UIComponentType}.
86
+ */
87
+ function createExperiment(options) {
88
+ const defaultTab = options.defaultTab === undefined
89
+ ? none
90
+ : some(East.value(variant(options.defaultTab, null), ExperimentTabType));
91
+ const columnMeta = options.columns === undefined
92
+ ? none
93
+ : some(East.value(new Map(Object.entries(options.columns).map(([k, c]) => [k, {
94
+ label: c?.label !== undefined ? some(c.label) : none,
95
+ unit: c?.unit !== undefined ? some(c.unit) : none,
96
+ higherIsBetter: c?.higherIsBetter !== undefined ? some(c.higherIsBetter) : none,
97
+ }])), ColumnMetaType));
98
+ return ExperimentComponent.Root({
99
+ data: options.data.binding,
100
+ config: options.config.binding,
101
+ experiment: options.experiment.binding,
102
+ population: options.population !== undefined ? some(options.population.binding) : none,
103
+ journal: options.journal !== undefined ? some(options.journal.binding) : none,
104
+ design: options.design !== undefined ? some(options.design.binding) : none,
105
+ columnMeta,
106
+ readonly: options.readonly ?? none,
107
+ defaultTab,
108
+ });
109
+ }
110
+ /**
111
+ * The Experiment component namespace. Surfaces an interactive causal-experiment
112
+ * over a bound input dataset + a single `experiment` function, generic over the
113
+ * row struct (the `Table` pattern).
114
+ *
115
+ * @remarks
116
+ * Use `Experiment.Root({ data, config, experiment, journal })` inside a
117
+ * `Reactive` block. `Types` exposes the render-contract value types (`Config`,
118
+ * `Result`, `Verdict`, `Overlap`, `Balance`, `Refutation`, `Journal`, …).
119
+ */
120
+ export const Experiment = {
121
+ Root: createExperiment,
122
+ /** The internal {@link EastUI.component} carrier renderers register against. */
123
+ Component: ExperimentComponent,
124
+ Types: {
125
+ /** Rendered payload struct (bindings + options). */
126
+ Payload: ExperimentPayloadType,
127
+ /** The experiment-config value type (what the pickers stage). */
128
+ Config: ExperimentConfigType,
129
+ /** The result value type (numbers + verdict). */
130
+ Result: ExperimentResultType,
131
+ /** The ALE dose-response curve value type (the "How much?" tab). */
132
+ DoseResponse: DoseResponseType,
133
+ /** The committed-experiment journal value type. */
134
+ Journal: JournalType,
135
+ /** The validation-trial recipe value type (the "Validate" tab). */
136
+ Design: ExperimentDesignType,
137
+ /** The optional design-knobs value type. */
138
+ DesignConfig: DesignConfigType,
139
+ /** The UI-side Step-4 population filter value type (Array of Slice predicates). */
140
+ Population: PopulationType,
141
+ /** Optional per-column display metadata. */
142
+ ColumnMeta: ColumnMetaType,
143
+ /** Initial result tab variant. */
144
+ Tab: ExperimentTabType,
145
+ },
146
+ };
147
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/experiment/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACH,QAAQ,EACR,WAAW,EACX,SAAS,EACT,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,OAAO,GAGV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAwB,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAmB,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAC7D,OAAO,EACH,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,oBAAoB,GACvB,MAAM,YAAY,CAAC;AAEpB,8EAA8E;AAC9E,gDAAgD;AAChD,OAAO,EACH,MAAM,EACN,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,gBA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