mlform 0.1.2 → 0.1.4
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 +241 -88
- package/dist/design-system-CrrSGfFB.js +1352 -0
- package/dist/engine-nnhWPT2L.js +5301 -0
- package/dist/kit-Dt_1Fxlc.js +76 -0
- package/dist/mlform/design-system.mjs +2 -0
- package/dist/mlform/engine.mjs +3 -0
- package/dist/mlform/kit.mjs +3 -0
- package/dist/mlform/primitives.mjs +2 -0
- package/dist/mlform/questionnaire.mjs +640 -0
- package/dist/mlform/transport.mjs +2 -0
- package/dist/mlform.mjs +4 -709
- package/dist/primitives-Pi-ztAr6.js +5063 -0
- package/dist/transport-A1RsnZhD.js +2143 -0
- package/dist/types/src/design-system/constants.d.ts +34 -0
- package/dist/types/src/design-system/contract/component-keys.d.ts +2 -0
- package/dist/types/src/design-system/contract/component-tokens.d.ts +5 -0
- package/dist/types/src/design-system/contract/global-tokens.d.ts +7 -0
- package/dist/types/src/design-system/contract/index.d.ts +4 -0
- package/dist/types/src/design-system/contract/token-keys.d.ts +12 -0
- package/dist/types/src/design-system/index.d.ts +8 -0
- package/dist/types/src/design-system/recipes/contrast.d.ts +2 -0
- package/dist/types/src/design-system/recipes/default.d.ts +2 -0
- package/dist/types/src/design-system/recipes/index.d.ts +4 -0
- package/dist/types/src/design-system/recipes/minimal.d.ts +2 -0
- package/dist/types/src/design-system/recipes/soft.d.ts +2 -0
- package/dist/types/src/design-system/registry/builtins.d.ts +5 -0
- package/dist/types/src/design-system/registry/create-registry.d.ts +2 -0
- package/dist/types/src/design-system/registry/deep-freeze.d.ts +5 -0
- package/dist/types/src/design-system/registry/define-recipe.d.ts +2 -0
- package/dist/types/src/design-system/registry/define-theme.d.ts +2 -0
- package/dist/types/src/design-system/registry/define-token-maps.d.ts +6 -0
- package/dist/types/src/design-system/registry/index.d.ts +5 -0
- package/dist/types/src/design-system/resolve/diagnostics.d.ts +9 -0
- package/dist/types/src/design-system/resolve/index.d.ts +5 -0
- package/dist/types/src/design-system/resolve/merge-config.d.ts +2 -0
- package/dist/types/src/design-system/resolve/migrate-tokens.d.ts +44 -0
- package/dist/types/src/design-system/resolve/resolve-mode.d.ts +6 -0
- package/dist/types/src/design-system/resolve/resolve-recipe.d.ts +2 -0
- package/dist/types/src/design-system/resolve/resolve-theme.d.ts +2 -0
- package/dist/types/src/design-system/resolve/resolve-tokens.d.ts +2 -0
- package/dist/types/src/design-system/runtime/apply-tokens.d.ts +4 -0
- package/dist/types/src/design-system/runtime/attach-design-system.d.ts +11 -0
- package/dist/types/src/design-system/runtime/create-stylesheet.d.ts +11 -0
- package/dist/types/src/design-system/runtime/declarations.d.ts +5 -0
- package/dist/types/src/design-system/runtime/design-system-controller.d.ts +9 -0
- package/dist/types/src/design-system/runtime/host-state.d.ts +3 -0
- package/dist/types/src/design-system/runtime/hydrate-design-system.d.ts +25 -0
- package/dist/types/src/design-system/runtime/index.d.ts +8 -0
- package/dist/types/src/design-system/themes/cobalt.d.ts +2 -0
- package/dist/types/src/design-system/themes/graphite.d.ts +2 -0
- package/dist/types/src/design-system/themes/index.d.ts +5 -0
- package/dist/types/src/design-system/themes/neutral.d.ts +2 -0
- package/dist/types/src/design-system/themes/sage.d.ts +2 -0
- package/dist/types/src/design-system/themes/sunset.d.ts +2 -0
- package/dist/types/src/design-system/tokens/base.d.ts +5 -0
- package/dist/types/src/design-system/tokens/contrast.d.ts +8 -0
- package/dist/types/src/design-system/tokens/density.d.ts +9 -0
- package/dist/types/src/design-system/tokens/forced-colors.d.ts +12 -0
- package/dist/types/src/design-system/tokens/index.d.ts +5 -0
- package/dist/types/src/design-system/tokens/motion.d.ts +2 -0
- package/dist/types/src/design-system/types.d.ts +225 -0
- package/dist/types/src/engine/builtins/fields/boolean.d.ts +8 -0
- package/dist/types/src/engine/builtins/fields/category.d.ts +11 -0
- package/dist/types/src/engine/builtins/fields/date.d.ts +9 -0
- package/dist/types/src/engine/builtins/fields/long-text.d.ts +10 -0
- package/dist/types/src/engine/builtins/fields/multi-choice.d.ts +12 -0
- package/dist/types/src/engine/builtins/fields/number.d.ts +11 -0
- package/dist/types/src/engine/builtins/fields/rating.d.ts +9 -0
- package/dist/types/src/engine/builtins/fields/series.d.ts +20 -0
- package/dist/types/src/engine/builtins/fields/single-choice.d.ts +12 -0
- package/dist/types/src/engine/builtins/fields/text.d.ts +10 -0
- package/dist/types/src/engine/builtins/index.d.ts +97 -0
- package/dist/types/src/engine/builtins/reports/classifier.d.ts +8 -0
- package/dist/types/src/engine/builtins/reports/regressor.d.ts +8 -0
- package/dist/types/src/engine/builtins/shared.d.ts +49 -0
- package/dist/types/src/engine/comparison.d.ts +2 -0
- package/dist/types/src/engine/constants.d.ts +51 -0
- package/dist/types/src/engine/declarative/explanation.d.ts +2 -0
- package/dist/types/src/engine/declarative/field.d.ts +2 -0
- package/dist/types/src/engine/declarative/presentation.d.ts +61 -0
- package/dist/types/src/engine/declarative/report.d.ts +2 -0
- package/dist/types/src/engine/equality.d.ts +4 -0
- package/dist/types/src/engine/errors.d.ts +28 -0
- package/dist/types/src/engine/explanations/controller.d.ts +13 -0
- package/dist/types/src/engine/explanations/index.d.ts +1 -0
- package/dist/types/src/engine/fields/controller.d.ts +30 -0
- package/dist/types/src/engine/fields/index.d.ts +1 -0
- package/dist/types/src/engine/form.d.ts +2 -0
- package/dist/types/src/engine/index.d.ts +11 -0
- package/dist/types/src/engine/paths.d.ts +2 -0
- package/dist/types/src/engine/registry/index.d.ts +26 -0
- package/dist/types/src/engine/reports/controller.d.ts +19 -0
- package/dist/types/src/engine/reports/index.d.ts +1 -0
- package/dist/types/src/engine/schema/index.d.ts +7 -0
- package/dist/types/src/engine/state/engine.d.ts +60 -0
- package/dist/types/src/engine/state/index.d.ts +3 -0
- package/dist/types/src/engine/state/snapshots.d.ts +5 -0
- package/dist/types/src/engine/state/store.d.ts +13 -0
- package/dist/types/src/engine/submission/abort.d.ts +15 -0
- package/dist/types/src/engine/submission/explanations.d.ts +2 -0
- package/dist/types/src/engine/submission/index.d.ts +5 -0
- package/dist/types/src/engine/submission/lifecycle.d.ts +16 -0
- package/dist/types/src/engine/submission/pipeline.d.ts +2 -0
- package/dist/types/src/engine/submission/reports.d.ts +12 -0
- package/dist/types/src/engine/submission/request.d.ts +23 -0
- package/dist/types/src/engine/submission/result.d.ts +4 -0
- package/dist/types/src/engine/submission/submitter.d.ts +40 -0
- package/dist/types/src/engine/types/explanation.d.ts +109 -0
- package/dist/types/src/engine/types/field.d.ts +172 -0
- package/dist/types/src/engine/types/form.d.ts +120 -0
- package/dist/types/src/engine/types/index.d.ts +9 -0
- package/dist/types/src/engine/types/pipeline.d.ts +31 -0
- package/dist/types/src/engine/types/registry.d.ts +17 -0
- package/dist/types/src/engine/types/report.d.ts +87 -0
- package/dist/types/src/engine/types/transport.d.ts +41 -0
- package/dist/types/src/engine/utils.d.ts +9 -0
- package/dist/types/src/engine/validation/conditions.d.ts +11 -0
- package/dist/types/src/engine/validation/field.d.ts +29 -0
- package/dist/types/src/engine/validation/form.d.ts +35 -0
- package/dist/types/src/engine/validation/index.d.ts +3 -0
- package/dist/types/src/engine/values.d.ts +2 -0
- package/dist/types/src/index.d.ts +7 -0
- package/dist/types/src/kit/constants.d.ts +4 -0
- package/dist/types/src/kit/defaults.d.ts +11 -0
- package/dist/types/src/kit/index.d.ts +4 -0
- package/dist/types/src/kit/mount-form.d.ts +3 -0
- package/dist/types/src/kit/types.d.ts +52 -0
- package/dist/types/src/primitives/base-async-report-element.d.ts +19 -0
- package/dist/types/src/primitives/base-explanation-element.d.ts +21 -0
- package/dist/types/src/primitives/base-field-element.d.ts +21 -0
- package/dist/types/src/primitives/base-report-element.d.ts +15 -0
- package/dist/types/src/primitives/components/declarative-explanation.d.ts +5 -0
- package/dist/types/src/primitives/components/declarative-field.d.ts +6 -0
- package/dist/types/src/primitives/components/declarative-report.d.ts +5 -0
- package/dist/types/src/primitives/components/explanation-panel.d.ts +22 -0
- package/dist/types/src/primitives/components/field-frame.d.ts +21 -0
- package/dist/types/src/primitives/components/form-errors.d.ts +19 -0
- package/dist/types/src/primitives/components/form-root.d.ts +29 -0
- package/dist/types/src/primitives/components/presentation.d.ts +4 -0
- package/dist/types/src/primitives/components/report-frame.d.ts +22 -0
- package/dist/types/src/primitives/components/submit-button.d.ts +21 -0
- package/dist/types/src/primitives/components/unsupported-component.d.ts +14 -0
- package/dist/types/src/primitives/constants.d.ts +94 -0
- package/dist/types/src/primitives/controller-binding.d.ts +32 -0
- package/dist/types/src/primitives/fields/boolean-field.d.ts +6 -0
- package/dist/types/src/primitives/fields/category-field.d.ts +6 -0
- package/dist/types/src/primitives/fields/date-field.d.ts +6 -0
- package/dist/types/src/primitives/fields/long-text-field.d.ts +6 -0
- package/dist/types/src/primitives/fields/multi-choice-field.d.ts +6 -0
- package/dist/types/src/primitives/fields/number-field.d.ts +8 -0
- package/dist/types/src/primitives/fields/rating-field.d.ts +6 -0
- package/dist/types/src/primitives/fields/series-field.d.ts +8 -0
- package/dist/types/src/primitives/fields/single-choice-field.d.ts +6 -0
- package/dist/types/src/primitives/fields/text-field.d.ts +6 -0
- package/dist/types/src/primitives/index.d.ts +8 -0
- package/dist/types/src/primitives/mount-form.d.ts +4 -0
- package/dist/types/src/primitives/register.d.ts +0 -0
- package/dist/types/src/primitives/registry.d.ts +3 -0
- package/dist/types/src/primitives/reports/classifier-report.d.ts +5 -0
- package/dist/types/src/primitives/reports/regressor-report.d.ts +5 -0
- package/dist/types/src/primitives/types.d.ts +128 -0
- package/dist/types/src/primitives/utils.d.ts +3 -0
- package/dist/types/src/questionnaire/constants.d.ts +31 -0
- package/dist/types/src/questionnaire/defaults.d.ts +8 -0
- package/dist/types/src/questionnaire/engine/controller.d.ts +12 -0
- package/dist/types/src/questionnaire/engine/schema.d.ts +9 -0
- package/dist/types/src/questionnaire/errors.d.ts +3 -0
- package/dist/types/src/questionnaire/index.d.ts +6 -0
- package/dist/types/src/questionnaire/mount.d.ts +3 -0
- package/dist/types/src/questionnaire/primitives/components/questionnaire-root.d.ts +23 -0
- package/dist/types/src/questionnaire/primitives/components/step-indicator.d.ts +14 -0
- package/dist/types/src/questionnaire/primitives/register.d.ts +0 -0
- package/dist/types/src/questionnaire/types.d.ts +69 -0
- package/dist/types/src/shared/errors.d.ts +3 -0
- package/dist/types/src/shared/index.d.ts +1 -0
- package/dist/types/src/transport/capabilities.d.ts +7 -0
- package/dist/types/src/transport/clone.d.ts +6 -0
- package/dist/types/src/transport/composition/fallback.d.ts +2 -0
- package/dist/types/src/transport/composition/fanout.d.ts +3 -0
- package/dist/types/src/transport/composition/hedged.d.ts +2 -0
- package/dist/types/src/transport/composition/index.d.ts +7 -0
- package/dist/types/src/transport/composition/load-balancing.d.ts +2 -0
- package/dist/types/src/transport/composition/pipeline.d.ts +2 -0
- package/dist/types/src/transport/composition/racing.d.ts +2 -0
- package/dist/types/src/transport/composition/routing.d.ts +3 -0
- package/dist/types/src/transport/constants.d.ts +34 -0
- package/dist/types/src/transport/errors.d.ts +36 -0
- package/dist/types/src/transport/index.d.ts +9 -0
- package/dist/types/src/transport/internal.d.ts +110 -0
- package/dist/types/src/transport/middleware/auth.d.ts +2 -0
- package/dist/types/src/transport/middleware/cache.d.ts +2 -0
- package/dist/types/src/transport/middleware/circuit-breaker.d.ts +2 -0
- package/dist/types/src/transport/middleware/dedup.d.ts +2 -0
- package/dist/types/src/transport/middleware/index.d.ts +12 -0
- package/dist/types/src/transport/middleware/logging.d.ts +2 -0
- package/dist/types/src/transport/middleware/metrics.d.ts +2 -0
- package/dist/types/src/transport/middleware/pipe.d.ts +2 -0
- package/dist/types/src/transport/middleware/rate-limit.d.ts +2 -0
- package/dist/types/src/transport/middleware/retry.d.ts +2 -0
- package/dist/types/src/transport/middleware/timeout.d.ts +2 -0
- package/dist/types/src/transport/middleware/tracing.d.ts +2 -0
- package/dist/types/src/transport/middleware/transform.d.ts +3 -0
- package/dist/types/src/transport/policy-context.d.ts +3 -0
- package/dist/types/src/transport/protocols/graphql.d.ts +2 -0
- package/dist/types/src/transport/protocols/grpc.d.ts +5 -0
- package/dist/types/src/transport/protocols/index.d.ts +5 -0
- package/dist/types/src/transport/protocols/json.d.ts +2 -0
- package/dist/types/src/transport/protocols/sse.d.ts +2 -0
- package/dist/types/src/transport/protocols/websocket.d.ts +2 -0
- package/dist/types/src/transport/runtime.d.ts +4 -0
- package/dist/types/src/transport/state/cache-store.d.ts +2 -0
- package/dist/types/src/transport/state/circuit-breaker.d.ts +2 -0
- package/dist/types/src/transport/state/health.d.ts +2 -0
- package/dist/types/src/transport/state/index.d.ts +5 -0
- package/dist/types/src/transport/state/rate-limiter.d.ts +2 -0
- package/dist/types/src/transport/state/session.d.ts +2 -0
- package/dist/types/src/transport/types/capabilities.d.ts +35 -0
- package/dist/types/src/transport/types/core.d.ts +57 -0
- package/dist/types/src/transport/types/events.d.ts +50 -0
- package/dist/types/src/transport/types/index.d.ts +7 -0
- package/dist/types/src/transport/types/middleware.d.ts +3 -0
- package/dist/types/src/transport/types/options.d.ts +258 -0
- package/dist/types/src/transport/types/session.d.ts +48 -0
- package/dist/types/src/transport/types/state.d.ts +46 -0
- package/package.json +93 -37
- package/dist/FieldStrategy-pPekBtH-.js +0 -2318
- package/dist/ModelTypes-B9_veCKB.js +0 -5
- package/dist/ReportStrategy-DY3GC_mJ.js +0 -23
- package/dist/boolean-field-Cd3uhIPj.js +0 -104
- package/dist/category-field-D_Ms1x9u.js +0 -73
- package/dist/classifier-prediction-C5QzorTo.js +0 -193
- package/dist/custom-element-ttkHUa8w.js +0 -13
- package/dist/date-field-Cg_ja679.js +0 -162
- package/dist/error-card-BwjPChwf.js +0 -195
- package/dist/field-wrapper-DqIQl76d.js +0 -177
- package/dist/ml-layout-Dx63KKf7.js +0 -332
- package/dist/mlform/extensions.mjs +0 -38
- package/dist/mlform/strategies.mjs +0 -292
- package/dist/number-field-CC2DrVEb.js +0 -165
- package/dist/property-jKFNMQpR.js +0 -561
- package/dist/range-field-Cr7LEtsJ.js +0 -98
- package/dist/regressor-prediction-C18dHlfK.js +0 -236
- package/dist/src/core/app/DescriptorItem.d.ts +0 -6
- package/dist/src/core/app/DescriptorRegistry.d.ts +0 -13
- package/dist/src/core/app/DescriptorService.d.ts +0 -22
- package/dist/src/core/app/DescriptorStrategy.d.ts +0 -11
- package/dist/src/core/app/index.d.ts +0 -4
- package/dist/src/core/domain/index.d.ts +0 -24
- package/dist/src/core/index.d.ts +0 -3
- package/dist/src/core/ui/error-card.d.ts +0 -38
- package/dist/src/core/ui/field-wrapper.d.ts +0 -23
- package/dist/src/core/ui/index.d.ts +0 -3
- package/dist/src/core/ui/ml-layout.d.ts +0 -23
- package/dist/src/extensions/app/FieldStrategy.d.ts +0 -10
- package/dist/src/extensions/app/ReportStrategy.d.ts +0 -9
- package/dist/src/extensions/app/index.d.ts +0 -2
- package/dist/src/extensions/domain/BaseField.d.ts +0 -7
- package/dist/src/extensions/domain/BaseModel.d.ts +0 -6
- package/dist/src/extensions/domain/index.d.ts +0 -2
- package/dist/src/extensions/index.d.ts +0 -3
- package/dist/src/extensions/ui/field-element.d.ts +0 -9
- package/dist/src/extensions/ui/index.d.ts +0 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/mlform/index.d.ts +0 -1
- package/dist/src/mlform/mlform.d.ts +0 -27
- package/dist/src/mlform/mlform.types.d.ts +0 -11
- package/dist/src/strategies/app/BooleanStrategy.d.ts +0 -12
- package/dist/src/strategies/app/CategoryStrategy.d.ts +0 -13
- package/dist/src/strategies/app/ClassifierStrategy.d.ts +0 -15
- package/dist/src/strategies/app/DateStrategy.d.ts +0 -15
- package/dist/src/strategies/app/NumberStrategy.d.ts +0 -29
- package/dist/src/strategies/app/RegressorStrategy.d.ts +0 -15
- package/dist/src/strategies/app/TextStrategy.d.ts +0 -16
- package/dist/src/strategies/app/index.d.ts +0 -7
- package/dist/src/strategies/domain/BooleanField.d.ts +0 -10
- package/dist/src/strategies/domain/CategoryField.d.ts +0 -11
- package/dist/src/strategies/domain/ClassifierModel.d.ts +0 -11
- package/dist/src/strategies/domain/DateField.d.ts +0 -13
- package/dist/src/strategies/domain/FieldTypes.d.ts +0 -7
- package/dist/src/strategies/domain/ModelTypes.d.ts +0 -4
- package/dist/src/strategies/domain/NumberField.d.ts +0 -15
- package/dist/src/strategies/domain/RegressorModel.d.ts +0 -11
- package/dist/src/strategies/domain/TextField.d.ts +0 -14
- package/dist/src/strategies/domain/index.d.ts +0 -9
- package/dist/src/strategies/index.d.ts +0 -1
- package/dist/src/strategies/ui/boolean-field.d.ts +0 -13
- package/dist/src/strategies/ui/category-field.d.ts +0 -14
- package/dist/src/strategies/ui/classifier-prediction.d.ts +0 -39
- package/dist/src/strategies/ui/date-field.d.ts +0 -18
- package/dist/src/strategies/ui/index.d.ts +0 -8
- package/dist/src/strategies/ui/number-field.d.ts +0 -19
- package/dist/src/strategies/ui/range-field.d.ts +0 -17
- package/dist/src/strategies/ui/regressor-prediction.d.ts +0 -29
- package/dist/src/strategies/ui/text-field.d.ts +0 -17
- package/dist/state-CLlTRyl1.js +0 -12
- package/dist/test/_fixtures/DummyField.d.ts +0 -9
- package/dist/test/setup.d.ts +0 -1
- package/dist/test/unit/DummyField.test.d.ts +0 -1
- package/dist/text-field-DwP-Fa1w.js +0 -114
package/README.md
CHANGED
|
@@ -2,131 +2,284 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/UlloaSP/mlform/actions/workflows/ci.yml)
|
|
4
4
|
[](https://github.com/UlloaSP/mlform/actions/workflows/release.yml)
|
|
5
|
+
[](https://www.npmjs.com/package/mlform)
|
|
6
|
+
[](LICENSE)
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
Schema-driven forms for machine learning applications.
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
MLForm gives you a predictable UI layer between users and model backends. You describe inputs and reports with a schema, MLForm renders accessible Web Components, validates values, submits structured payloads, and displays model results in the same host container.
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
- **Integración ML**: Soporte para modelos de clasificación y regresión
|
|
12
|
-
- **Web Components**: Componentes reutilizables basados en Lit
|
|
13
|
-
- **TypeScript**: Totalmente tipado para mejor DX
|
|
14
|
-
- **Validación**: Validación robusta con Zod
|
|
12
|
+
Version `0.1.4` is the current release in this repository.
|
|
15
13
|
|
|
16
|
-
##
|
|
14
|
+
## Why MLForm
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
npm install mlform
|
|
20
|
-
```
|
|
16
|
+
Most ML product forms drift over time:
|
|
21
17
|
|
|
22
|
-
|
|
18
|
+
- the frontend shape stops matching the backend contract
|
|
19
|
+
- validation rules end up duplicated across components
|
|
20
|
+
- model outputs are rendered ad hoc in each screen
|
|
21
|
+
- design and accessibility regress when teams move fast
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
MLForm solves that by centering everything on an explicit schema and a transport layer.
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
- npm >= 9
|
|
25
|
+
Use it for:
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
- prediction forms
|
|
28
|
+
- scoring and approval tools
|
|
29
|
+
- forecasting dashboards
|
|
30
|
+
- internal review consoles
|
|
31
|
+
- embedded model workflows inside larger apps
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
# Clonar el repositorio
|
|
33
|
-
git clone https://github.com/UlloaSP/mlform.git
|
|
34
|
-
cd mlform
|
|
33
|
+
## Install
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
npm install
|
|
35
|
+
For application usage:
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
npm
|
|
37
|
+
```bash
|
|
38
|
+
npm install mlform
|
|
39
|
+
```
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
npm run lint
|
|
41
|
+
Import from the root package unless you specifically need a lower-level surface:
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
```ts
|
|
44
|
+
import { createJsonTransport, mountForm } from "mlform";
|
|
45
|
+
```
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
npm run type
|
|
47
|
+
## Quick Start
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
npm run build
|
|
49
|
+
Create a host element:
|
|
53
50
|
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
```html
|
|
52
|
+
<div id="prediction-form"></div>
|
|
56
53
|
```
|
|
57
54
|
|
|
58
|
-
|
|
55
|
+
Mount a form:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { createJsonTransport, mountForm } from "mlform";
|
|
59
|
+
|
|
60
|
+
const container = document.querySelector("#prediction-form");
|
|
61
|
+
|
|
62
|
+
if (!container) {
|
|
63
|
+
throw new Error("Missing #prediction-form container.");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const mounted = mountForm(container as HTMLElement, {
|
|
67
|
+
transport: createJsonTransport({ endpoint: "/api/predict" }),
|
|
68
|
+
schema: {
|
|
69
|
+
fields: [
|
|
70
|
+
{
|
|
71
|
+
id: "prompt",
|
|
72
|
+
kind: "text",
|
|
73
|
+
label: "Prompt",
|
|
74
|
+
required: true,
|
|
75
|
+
minLength: 3,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "threshold",
|
|
79
|
+
kind: "number",
|
|
80
|
+
label: "Confidence threshold",
|
|
81
|
+
min: 0,
|
|
82
|
+
max: 1,
|
|
83
|
+
step: 0.05,
|
|
84
|
+
defaultValue: 0.75,
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
reports: [
|
|
88
|
+
{
|
|
89
|
+
id: "prediction",
|
|
90
|
+
kind: "classifier",
|
|
91
|
+
label: "Prediction",
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
labels: {
|
|
96
|
+
submit: "Run prediction",
|
|
97
|
+
submitting: "Running...",
|
|
98
|
+
},
|
|
99
|
+
layout: "split",
|
|
100
|
+
designSystem: {
|
|
101
|
+
mode: "auto",
|
|
102
|
+
theme: "cobalt",
|
|
103
|
+
recipe: "soft",
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
window.addEventListener("beforeunload", () => mounted.unmount());
|
|
108
|
+
```
|
|
59
109
|
|
|
60
|
-
|
|
61
|
-
- `npm run lint:fix` - Corrige automáticamente los errores de linting
|
|
62
|
-
- `npm run format` - Formatea el código con Prettier
|
|
63
|
-
- `npm run format:check` - Verifica el formato del código
|
|
64
|
-
- `npm run type` - Verifica tipos con TypeScript
|
|
65
|
-
- `npm run test` - Ejecuta tests con Vitest
|
|
66
|
-
- `npm run test:watch` - Ejecuta tests en modo watch
|
|
67
|
-
- `npm run coverage` - Genera reporte de cobertura
|
|
68
|
-
- `npm run build` - Construye el proyecto para producción
|
|
69
|
-
- `npm run docs` - Genera documentación con TypeDoc
|
|
70
|
-
- `npm run ci` - Ejecuta todo el pipeline de CI localmente
|
|
110
|
+
The default JSON transport sends:
|
|
71
111
|
|
|
72
|
-
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"inputs": {
|
|
115
|
+
"prompt": "Example text",
|
|
116
|
+
"threshold": 0.75
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
73
120
|
|
|
74
|
-
|
|
121
|
+
Return reports keyed by report id:
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"reports": {
|
|
126
|
+
"prediction": {
|
|
127
|
+
"label": "Approved",
|
|
128
|
+
"confidence": 0.91,
|
|
129
|
+
"probabilities": {
|
|
130
|
+
"Approved": 0.91,
|
|
131
|
+
"Rejected": 0.09
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"meta": {
|
|
136
|
+
"model": "credit-risk-v2"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
75
140
|
|
|
76
|
-
|
|
141
|
+
## What You Get
|
|
142
|
+
|
|
143
|
+
- Schema-driven fields, reports, conditions, defaults, and serialization
|
|
144
|
+
- Accessible Web Components for form inputs, submit actions, and result rendering
|
|
145
|
+
- Built-in JSON transport plus composable transport middleware
|
|
146
|
+
- Headless engine APIs for custom orchestration and registries
|
|
147
|
+
- Runtime design system with themes, recipes, density, motion, and token overrides
|
|
148
|
+
- Extension points for custom field, report, and explanation kinds
|
|
149
|
+
|
|
150
|
+
Built-in fields:
|
|
151
|
+
|
|
152
|
+
- `text`
|
|
153
|
+
- `number`
|
|
154
|
+
- `boolean`
|
|
155
|
+
- `category`
|
|
156
|
+
- `date`
|
|
157
|
+
- `time-series`
|
|
158
|
+
|
|
159
|
+
Built-in reports:
|
|
160
|
+
|
|
161
|
+
- `classifier`
|
|
162
|
+
- `regressor`
|
|
163
|
+
|
|
164
|
+
Built-in themes:
|
|
165
|
+
|
|
166
|
+
- `neutral`
|
|
167
|
+
- `cobalt`
|
|
168
|
+
- `graphite`
|
|
169
|
+
- `sage`
|
|
170
|
+
- `sunset`
|
|
171
|
+
|
|
172
|
+
Built-in recipes:
|
|
173
|
+
|
|
174
|
+
- `default`
|
|
175
|
+
- `minimal`
|
|
176
|
+
- `soft`
|
|
177
|
+
- `contrast`
|
|
178
|
+
|
|
179
|
+
## Package Surfaces
|
|
180
|
+
|
|
181
|
+
| Surface | Use it for |
|
|
182
|
+
| ---------------------- | ---------------------------------------------------------------------------------------- |
|
|
183
|
+
| `mlform` | Application-first API for mounting forms with sensible defaults. |
|
|
184
|
+
| `mlform/kit` | Explicit kit entrypoint with mount, transport, labels, and lifecycle utilities. |
|
|
185
|
+
| `mlform/engine` | Headless state, validation, registries, hooks, conditions, and submission orchestration. |
|
|
186
|
+
| `mlform/primitives` | Web Component renderers and custom renderer registries. |
|
|
187
|
+
| `mlform/design-system` | Themes, recipes, tokens, mode resolution, and host integration. |
|
|
188
|
+
| `mlform/transport` | Transport composition, middleware, resilience policies, and orchestration helpers. |
|
|
189
|
+
|
|
190
|
+
## Custom Domain Kinds
|
|
191
|
+
|
|
192
|
+
When built-in kinds are not enough, define your own field and report kinds without rewriting the normal rendering path.
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
import { createBuiltinRegistry, defineFieldKind } from "mlform/engine";
|
|
196
|
+
import { z } from "zod";
|
|
197
|
+
|
|
198
|
+
const registry = createBuiltinRegistry();
|
|
199
|
+
|
|
200
|
+
registry.registerField(
|
|
201
|
+
defineFieldKind({
|
|
202
|
+
kind: "score",
|
|
203
|
+
schema: z.object({
|
|
204
|
+
kind: z.literal("score"),
|
|
205
|
+
id: z.string().optional(),
|
|
206
|
+
label: z.string(),
|
|
207
|
+
min: z.number().default(0),
|
|
208
|
+
max: z.number().default(100),
|
|
209
|
+
}),
|
|
210
|
+
value: {
|
|
211
|
+
default: () => 0,
|
|
212
|
+
normalize: (value) => Number(value ?? 0),
|
|
213
|
+
serialize: (value) => value,
|
|
214
|
+
},
|
|
215
|
+
validate: ({ value, config }) =>
|
|
216
|
+
value < config.min || value > config.max ? ["Score out of range."] : [],
|
|
217
|
+
render: {
|
|
218
|
+
widget: "number",
|
|
219
|
+
hints: ({ config }) => ({
|
|
220
|
+
min: config.min,
|
|
221
|
+
max: config.max,
|
|
222
|
+
unit: "%",
|
|
223
|
+
}),
|
|
224
|
+
},
|
|
225
|
+
}),
|
|
226
|
+
);
|
|
227
|
+
```
|
|
77
228
|
|
|
78
|
-
|
|
229
|
+
Stay at the declarative `define*Kind` layer unless you truly need fully custom rendering or low-level primitive behavior.
|
|
79
230
|
|
|
80
|
-
|
|
81
|
-
2. **📝 Type Check** - Verificación de tipos TypeScript
|
|
82
|
-
3. **🧪 Testing** - Tests unitarios en múltiples versiones de Node.js (18, 20, 22)
|
|
83
|
-
4. **🏗️ Build** - Construcción del proyecto
|
|
84
|
-
5. **📚 Documentation** - Generación de documentación (solo en main/docs)
|
|
85
|
-
6. **🔒 Security** - Auditoría de seguridad de dependencias
|
|
231
|
+
## Typical Flow
|
|
86
232
|
|
|
87
|
-
|
|
233
|
+
1. Define the schema with `fields` and `reports`.
|
|
234
|
+
2. Mount the form with `mountForm`.
|
|
235
|
+
3. Point the transport at your model endpoint or custom backend adapter.
|
|
236
|
+
4. Return normalized reports from the backend.
|
|
237
|
+
5. Customize theme, recipe, labels, or registries only where your product needs it.
|
|
88
238
|
|
|
89
|
-
|
|
239
|
+
## Documentation
|
|
90
240
|
|
|
91
|
-
|
|
92
|
-
|
|
241
|
+
- Docs home: https://ulloasp.github.io/mlform/
|
|
242
|
+
- Quick start: https://ulloasp.github.io/mlform/getting-started/quick-start/
|
|
243
|
+
- Installation: https://ulloasp.github.io/mlform/getting-started/installation/
|
|
244
|
+
- Backend contract: https://ulloasp.github.io/mlform/guides/backend-contract/
|
|
245
|
+
- Transport guide: https://ulloasp.github.io/mlform/kit/transport/
|
|
246
|
+
- Design system: https://ulloasp.github.io/mlform/design-system/overview/
|
|
247
|
+
- API reference: https://ulloasp.github.io/mlform/reference/kit/
|
|
248
|
+
- Migration guide: https://ulloasp.github.io/mlform/migration/from-legacy-mlform/
|
|
249
|
+
- Versioning notes: https://ulloasp.github.io/mlform/support/versioning/
|
|
93
250
|
|
|
94
|
-
|
|
251
|
+
## Development
|
|
95
252
|
|
|
96
|
-
|
|
97
|
-
- **Linting**: Sin errores
|
|
98
|
-
- **Formato**: Código debe seguir las reglas de Prettier
|
|
99
|
-
- **Tipos**: Sin errores de TypeScript
|
|
100
|
-
- **Build**: Debe compilar sin errores
|
|
253
|
+
This repository uses Vite+. Do not use `npm`, `pnpm`, or `yarn` directly for workspace tasks in this repo.
|
|
101
254
|
|
|
102
|
-
|
|
255
|
+
Run the main package checks:
|
|
103
256
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
257
|
+
```bash
|
|
258
|
+
vp install
|
|
259
|
+
vp check
|
|
260
|
+
vp test
|
|
261
|
+
vp build
|
|
262
|
+
```
|
|
107
263
|
|
|
108
|
-
|
|
264
|
+
Docs live in `docs/`:
|
|
109
265
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
266
|
+
```bash
|
|
267
|
+
cd docs
|
|
268
|
+
vp install
|
|
269
|
+
vp run typecheck
|
|
270
|
+
vp run build
|
|
271
|
+
vp run dev
|
|
272
|
+
```
|
|
115
273
|
|
|
116
|
-
|
|
274
|
+
The main package targets Node.js `>=24.9.0`.
|
|
117
275
|
|
|
118
|
-
|
|
119
|
-
- Escribe tests para nuevas funcionalidades
|
|
120
|
-
- Mantén la cobertura de tests >= 80%
|
|
121
|
-
- Documenta el código con JSDoc
|
|
122
|
-
- Usa Conventional Commits para mensajes de commit
|
|
276
|
+
## Release Notes
|
|
123
277
|
|
|
124
|
-
|
|
278
|
+
For `0.1.4`, use the repository release entry and the published docs as the source of truth:
|
|
125
279
|
|
|
126
|
-
|
|
280
|
+
- GitHub releases: https://github.com/UlloaSP/mlform/releases
|
|
281
|
+
- npm package: https://www.npmjs.com/package/mlform
|
|
127
282
|
|
|
128
|
-
##
|
|
283
|
+
## License
|
|
129
284
|
|
|
130
|
-
|
|
131
|
-
- [Issues](https://github.com/UlloaSP/mlform/issues)
|
|
132
|
-
- [NPM Package](https://www.npmjs.com/package/mlform)
|
|
285
|
+
MIT
|