mlform 0.1.9 → 0.1.11
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.
- package/README.md +18 -16
- package/dist/builtins-D8rXH4ED.js +725 -0
- package/dist/{design-system-CIU_vH6O.js → design-6suKVQDo.js} +15 -15
- package/dist/mlform/builtins.mjs +2 -0
- package/dist/mlform/{design-system.mjs → design.mjs} +2 -2
- package/dist/mlform/kit.mjs +1896 -3
- package/dist/mlform/primitives.mjs +2 -2
- package/dist/mlform/runtime.mjs +3 -4
- package/dist/mlform/schema.mjs +2 -102
- package/dist/mlform/transport.mjs +2 -2
- package/dist/{primitives-Di95y_ur.js → primitives-k9HTnd72.js} +2303 -3384
- package/dist/{runtime-C5iTM3uu.js → runtime-CI7vlp9i.js} +655 -791
- package/dist/schema-DSAZ6bts.js +88 -0
- package/dist/{transport-B6ePTLFK.js → transport-CO6udZ6z.js} +605 -575
- package/dist/types/{builtins-ml/definitions/index.d.ts → builtins/definitions/collections.d.ts} +1 -15
- package/dist/types/{shared/object.d.ts → builtins/definitions/fields/value-helpers.d.ts} +1 -0
- package/dist/types/builtins/definitions/index.d.ts +16 -0
- package/dist/types/{builtins-ml → builtins}/definitions/shared.d.ts +2 -9
- package/dist/types/builtins/index.d.ts +6 -0
- package/dist/types/builtins/mapped-category-behavior.d.ts +2 -0
- package/dist/types/builtins/registry-pack.d.ts +10 -0
- package/dist/types/{design-system → design}/index.d.ts +1 -1
- package/dist/types/{design-system/recipes/index.d.ts → design/recipes/collections.d.ts} +0 -1
- package/dist/types/design/recipes/index.d.ts +2 -0
- package/dist/types/design/resolve/index.d.ts +4 -0
- package/dist/types/{design-system/resolve/index.d.ts → design/resolve/resolve-design.d.ts} +0 -3
- package/dist/types/{design-system → design}/runtime/index.d.ts +3 -3
- package/dist/types/{design-system/themes/index.d.ts → design/themes/collections.d.ts} +0 -2
- package/dist/types/design/themes/index.d.ts +3 -0
- package/dist/types/{design-system → design}/types.d.ts +1 -1
- package/dist/types/kit/constants.d.ts +2 -10
- package/dist/types/kit/defaults.d.ts +1 -1
- package/dist/types/kit/disclosure-root-styles.d.ts +1 -0
- package/dist/types/kit/error-navigation.d.ts +2 -1
- package/dist/types/kit/index.d.ts +4 -5
- package/dist/types/{presentation → kit/kinds}/define-field-kind.d.ts +11 -3
- package/dist/types/kit/kinds/define-report-kind.d.ts +40 -0
- package/dist/types/kit/kinds/index.d.ts +3 -0
- package/dist/types/kit/kinds/register-kind.d.ts +5 -0
- package/dist/types/kit/layout-helpers.d.ts +7 -11
- package/dist/types/kit/layout-node-render.d.ts +4 -4
- package/dist/types/kit/layout-node-resolver.d.ts +1 -1
- package/dist/types/kit/{accordion-root.d.ts → layout-root.d.ts} +3 -4
- package/dist/types/kit/layout-types.d.ts +8 -36
- package/dist/types/kit/layout-utils.d.ts +0 -1
- package/dist/types/kit/layout.d.ts +2 -2
- package/dist/types/kit/mount-types.d.ts +8 -7
- package/dist/types/kit/panel-nav.d.ts +1 -1
- package/dist/types/kit/tabs-root.d.ts +1 -2
- package/dist/types/kit/types.d.ts +2 -3
- package/dist/types/kit/view-core-types.d.ts +110 -0
- package/dist/types/kit/view-layout-state.d.ts +10 -3
- package/dist/types/kit/view-navigation.d.ts +3 -3
- package/dist/types/kit/view-snapshot-cache.d.ts +3 -3
- package/dist/types/kit/view-snapshot.d.ts +4 -4
- package/dist/types/kit/view-types.d.ts +1 -172
- package/dist/types/kit/view.d.ts +2 -8
- package/dist/types/kit/wizard-root.d.ts +1 -2
- package/dist/types/primitives/base-async-report-element.d.ts +1 -1
- package/dist/types/primitives/base-field-element.d.ts +3 -3
- package/dist/types/primitives/base-report-element.d.ts +3 -3
- package/dist/types/primitives/components/descriptor-content.d.ts +4 -0
- package/dist/types/primitives/components/error-focus.d.ts +3 -2
- package/dist/types/primitives/components/field-frame-feedback.d.ts +3 -3
- package/dist/types/primitives/components/field-frame.d.ts +3 -3
- package/dist/types/primitives/components/form-errors.d.ts +2 -2
- package/dist/types/primitives/components/form-root-presenters.d.ts +6 -11
- package/dist/types/primitives/components/form-root-state.d.ts +4 -6
- package/dist/types/primitives/components/form-root-templates.d.ts +4 -8
- package/dist/types/primitives/components/form-root.d.ts +4 -4
- package/dist/types/primitives/components/report-frame.d.ts +4 -4
- package/dist/types/primitives/components/submit-button.d.ts +2 -2
- package/dist/types/primitives/constants.d.ts +6 -9
- package/dist/types/primitives/controller-types.d.ts +96 -0
- package/dist/types/primitives/descriptor-resolution.d.ts +6 -0
- package/dist/types/primitives/descriptors/content.d.ts +61 -0
- package/dist/types/primitives/descriptors/field.d.ts +32 -0
- package/dist/types/primitives/descriptors/index.d.ts +5 -0
- package/dist/types/primitives/descriptors/registry.d.ts +11 -0
- package/dist/types/primitives/descriptors/report.d.ts +20 -0
- package/dist/types/primitives/index.d.ts +8 -3
- package/dist/types/primitives/mount-form.d.ts +2 -2
- package/dist/types/primitives/request-runner.d.ts +13 -0
- package/dist/types/primitives/types.d.ts +16 -53
- package/dist/types/runtime/errors.d.ts +1 -2
- package/dist/types/runtime/index.d.ts +2 -4
- package/dist/types/runtime/reports/controller.d.ts +3 -2
- package/dist/types/runtime/runtime-controller.d.ts +1 -5
- package/dist/types/runtime/state/engine.d.ts +1 -2
- package/dist/types/runtime/submission/create-submitter.d.ts +1 -1
- package/dist/types/runtime/submission/index.d.ts +1 -1
- package/dist/types/runtime/submission/lifecycle.d.ts +1 -2
- package/dist/types/runtime/submission/pipeline.d.ts +1 -1
- package/dist/types/runtime/submission/report-fetches.d.ts +2 -0
- package/dist/types/runtime/submission/types.d.ts +1 -2
- package/dist/types/runtime/types/form.d.ts +9 -13
- package/dist/types/runtime/types/index.d.ts +0 -1
- package/dist/types/runtime/types/pipeline.d.ts +10 -10
- package/dist/types/runtime/types/registry.d.ts +2 -3
- package/dist/types/runtime/types/report.d.ts +4 -1
- package/dist/types/runtime/types/transport.d.ts +3 -4
- package/dist/types/runtime/utils.d.ts +1 -3
- package/dist/types/runtime/validation/form.d.ts +1 -1
- package/dist/types/schema/ids.d.ts +1 -0
- package/dist/types/schema/index.d.ts +3 -1
- package/dist/types/schema/registry.d.ts +2 -4
- package/dist/types/schema/report-fetch-request.d.ts +6 -0
- package/dist/types/schema/types/form.d.ts +0 -3
- package/dist/types/schema/types/registry.d.ts +0 -5
- package/dist/types/schema/types/report.d.ts +25 -3
- package/dist/types/schema/types/submit.d.ts +11 -0
- package/dist/types/transport/errors.d.ts +1 -2
- package/dist/types/transport/index.d.ts +2 -0
- package/dist/types/transport/request-runner.d.ts +16 -0
- package/package.json +14 -27
- package/dist/builtins-ml-pjab8_gu.js +0 -3878
- package/dist/errors-CTNw8fwS.js +0 -8
- package/dist/kit-QY6zff-h.js +0 -1888
- package/dist/mlform/behaviors.mjs +0 -32
- package/dist/mlform/builtins-ml.mjs +0 -2
- package/dist/mlform/presentation.mjs +0 -2
- package/dist/mlform.mjs +0 -8
- package/dist/presentation-BrlVO4oV.js +0 -200
- package/dist/strings-CWwrrYzz.js +0 -4
- package/dist/types/behaviors/index.d.ts +0 -3
- package/dist/types/builtins-ml/index.d.ts +0 -5
- package/dist/types/index.d.ts +0 -13
- package/dist/types/kit/accordion-root-styles.d.ts +0 -1
- package/dist/types/kit/accordion.d.ts +0 -2
- package/dist/types/kit/tabs.d.ts +0 -2
- package/dist/types/kit/wizard.d.ts +0 -2
- package/dist/types/packs/default.d.ts +0 -2
- package/dist/types/packs/index.d.ts +0 -3
- package/dist/types/packs/ml.d.ts +0 -2
- package/dist/types/packs/shared.d.ts +0 -24
- package/dist/types/presentation/define-explanation-kind.d.ts +0 -11
- package/dist/types/presentation/define-report-kind.d.ts +0 -15
- package/dist/types/presentation/index.d.ts +0 -10
- package/dist/types/presentation/register-kind.d.ts +0 -6
- package/dist/types/presentation/registry.d.ts +0 -15
- package/dist/types/presentation/types/explanation.d.ts +0 -32
- package/dist/types/presentation/types/field.d.ts +0 -36
- package/dist/types/presentation/types/presentation.d.ts +0 -61
- package/dist/types/presentation/types/report.d.ts +0 -41
- package/dist/types/primitives/base-explanation-element.d.ts +0 -22
- package/dist/types/primitives/components/declarative-explanation.d.ts +0 -5
- package/dist/types/primitives/components/explanation-panel.d.ts +0 -24
- package/dist/types/primitives/components/presentation.d.ts +0 -4
- package/dist/types/primitives/presentation.d.ts +0 -8
- package/dist/types/runtime/explanations/controller.d.ts +0 -13
- package/dist/types/runtime/explanations/index.d.ts +0 -1
- package/dist/types/runtime/schema/index.d.ts +0 -7
- package/dist/types/runtime/submission/explanations.d.ts +0 -2
- package/dist/types/runtime/types/explanation.d.ts +0 -15
- package/dist/types/schema/types/explanation.d.ts +0 -43
- package/dist/types/shared/errors.d.ts +0 -3
- package/dist/types/shared/index.d.ts +0 -3
- package/dist/types/shared/strings.d.ts +0 -1
- package/dist/utils-J5o8lkea.js +0 -29
- /package/dist/types/{runtime → builtins}/constants.d.ts +0 -0
- /package/dist/types/{builtins-ml → builtins}/definitions/fields/boolean.d.ts +0 -0
- /package/dist/types/{builtins-ml → builtins}/definitions/fields/category.d.ts +0 -0
- /package/dist/types/{builtins-ml → builtins}/definitions/fields/date.d.ts +0 -0
- /package/dist/types/{builtins-ml → builtins}/definitions/fields/long-text.d.ts +0 -0
- /package/dist/types/{builtins-ml → builtins}/definitions/fields/mapped-category.d.ts +0 -0
- /package/dist/types/{builtins-ml → builtins}/definitions/fields/multi-choice.d.ts +0 -0
- /package/dist/types/{builtins-ml → builtins}/definitions/fields/number.d.ts +0 -0
- /package/dist/types/{builtins-ml → builtins}/definitions/fields/rating.d.ts +0 -0
- /package/dist/types/{builtins-ml → builtins}/definitions/fields/series-helpers.d.ts +0 -0
- /package/dist/types/{builtins-ml → builtins}/definitions/fields/series.d.ts +0 -0
- /package/dist/types/{builtins-ml → builtins}/definitions/fields/single-choice.d.ts +0 -0
- /package/dist/types/{builtins-ml → builtins}/definitions/fields/text.d.ts +0 -0
- /package/dist/types/{builtins-ml → builtins}/definitions/reports/classifier.d.ts +0 -0
- /package/dist/types/{builtins-ml → builtins}/definitions/reports/regressor.d.ts +0 -0
- /package/dist/types/{design-system → design}/constants.d.ts +0 -0
- /package/dist/types/{design-system → design}/contract/component-keys.d.ts +0 -0
- /package/dist/types/{design-system → design}/contract/component-tokens.d.ts +0 -0
- /package/dist/types/{design-system → design}/contract/global-tokens.d.ts +0 -0
- /package/dist/types/{design-system → design}/contract/index.d.ts +0 -0
- /package/dist/types/{design-system → design}/contract/token-keys.d.ts +0 -0
- /package/dist/types/{design-system → design}/recipes/contrast.d.ts +0 -0
- /package/dist/types/{design-system → design}/recipes/default.d.ts +0 -0
- /package/dist/types/{design-system → design}/recipes/minimal.d.ts +0 -0
- /package/dist/types/{design-system → design}/recipes/soft.d.ts +0 -0
- /package/dist/types/{design-system → design}/registry/builtins.d.ts +0 -0
- /package/dist/types/{design-system → design}/registry/create-registry.d.ts +0 -0
- /package/dist/types/{design-system → design}/registry/deep-freeze.d.ts +0 -0
- /package/dist/types/{design-system → design}/registry/define-recipe.d.ts +0 -0
- /package/dist/types/{design-system → design}/registry/define-theme.d.ts +0 -0
- /package/dist/types/{design-system → design}/registry/define-token-maps.d.ts +0 -0
- /package/dist/types/{design-system → design}/registry/index.d.ts +0 -0
- /package/dist/types/{design-system → design}/resolve/diagnostics.d.ts +0 -0
- /package/dist/types/{design-system → design}/resolve/merge-config.d.ts +0 -0
- /package/dist/types/{design-system → design}/resolve/migrate-tokens.d.ts +0 -0
- /package/dist/types/{design-system → design}/resolve/resolve-mode.d.ts +0 -0
- /package/dist/types/{design-system → design}/resolve/resolve-recipe.d.ts +0 -0
- /package/dist/types/{design-system → design}/resolve/resolve-theme.d.ts +0 -0
- /package/dist/types/{design-system → design}/resolve/resolve-tokens.d.ts +0 -0
- /package/dist/types/{design-system → design}/runtime/apply-tokens.d.ts +0 -0
- /package/dist/types/{design-system/runtime/attach-design-system.d.ts → design/runtime/attach-design.d.ts} +0 -0
- /package/dist/types/{design-system → design}/runtime/controller-helpers.d.ts +0 -0
- /package/dist/types/{design-system → design}/runtime/create-stylesheet.d.ts +0 -0
- /package/dist/types/{design-system → design}/runtime/declarations.d.ts +0 -0
- /package/dist/types/{design-system/runtime/design-system-controller.d.ts → design/runtime/design-controller.d.ts} +0 -0
- /package/dist/types/{design-system → design}/runtime/fingerprint.d.ts +0 -0
- /package/dist/types/{design-system → design}/runtime/host-observer.d.ts +0 -0
- /package/dist/types/{design-system → design}/runtime/host-state.d.ts +0 -0
- /package/dist/types/{design-system/runtime/hydrate-design-system.d.ts → design/runtime/hydrate-design.d.ts} +0 -0
- /package/dist/types/{design-system → design}/runtime/hydration-state.d.ts +0 -0
- /package/dist/types/{design-system → design}/runtime/inherited-scheme.d.ts +0 -0
- /package/dist/types/{design-system → design}/runtime/media.d.ts +0 -0
- /package/dist/types/{design-system → design}/themes/airbnb.d.ts +0 -0
- /package/dist/types/{design-system → design}/themes/clickhouse.d.ts +0 -0
- /package/dist/types/{design-system → design}/themes/cobalt.d.ts +0 -0
- /package/dist/types/{design-system → design}/themes/graphite.d.ts +0 -0
- /package/dist/types/{design-system → design}/themes/neutral.d.ts +0 -0
- /package/dist/types/{design-system → design}/themes/sage.d.ts +0 -0
- /package/dist/types/{design-system → design}/themes/sunset.d.ts +0 -0
- /package/dist/types/{design-system → design}/tokens/base.d.ts +0 -0
- /package/dist/types/{design-system → design}/tokens/contrast.d.ts +0 -0
- /package/dist/types/{design-system → design}/tokens/density.d.ts +0 -0
- /package/dist/types/{design-system → design}/tokens/forced-colors.d.ts +0 -0
- /package/dist/types/{design-system → design}/tokens/index.d.ts +0 -0
- /package/dist/types/{design-system → design}/tokens/motion.d.ts +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FieldConfig, FieldStateSnapshot, FormSchema, InactiveFieldPolicy, NormalizedFieldConfig, NormalizedReportConfig, Registry, ReportConfig, ReportStateSnapshot, SelectorSubscriptionOptions } from '../../schema';
|
|
2
2
|
import { RuntimeBehavior } from './behavior';
|
|
3
3
|
import { AfterSubmitContext, BeforeSubmitContext, SubmitErrorContext, SubmitOptions, SubmitResult, Transport, TransportStreamEvent } from './transport';
|
|
4
|
-
import { ExplanationController, ExplanationStateSnapshot } from './explanation';
|
|
5
4
|
import { FieldController } from './field';
|
|
6
5
|
import { ReportController } from './report';
|
|
7
6
|
type MaybePromise<T> = T | PromiseLike<T>;
|
|
@@ -31,7 +30,6 @@ export interface FormState {
|
|
|
31
30
|
touched: boolean;
|
|
32
31
|
values: Record<string, unknown>;
|
|
33
32
|
reportStates: Record<string, ReportStateSnapshot>;
|
|
34
|
-
explanationStates: Record<string, ExplanationStateSnapshot>;
|
|
35
33
|
submissionProgress: SubmissionProgressState | null;
|
|
36
34
|
errors: {
|
|
37
35
|
form: string[];
|
|
@@ -63,13 +61,13 @@ export interface AfterValidateContext {
|
|
|
63
61
|
result: FormValidationResult;
|
|
64
62
|
submitCount: number;
|
|
65
63
|
}
|
|
66
|
-
export interface
|
|
67
|
-
|
|
64
|
+
export interface AfterReportFetchContext {
|
|
65
|
+
reportId: string;
|
|
68
66
|
kind: string;
|
|
69
|
-
|
|
67
|
+
payload: unknown;
|
|
70
68
|
}
|
|
71
|
-
export interface
|
|
72
|
-
|
|
69
|
+
export interface ReportFetchErrorContext {
|
|
70
|
+
reportId: string;
|
|
73
71
|
kind: string;
|
|
74
72
|
error: unknown;
|
|
75
73
|
}
|
|
@@ -79,8 +77,8 @@ export interface FormHooks {
|
|
|
79
77
|
beforeSubmit?: (context: BeforeSubmitContext) => MaybePromise<void>;
|
|
80
78
|
afterSubmit?: (context: AfterSubmitContext) => MaybePromise<void>;
|
|
81
79
|
onSubmitError?: (context: SubmitErrorContext) => MaybePromise<void>;
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
afterReportFetch?: (context: AfterReportFetchContext) => MaybePromise<void>;
|
|
81
|
+
onReportFetchError?: (context: ReportFetchErrorContext) => MaybePromise<void>;
|
|
84
82
|
}
|
|
85
83
|
export interface CreateFormConfig {
|
|
86
84
|
schema: FormSchema;
|
|
@@ -100,11 +98,9 @@ export interface CreateFormConfig {
|
|
|
100
98
|
export interface FormController {
|
|
101
99
|
readonly fields: readonly FieldController[];
|
|
102
100
|
readonly reports: readonly ReportController[];
|
|
103
|
-
readonly explanations: readonly ExplanationController[];
|
|
104
101
|
readonly state: FormState;
|
|
105
102
|
getField(id: string): FieldController | undefined;
|
|
106
103
|
getReport(id: string): ReportController | undefined;
|
|
107
|
-
getExplanation(id: string): ExplanationController | undefined;
|
|
108
104
|
getValues(): Record<string, unknown>;
|
|
109
105
|
setValues(values: Record<string, unknown>): void;
|
|
110
106
|
validate(): Promise<FormValidationResult>;
|
|
@@ -114,4 +110,4 @@ export interface FormController {
|
|
|
114
110
|
subscribe(listener: (state: FormState) => void): () => void;
|
|
115
111
|
subscribeSelector<TSelected>(selector: (state: FormState) => TSelected, listener: (selected: TSelected, state: FormState) => void, options?: SelectorSubscriptionOptions<TSelected>): () => void;
|
|
116
112
|
}
|
|
117
|
-
export type {
|
|
113
|
+
export type { FieldConfig, FormSchema, Registry, ReportConfig };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ExplanationController, ExplanationFetchRequest } from './explanation';
|
|
2
1
|
import { FormController } from './form';
|
|
2
|
+
import { ReportController, ReportFetchRequest } from './report';
|
|
3
3
|
import { SubmitOptions, SubmitResult } from './transport';
|
|
4
|
-
export interface
|
|
4
|
+
export interface ReportFetchExecutionResult {
|
|
5
5
|
results: Record<string, unknown>;
|
|
6
6
|
errors: Record<string, string>;
|
|
7
7
|
}
|
|
8
8
|
export interface PipelineArtifactContext {
|
|
9
9
|
submitResult: SubmitResult;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
reportFetchResults: Record<string, unknown>;
|
|
11
|
+
reportFetchErrors: Record<string, string>;
|
|
12
12
|
}
|
|
13
13
|
export interface PipelineArtifactAdapter<TArtifacts extends Record<string, unknown> = {}> {
|
|
14
14
|
derive(context: PipelineArtifactContext): TArtifacts | Promise<TArtifacts>;
|
|
@@ -17,15 +17,15 @@ export interface ExecuteFormPipelineOptions<TArtifacts extends Record<string, un
|
|
|
17
17
|
form: FormController;
|
|
18
18
|
submit?: SubmitOptions;
|
|
19
19
|
artifactAdapter?: PipelineArtifactAdapter<TArtifacts>;
|
|
20
|
-
|
|
20
|
+
reportFetchMode?: "none" | "all";
|
|
21
21
|
}
|
|
22
22
|
export interface PipelineResult<TArtifacts extends Record<string, unknown> = {}> {
|
|
23
23
|
submitResult: SubmitResult;
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
reportFetchResults: Record<string, unknown>;
|
|
25
|
+
reportFetchErrors: Record<string, string>;
|
|
26
26
|
artifacts: TArtifacts;
|
|
27
27
|
}
|
|
28
|
-
export interface
|
|
29
|
-
|
|
30
|
-
request:
|
|
28
|
+
export interface ReportFetchExecutionContext {
|
|
29
|
+
reports: readonly ReportController[];
|
|
30
|
+
request: ReportFetchRequest;
|
|
31
31
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface Registry extends Omit<SchemaRegistry, "
|
|
1
|
+
import { FieldDefinition, Registry as SchemaRegistry, ReportDefinition } from '../../schema';
|
|
2
|
+
export interface Registry extends Omit<SchemaRegistry, "registerField" | "registerReport"> {
|
|
3
3
|
registerField(definition: FieldDefinition): Registry;
|
|
4
4
|
registerReport(definition: ReportDefinition): Registry;
|
|
5
|
-
registerExplanation(definition: ExplanationDefinition): Registry;
|
|
6
5
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { NormalizedReportConfig as SchemaNormalizedReportConfig, ReportDefinition as SchemaReportDefinition, ReportStateSnapshot } from '../../schema';
|
|
2
|
-
export type { BaseReportConfig, PartialReportUpdatePolicy, ReportConfig, ReportPayloadContext, ReportPayloadValidationPolicy, ReportResolveContext, ReportStateSnapshot, ReportStatus, } from '../../schema';
|
|
2
|
+
export type { BaseReportConfig, PartialReportUpdatePolicy, ReportConfig, ReportFetchContext, ReportFetchFactory, ReportFetchRequest, ReportFetchStatus, ReportFetchTransport, ReportPayloadContext, ReportPayloadValidationPolicy, ReportResolveContext, ReportStateSnapshot, ReportStatus, } from '../../schema';
|
|
3
3
|
export interface ReportHandle {
|
|
4
4
|
readonly id: string;
|
|
5
5
|
readonly kind: string;
|
|
6
6
|
readonly config: SchemaNormalizedReportConfig;
|
|
7
7
|
readonly state: ReportStateSnapshot;
|
|
8
|
+
readonly canFetch: boolean;
|
|
9
|
+
fetch(request: import('../../schema').ReportFetchRequest): Promise<void>;
|
|
10
|
+
abort(): void;
|
|
8
11
|
subscribe(listener: (state: ReportStateSnapshot) => void): () => void;
|
|
9
12
|
}
|
|
10
13
|
export type ReportController = ReportHandle;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { SubmitRequest as BaseSubmitRequest,
|
|
1
|
+
import { SubmitRequest as BaseSubmitRequest, Transport as BaseTransport, TransportStreamEvent as BaseTransportStreamEvent } from '../../transport';
|
|
2
|
+
import { SubmitResult as SchemaSubmitResult } from '../../schema';
|
|
2
3
|
import { NormalizedFieldConfig } from './field';
|
|
3
4
|
import { NormalizedReportConfig, ReportStateSnapshot } from './report';
|
|
4
5
|
export type { CapabilityRequirement, CircuitBreakerSharedState, CircuitBreakerStateSnapshot, RateLimitLeaseRequest, SharedRateLimiter, SharedRateLimiterLease, SubmitRequestMetadata, SubmitRequestTransportContext, TransportAuthKind, TransportBackpressureMode, TransportCacheEntry, TransportCacheStore, TransportCapabilities, TransportCollection, TransportConsistency, TransportDeliveryMode, TransportHealthSnapshot, TransportHealthState, TransportPolicyContext, TransportResponse, TransportSession, TransportSessionCloseEvent, TransportSessionErrorEvent, TransportSessionEvent, TransportSessionMessage, TransportSessionMessageEvent, TransportSessionMetaEvent, TransportSessionProgressEvent, TransportSessionResultEvent, TransportStreamChunkEvent, TransportStreamErrorEvent, TransportStreamMetaEvent, TransportStreamProgressEvent, TransportStreamReportPatchEvent, TransportStreamReportReplaceEvent, } from '../../transport';
|
|
5
6
|
export type SubmitRequest = BaseSubmitRequest<NormalizedFieldConfig, NormalizedReportConfig>;
|
|
6
|
-
export type SubmitResult =
|
|
7
|
-
reportStates: Record<string, ReportStateSnapshot>;
|
|
8
|
-
};
|
|
7
|
+
export type SubmitResult = SchemaSubmitResult<ReportStateSnapshot>;
|
|
9
8
|
export type Transport = BaseTransport<NormalizedFieldConfig, NormalizedReportConfig>;
|
|
10
9
|
export type TransportStreamEvent = BaseTransportStreamEvent;
|
|
11
10
|
export interface SubmitOptions {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { MaybePromise } from './types';
|
|
2
|
-
|
|
3
|
-
export { isRecord, slugify };
|
|
2
|
+
export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
|
|
4
3
|
export declare const isPromiseLike: <T>(value: MaybePromise<T>) => value is PromiseLike<T>;
|
|
5
4
|
export declare const isEmptyValue: (value: unknown) => boolean;
|
|
6
|
-
export declare const toDate: (value: unknown) => Date | null;
|
|
7
5
|
export declare const identity: <T>(value: T) => T;
|
|
8
6
|
export declare const deepFreeze: <T>(value: T) => T;
|
|
9
7
|
export declare const delay: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NormalizedFormSchema } from '
|
|
1
|
+
import { NormalizedFormSchema } from '../../schema';
|
|
2
2
|
import { EngineStore } from '../state';
|
|
3
3
|
import { FieldValidationResult, FormHooks, FormStatus, FormValidationIssue, FormValidationResult, FormValidator, InactiveFieldPolicy } from '../types';
|
|
4
4
|
type FormValidationField = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const normalizeSchemaId: (value: string) => string;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
export { normalizeSchemaId } from './ids';
|
|
1
2
|
export * from './normalize';
|
|
3
|
+
export { createReportFetchRequest } from './report-fetch-request';
|
|
2
4
|
export * from './registry';
|
|
3
|
-
export type * from './types/explanation';
|
|
4
5
|
export type * from './types/field';
|
|
5
6
|
export type * from './types/form';
|
|
6
7
|
export type * from './types/registry';
|
|
7
8
|
export type * from './types/report';
|
|
9
|
+
export type * from './types/submit';
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare class RegistryError extends MLFormError {
|
|
1
|
+
import { FieldConfig, FieldDefinition, Registry, ReportConfig, ReportDefinition } from './index';
|
|
2
|
+
export declare class RegistryError extends Error {
|
|
4
3
|
constructor(message: string);
|
|
5
4
|
}
|
|
6
5
|
export declare const createRegistry: () => Registry;
|
|
7
6
|
export declare const defineFieldDefinition: <TDefinition extends FieldDefinition<FieldConfig, unknown>>(definition: TDefinition) => TDefinition;
|
|
8
7
|
export declare const defineReportDefinition: <TDefinition extends ReportDefinition<ReportConfig>>(definition: TDefinition) => TDefinition;
|
|
9
|
-
export declare const defineExplanationDefinition: <TDefinition extends ExplanationDefinition<ExplanationConfig>>(definition: TDefinition) => TDefinition;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { ExplanationConfig, NormalizedExplanationConfig } from './explanation';
|
|
2
1
|
import { FieldConfig, NormalizedFieldConfig } from './field';
|
|
3
2
|
import { NormalizedReportConfig, ReportConfig } from './report';
|
|
4
3
|
export interface FormSchema {
|
|
5
4
|
fields: FieldConfig[];
|
|
6
5
|
reports?: ReportConfig[];
|
|
7
|
-
explanations?: ExplanationConfig[];
|
|
8
6
|
}
|
|
9
7
|
export interface NormalizedFormSchema {
|
|
10
8
|
fields: NormalizedFieldConfig[];
|
|
11
9
|
reports: NormalizedReportConfig[];
|
|
12
|
-
explanations: NormalizedExplanationConfig[];
|
|
13
10
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ExplanationConfig, ExplanationDefinition } from './explanation';
|
|
2
1
|
import { FieldConfig, FieldDefinition } from './field';
|
|
3
2
|
import { ReportConfig, ReportDefinition } from './report';
|
|
4
3
|
export interface Registry {
|
|
@@ -10,8 +9,4 @@ export interface Registry {
|
|
|
10
9
|
unregisterReport(kind: string): Registry;
|
|
11
10
|
getReport<TConfig extends ReportConfig = ReportConfig>(kind: string): ReportDefinition<TConfig> | undefined;
|
|
12
11
|
listReports(): ReportDefinition<ReportConfig>[];
|
|
13
|
-
registerExplanation<TConfig extends ExplanationConfig>(definition: ExplanationDefinition<TConfig>): Registry;
|
|
14
|
-
unregisterExplanation(kind: string): Registry;
|
|
15
|
-
getExplanation<TConfig extends ExplanationConfig = ExplanationConfig>(kind: string): ExplanationDefinition<TConfig> | undefined;
|
|
16
|
-
listExplanations(): ExplanationDefinition<ExplanationConfig>[];
|
|
17
12
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ZodType } from 'zod';
|
|
2
2
|
import { MaybePromise } from './field';
|
|
3
|
-
import { SubmitResult } from '
|
|
3
|
+
import { SubmitResult } from './submit';
|
|
4
4
|
export type ReportStatus = "idle" | "loading" | "ready" | "error";
|
|
5
|
+
export type ReportFetchStatus = ReportStatus;
|
|
5
6
|
export type ReportPayloadValidationPolicy = "report-error" | "fail-submit";
|
|
6
7
|
export type PartialReportUpdatePolicy = "trust" | "validate" | "defer";
|
|
7
8
|
export interface BaseReportConfig {
|
|
@@ -25,13 +26,33 @@ export interface ReportStateSnapshot {
|
|
|
25
26
|
}
|
|
26
27
|
export interface ReportPayloadContext<TConfig extends ReportConfig = ReportConfig> {
|
|
27
28
|
report: NormalizedReportConfig<TConfig>;
|
|
28
|
-
result: SubmitResult
|
|
29
|
+
result: SubmitResult<ReportStateSnapshot>;
|
|
29
30
|
}
|
|
30
31
|
export interface ReportResolveContext<TConfig extends ReportConfig = ReportConfig> {
|
|
31
32
|
config: NormalizedReportConfig<TConfig>;
|
|
32
33
|
report: NormalizedReportConfig<TConfig>;
|
|
33
|
-
result: SubmitResult
|
|
34
|
+
result: SubmitResult<ReportStateSnapshot>;
|
|
34
35
|
}
|
|
36
|
+
export interface ReportFetchRequest {
|
|
37
|
+
reportId: string;
|
|
38
|
+
backend?: string;
|
|
39
|
+
values: Record<string, unknown>;
|
|
40
|
+
fieldValues: Record<string, unknown>;
|
|
41
|
+
serializedValues: Record<string, unknown>;
|
|
42
|
+
serializedFieldValues: Record<string, unknown>;
|
|
43
|
+
reports: Record<string, unknown>;
|
|
44
|
+
meta: Record<string, unknown>;
|
|
45
|
+
raw: unknown;
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
}
|
|
48
|
+
export interface ReportFetchTransport {
|
|
49
|
+
submit: (request: ReportFetchRequest) => Promise<unknown>;
|
|
50
|
+
}
|
|
51
|
+
export interface ReportFetchContext<TConfig extends ReportConfig = ReportConfig> {
|
|
52
|
+
config: NormalizedReportConfig<TConfig>;
|
|
53
|
+
reportId: string;
|
|
54
|
+
}
|
|
55
|
+
export type ReportFetchFactory<TConfig extends ReportConfig = ReportConfig> = (context: ReportFetchContext<TConfig>) => ReportFetchTransport;
|
|
35
56
|
export interface ReportDefinition<TConfig extends ReportConfig = ReportConfig> {
|
|
36
57
|
kind: string;
|
|
37
58
|
schema: ZodType<TConfig>;
|
|
@@ -39,5 +60,6 @@ export interface ReportDefinition<TConfig extends ReportConfig = ReportConfig> {
|
|
|
39
60
|
payloadValidationPolicy?: ReportPayloadValidationPolicy;
|
|
40
61
|
partialUpdatePolicy?: PartialReportUpdatePolicy;
|
|
41
62
|
clonePayload?: (payload: unknown, config: TConfig) => unknown;
|
|
63
|
+
fetch?: ReportFetchFactory<TConfig>;
|
|
42
64
|
resolvePayload?: (config: TConfig, context: ReportPayloadContext<TConfig>) => MaybePromise<unknown>;
|
|
43
65
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface SubmitResult<TReportState = unknown> {
|
|
2
|
+
backend?: string;
|
|
3
|
+
values: Record<string, unknown>;
|
|
4
|
+
fieldValues: Record<string, unknown>;
|
|
5
|
+
serializedValues: Record<string, unknown>;
|
|
6
|
+
serializedFieldValues: Record<string, unknown>;
|
|
7
|
+
reports: Record<string, unknown>;
|
|
8
|
+
reportStates: Record<string, TReportState>;
|
|
9
|
+
meta: Record<string, unknown>;
|
|
10
|
+
raw: unknown;
|
|
11
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { MLFormError } from '../shared';
|
|
2
1
|
export declare const transportErrorCodes: {
|
|
3
2
|
readonly TIMEOUT: "TIMEOUT";
|
|
4
3
|
readonly AUTH_FAILED: "AUTH_FAILED";
|
|
@@ -16,7 +15,7 @@ export declare const transportErrorCodes: {
|
|
|
16
15
|
readonly QUORUM_NOT_REACHED: "QUORUM_NOT_REACHED";
|
|
17
16
|
};
|
|
18
17
|
export type TransportErrorCode = (typeof transportErrorCodes)[keyof typeof transportErrorCodes] | (string & {});
|
|
19
|
-
export declare class TransportError extends
|
|
18
|
+
export declare class TransportError extends Error {
|
|
20
19
|
readonly cause: unknown;
|
|
21
20
|
readonly source?: string;
|
|
22
21
|
readonly status?: number;
|
|
@@ -3,6 +3,8 @@ export { TransportError, transportErrorCodes, type TransportErrorCode } from './
|
|
|
3
3
|
export { transportDefaults, transportErrorMessages } from './constants';
|
|
4
4
|
export { assertPayloadWithinLimits, assertTransportCapabilities, cloneCapabilities, inferTransportCapabilities, mergeTransportCapabilities, normalizeTransportCapabilities, } from './capabilities';
|
|
5
5
|
export { getTransportPolicyContext, withTransportPolicyContext } from './policy-context';
|
|
6
|
+
export { createTransportRequestRunner, extractErrorMessage } from './request-runner';
|
|
7
|
+
export type { TransportRequestOutcome, TransportRequestRunner } from './request-runner';
|
|
6
8
|
export * from './protocols';
|
|
7
9
|
export * from './middleware';
|
|
8
10
|
export * from './composition';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type TransportRequestOutcome<TResult> = {
|
|
2
|
+
status: "completed";
|
|
3
|
+
value: TResult;
|
|
4
|
+
} | {
|
|
5
|
+
status: "aborted";
|
|
6
|
+
} | {
|
|
7
|
+
status: "failed";
|
|
8
|
+
error: unknown;
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
export type TransportRequestRunner = {
|
|
12
|
+
run<TResult>(submit: (signal: AbortSignal | undefined) => Promise<TResult>, signals?: readonly (AbortSignal | undefined)[]): Promise<TransportRequestOutcome<TResult>>;
|
|
13
|
+
abort(reason?: unknown): void;
|
|
14
|
+
};
|
|
15
|
+
export declare const extractErrorMessage: (error: unknown) => string;
|
|
16
|
+
export declare const createTransportRequestRunner: () => TransportRequestRunner;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mlform",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Composable form generation utilities for machine learning backend integration",
|
|
6
6
|
"keywords": [
|
|
@@ -50,47 +50,34 @@
|
|
|
50
50
|
"dist/**"
|
|
51
51
|
],
|
|
52
52
|
"type": "module",
|
|
53
|
-
"types": "dist/types/src/index.d.ts",
|
|
54
53
|
"exports": {
|
|
55
|
-
".": {
|
|
56
|
-
"types": "./dist/types/src/index.d.ts",
|
|
57
|
-
"import": "./dist/mlform.mjs"
|
|
58
|
-
},
|
|
59
54
|
"./kit": {
|
|
60
|
-
"types": "./dist/types/
|
|
55
|
+
"types": "./dist/types/kit/index.d.ts",
|
|
61
56
|
"import": "./dist/mlform/kit.mjs"
|
|
62
57
|
},
|
|
63
58
|
"./runtime": {
|
|
64
|
-
"types": "./dist/types/
|
|
59
|
+
"types": "./dist/types/runtime/index.d.ts",
|
|
65
60
|
"import": "./dist/mlform/runtime.mjs"
|
|
66
61
|
},
|
|
67
62
|
"./schema": {
|
|
68
|
-
"types": "./dist/types/
|
|
63
|
+
"types": "./dist/types/schema/index.d.ts",
|
|
69
64
|
"import": "./dist/mlform/schema.mjs"
|
|
70
65
|
},
|
|
71
|
-
"./
|
|
72
|
-
"types": "./dist/types/
|
|
73
|
-
"import": "./dist/mlform/
|
|
74
|
-
},
|
|
75
|
-
"./builtins-ml": {
|
|
76
|
-
"types": "./dist/types/src/builtins-ml/index.d.ts",
|
|
77
|
-
"import": "./dist/mlform/builtins-ml.mjs"
|
|
78
|
-
},
|
|
79
|
-
"./behaviors": {
|
|
80
|
-
"types": "./dist/types/src/behaviors/index.d.ts",
|
|
81
|
-
"import": "./dist/mlform/behaviors.mjs"
|
|
66
|
+
"./builtins": {
|
|
67
|
+
"types": "./dist/types/builtins/index.d.ts",
|
|
68
|
+
"import": "./dist/mlform/builtins.mjs"
|
|
82
69
|
},
|
|
83
70
|
"./transport": {
|
|
84
|
-
"types": "./dist/types/
|
|
71
|
+
"types": "./dist/types/transport/index.d.ts",
|
|
85
72
|
"import": "./dist/mlform/transport.mjs"
|
|
86
73
|
},
|
|
87
74
|
"./primitives": {
|
|
88
|
-
"types": "./dist/types/
|
|
75
|
+
"types": "./dist/types/primitives/index.d.ts",
|
|
89
76
|
"import": "./dist/mlform/primitives.mjs"
|
|
90
77
|
},
|
|
91
|
-
"./design
|
|
92
|
-
"types": "./dist/types/
|
|
93
|
-
"import": "./dist/mlform/design
|
|
78
|
+
"./design": {
|
|
79
|
+
"types": "./dist/types/design/index.d.ts",
|
|
80
|
+
"import": "./dist/mlform/design.mjs"
|
|
94
81
|
}
|
|
95
82
|
},
|
|
96
83
|
"publishConfig": {
|
|
@@ -102,11 +89,11 @@
|
|
|
102
89
|
"zod": "4.4.3"
|
|
103
90
|
},
|
|
104
91
|
"devDependencies": {
|
|
105
|
-
"@types/node": "^25.
|
|
92
|
+
"@types/node": "^25.9.1",
|
|
106
93
|
"jsdom": "^29.1.1",
|
|
107
94
|
"typescript": "~6.0.3",
|
|
108
95
|
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
|
|
109
|
-
"vite-plugin-dts": "^5.0.
|
|
96
|
+
"vite-plugin-dts": "^5.0.1",
|
|
110
97
|
"vite-plus": "latest",
|
|
111
98
|
"vitest": "npm:@voidzero-dev/vite-plus-test@latest"
|
|
112
99
|
},
|