mlform 0.1.3 → 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 +224 -152
- 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 -717
- 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 +71 -59
- package/dist/FieldStrategy-CW2h8YyB.js +0 -2427
- package/dist/ModelTypes-B9_veCKB.js +0 -5
- package/dist/ReportStrategy-CxPzs4b2.js +0 -23
- package/dist/boolean-field-Dwz0ejWl.js +0 -104
- package/dist/category-field-DIgX--Px.js +0 -73
- package/dist/classifier-prediction-DgiEREf_.js +0 -193
- package/dist/custom-element-DFxkZ1wU.js +0 -8
- package/dist/date-field-91U2Xe46.js +0 -162
- package/dist/error-card-DHdkE18B.js +0 -195
- package/dist/field-wrapper-CBmpN5T_.js +0 -177
- package/dist/ml-layout-BJax9HVW.js +0 -332
- package/dist/mlform/extensions.mjs +0 -38
- package/dist/mlform/strategies.mjs +0 -292
- package/dist/number-field-Bcp45dJb.js +0 -164
- package/dist/property-B2UZ3Oii.js +0 -536
- package/dist/range-field-CD0kkCt0.js +0 -98
- package/dist/regressor-prediction-CPzZXlmA.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 -25
- 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-Ba1Gr1cr.js +0 -7
- package/dist/test/_fixtures/DummyField.d.ts +0 -9
- package/dist/test/integration/lifecycle.integration.test.d.ts +0 -1
- package/dist/test/integration/registration.integration.test.d.ts +0 -1
- package/dist/test/integration/state.integration.test.d.ts +0 -1
- package/dist/test/integration/validation.integration.test.d.ts +0 -1
- package/dist/test/setup.d.ts +0 -1
- package/dist/test/unit/DummyField.test.d.ts +0 -1
- package/dist/test/unit/Strategies.extensions.test.d.ts +0 -1
- package/dist/test/unit/Strategies.test.d.ts +0 -1
- package/dist/text-field-CSBBr4gN.js +0 -114
package/dist/mlform.mjs
CHANGED
|
@@ -1,717 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
this.counter = 0, this.metadataRegistry = e?.metadata ?? M, this.target = e?.target ?? "draft-2020-12", this.unrepresentable = e?.unrepresentable ?? "throw", this.override = e?.override ?? (() => {
|
|
6
|
-
}), this.io = e?.io ?? "output", this.seen = /* @__PURE__ */ new Map();
|
|
7
|
-
}
|
|
8
|
-
process(e, r = { path: [], schemaPath: [] }) {
|
|
9
|
-
var o;
|
|
10
|
-
const s = e._zod.def, u = {
|
|
11
|
-
guid: "uuid",
|
|
12
|
-
url: "uri",
|
|
13
|
-
datetime: "date-time",
|
|
14
|
-
json_string: "json-string",
|
|
15
|
-
regex: ""
|
|
16
|
-
// do not set
|
|
17
|
-
}, g = this.seen.get(e);
|
|
18
|
-
if (g)
|
|
19
|
-
return g.count++, r.schemaPath.includes(e) && (g.cycle = r.path), g.schema;
|
|
20
|
-
const p = { schema: {}, count: 1, cycle: void 0, path: r.path };
|
|
21
|
-
this.seen.set(e, p);
|
|
22
|
-
const b = e._zod.toJSONSchema?.();
|
|
23
|
-
if (b)
|
|
24
|
-
p.schema = b;
|
|
25
|
-
else {
|
|
26
|
-
const n = {
|
|
27
|
-
...r,
|
|
28
|
-
schemaPath: [...r.schemaPath, e],
|
|
29
|
-
path: r.path
|
|
30
|
-
}, S = e._zod.parent;
|
|
31
|
-
if (S)
|
|
32
|
-
p.ref = S, this.process(S, n), this.seen.get(S).isParent = !0;
|
|
33
|
-
else {
|
|
34
|
-
const c = p.schema;
|
|
35
|
-
switch (s.type) {
|
|
36
|
-
case "string": {
|
|
37
|
-
const t = c;
|
|
38
|
-
t.type = "string";
|
|
39
|
-
const { minimum: i, maximum: a, format: h, patterns: f, contentEncoding: d } = e._zod.bag;
|
|
40
|
-
if (typeof i == "number" && (t.minLength = i), typeof a == "number" && (t.maxLength = a), h && (t.format = u[h] ?? h, t.format === "" && delete t.format), d && (t.contentEncoding = d), f && f.size > 0) {
|
|
41
|
-
const w = [...f];
|
|
42
|
-
w.length === 1 ? t.pattern = w[0].source : w.length > 1 && (p.schema.allOf = [
|
|
43
|
-
...w.map((O) => ({
|
|
44
|
-
...this.target === "draft-7" || this.target === "draft-4" || this.target === "openapi-3.0" ? { type: "string" } : {},
|
|
45
|
-
pattern: O.source
|
|
46
|
-
}))
|
|
47
|
-
]);
|
|
48
|
-
}
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
case "number": {
|
|
52
|
-
const t = c, { minimum: i, maximum: a, format: h, multipleOf: f, exclusiveMaximum: d, exclusiveMinimum: w } = e._zod.bag;
|
|
53
|
-
typeof h == "string" && h.includes("int") ? t.type = "integer" : t.type = "number", typeof w == "number" && (this.target === "draft-4" || this.target === "openapi-3.0" ? (t.minimum = w, t.exclusiveMinimum = !0) : t.exclusiveMinimum = w), typeof i == "number" && (t.minimum = i, typeof w == "number" && this.target !== "draft-4" && (w >= i ? delete t.minimum : delete t.exclusiveMinimum)), typeof d == "number" && (this.target === "draft-4" || this.target === "openapi-3.0" ? (t.maximum = d, t.exclusiveMaximum = !0) : t.exclusiveMaximum = d), typeof a == "number" && (t.maximum = a, typeof d == "number" && this.target !== "draft-4" && (d <= a ? delete t.maximum : delete t.exclusiveMaximum)), typeof f == "number" && (t.multipleOf = f);
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
case "boolean": {
|
|
57
|
-
const t = c;
|
|
58
|
-
t.type = "boolean";
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
case "bigint": {
|
|
62
|
-
if (this.unrepresentable === "throw")
|
|
63
|
-
throw new Error("BigInt cannot be represented in JSON Schema");
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
case "symbol": {
|
|
67
|
-
if (this.unrepresentable === "throw")
|
|
68
|
-
throw new Error("Symbols cannot be represented in JSON Schema");
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
case "null": {
|
|
72
|
-
this.target === "openapi-3.0" ? (c.type = "string", c.nullable = !0, c.enum = [null]) : c.type = "null";
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
case "any":
|
|
76
|
-
break;
|
|
77
|
-
case "unknown":
|
|
78
|
-
break;
|
|
79
|
-
case "undefined": {
|
|
80
|
-
if (this.unrepresentable === "throw")
|
|
81
|
-
throw new Error("Undefined cannot be represented in JSON Schema");
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
case "void": {
|
|
85
|
-
if (this.unrepresentable === "throw")
|
|
86
|
-
throw new Error("Void cannot be represented in JSON Schema");
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
case "never": {
|
|
90
|
-
c.not = {};
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
case "date": {
|
|
94
|
-
if (this.unrepresentable === "throw")
|
|
95
|
-
throw new Error("Date cannot be represented in JSON Schema");
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
case "array": {
|
|
99
|
-
const t = c, { minimum: i, maximum: a } = e._zod.bag;
|
|
100
|
-
typeof i == "number" && (t.minItems = i), typeof a == "number" && (t.maxItems = a), t.type = "array", t.items = this.process(s.element, { ...n, path: [...n.path, "items"] });
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
case "object": {
|
|
104
|
-
const t = c;
|
|
105
|
-
t.type = "object", t.properties = {};
|
|
106
|
-
const i = s.shape;
|
|
107
|
-
for (const f in i)
|
|
108
|
-
t.properties[f] = this.process(i[f], {
|
|
109
|
-
...n,
|
|
110
|
-
path: [...n.path, "properties", f]
|
|
111
|
-
});
|
|
112
|
-
const a = new Set(Object.keys(i)), h = new Set([...a].filter((f) => {
|
|
113
|
-
const d = s.shape[f]._zod;
|
|
114
|
-
return this.io === "input" ? d.optin === void 0 : d.optout === void 0;
|
|
115
|
-
}));
|
|
116
|
-
h.size > 0 && (t.required = Array.from(h)), s.catchall?._zod.def.type === "never" ? t.additionalProperties = !1 : s.catchall ? s.catchall && (t.additionalProperties = this.process(s.catchall, {
|
|
117
|
-
...n,
|
|
118
|
-
path: [...n.path, "additionalProperties"]
|
|
119
|
-
})) : this.io === "output" && (t.additionalProperties = !1);
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
case "union": {
|
|
123
|
-
const t = c, i = s.options.map((a, h) => this.process(a, {
|
|
124
|
-
...n,
|
|
125
|
-
path: [...n.path, "anyOf", h]
|
|
126
|
-
}));
|
|
127
|
-
t.anyOf = i;
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
case "intersection": {
|
|
131
|
-
const t = c, i = this.process(s.left, {
|
|
132
|
-
...n,
|
|
133
|
-
path: [...n.path, "allOf", 0]
|
|
134
|
-
}), a = this.process(s.right, {
|
|
135
|
-
...n,
|
|
136
|
-
path: [...n.path, "allOf", 1]
|
|
137
|
-
}), h = (d) => "allOf" in d && Object.keys(d).length === 1, f = [
|
|
138
|
-
...h(i) ? i.allOf : [i],
|
|
139
|
-
...h(a) ? a.allOf : [a]
|
|
140
|
-
];
|
|
141
|
-
t.allOf = f;
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
case "tuple": {
|
|
145
|
-
const t = c;
|
|
146
|
-
t.type = "array";
|
|
147
|
-
const i = this.target === "draft-2020-12" ? "prefixItems" : "items", a = this.target === "draft-2020-12" || this.target === "openapi-3.0" ? "items" : "additionalItems", h = s.items.map((O, J) => this.process(O, {
|
|
148
|
-
...n,
|
|
149
|
-
path: [...n.path, i, J]
|
|
150
|
-
})), f = s.rest ? this.process(s.rest, {
|
|
151
|
-
...n,
|
|
152
|
-
path: [...n.path, a, ...this.target === "openapi-3.0" ? [s.items.length] : []]
|
|
153
|
-
}) : null;
|
|
154
|
-
this.target === "draft-2020-12" ? (t.prefixItems = h, f && (t.items = f)) : this.target === "openapi-3.0" ? (t.items = {
|
|
155
|
-
anyOf: h
|
|
156
|
-
}, f && t.items.anyOf.push(f), t.minItems = h.length, f || (t.maxItems = h.length)) : (t.items = h, f && (t.additionalItems = f));
|
|
157
|
-
const { minimum: d, maximum: w } = e._zod.bag;
|
|
158
|
-
typeof d == "number" && (t.minItems = d), typeof w == "number" && (t.maxItems = w);
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
case "record": {
|
|
162
|
-
const t = c;
|
|
163
|
-
t.type = "object", (this.target === "draft-7" || this.target === "draft-2020-12") && (t.propertyNames = this.process(s.keyType, {
|
|
164
|
-
...n,
|
|
165
|
-
path: [...n.path, "propertyNames"]
|
|
166
|
-
})), t.additionalProperties = this.process(s.valueType, {
|
|
167
|
-
...n,
|
|
168
|
-
path: [...n.path, "additionalProperties"]
|
|
169
|
-
});
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
case "map": {
|
|
173
|
-
if (this.unrepresentable === "throw")
|
|
174
|
-
throw new Error("Map cannot be represented in JSON Schema");
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
case "set": {
|
|
178
|
-
if (this.unrepresentable === "throw")
|
|
179
|
-
throw new Error("Set cannot be represented in JSON Schema");
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
case "enum": {
|
|
183
|
-
const t = c, i = D(s.entries);
|
|
184
|
-
i.every((a) => typeof a == "number") && (t.type = "number"), i.every((a) => typeof a == "string") && (t.type = "string"), t.enum = i;
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
case "literal": {
|
|
188
|
-
const t = c, i = [];
|
|
189
|
-
for (const a of s.values)
|
|
190
|
-
if (a === void 0) {
|
|
191
|
-
if (this.unrepresentable === "throw")
|
|
192
|
-
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
193
|
-
} else if (typeof a == "bigint") {
|
|
194
|
-
if (this.unrepresentable === "throw")
|
|
195
|
-
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
196
|
-
i.push(Number(a));
|
|
197
|
-
} else
|
|
198
|
-
i.push(a);
|
|
199
|
-
if (i.length !== 0) if (i.length === 1) {
|
|
200
|
-
const a = i[0];
|
|
201
|
-
t.type = a === null ? "null" : typeof a, this.target === "draft-4" || this.target === "openapi-3.0" ? t.enum = [a] : t.const = a;
|
|
202
|
-
} else
|
|
203
|
-
i.every((a) => typeof a == "number") && (t.type = "number"), i.every((a) => typeof a == "string") && (t.type = "string"), i.every((a) => typeof a == "boolean") && (t.type = "string"), i.every((a) => a === null) && (t.type = "null"), t.enum = i;
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
case "file": {
|
|
207
|
-
const t = c, i = {
|
|
208
|
-
type: "string",
|
|
209
|
-
format: "binary",
|
|
210
|
-
contentEncoding: "binary"
|
|
211
|
-
}, { minimum: a, maximum: h, mime: f } = e._zod.bag;
|
|
212
|
-
a !== void 0 && (i.minLength = a), h !== void 0 && (i.maxLength = h), f ? f.length === 1 ? (i.contentMediaType = f[0], Object.assign(t, i)) : t.anyOf = f.map((d) => ({ ...i, contentMediaType: d })) : Object.assign(t, i);
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
case "transform": {
|
|
216
|
-
if (this.unrepresentable === "throw")
|
|
217
|
-
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
case "nullable": {
|
|
221
|
-
const t = this.process(s.innerType, n);
|
|
222
|
-
this.target === "openapi-3.0" ? (p.ref = s.innerType, c.nullable = !0) : c.anyOf = [t, { type: "null" }];
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
case "nonoptional": {
|
|
226
|
-
this.process(s.innerType, n), p.ref = s.innerType;
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
case "success": {
|
|
230
|
-
const t = c;
|
|
231
|
-
t.type = "boolean";
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
case "default": {
|
|
235
|
-
this.process(s.innerType, n), p.ref = s.innerType, c.default = JSON.parse(JSON.stringify(s.defaultValue));
|
|
236
|
-
break;
|
|
237
|
-
}
|
|
238
|
-
case "prefault": {
|
|
239
|
-
this.process(s.innerType, n), p.ref = s.innerType, this.io === "input" && (c._prefault = JSON.parse(JSON.stringify(s.defaultValue)));
|
|
240
|
-
break;
|
|
241
|
-
}
|
|
242
|
-
case "catch": {
|
|
243
|
-
this.process(s.innerType, n), p.ref = s.innerType;
|
|
244
|
-
let t;
|
|
245
|
-
try {
|
|
246
|
-
t = s.catchValue(void 0);
|
|
247
|
-
} catch {
|
|
248
|
-
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
249
|
-
}
|
|
250
|
-
c.default = t;
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
case "nan": {
|
|
254
|
-
if (this.unrepresentable === "throw")
|
|
255
|
-
throw new Error("NaN cannot be represented in JSON Schema");
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
case "template_literal": {
|
|
259
|
-
const t = c, i = e._zod.pattern;
|
|
260
|
-
if (!i)
|
|
261
|
-
throw new Error("Pattern not found in template literal");
|
|
262
|
-
t.type = "string", t.pattern = i.source;
|
|
263
|
-
break;
|
|
264
|
-
}
|
|
265
|
-
case "pipe": {
|
|
266
|
-
const t = this.io === "input" ? s.in._zod.def.type === "transform" ? s.out : s.in : s.out;
|
|
267
|
-
this.process(t, n), p.ref = t;
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
case "readonly": {
|
|
271
|
-
this.process(s.innerType, n), p.ref = s.innerType, c.readOnly = !0;
|
|
272
|
-
break;
|
|
273
|
-
}
|
|
274
|
-
// passthrough types
|
|
275
|
-
case "promise": {
|
|
276
|
-
this.process(s.innerType, n), p.ref = s.innerType;
|
|
277
|
-
break;
|
|
278
|
-
}
|
|
279
|
-
case "optional": {
|
|
280
|
-
this.process(s.innerType, n), p.ref = s.innerType;
|
|
281
|
-
break;
|
|
282
|
-
}
|
|
283
|
-
case "lazy": {
|
|
284
|
-
const t = e._zod.innerType;
|
|
285
|
-
this.process(t, n), p.ref = t;
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
288
|
-
case "custom": {
|
|
289
|
-
if (this.unrepresentable === "throw")
|
|
290
|
-
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
291
|
-
break;
|
|
292
|
-
}
|
|
293
|
-
case "function": {
|
|
294
|
-
if (this.unrepresentable === "throw")
|
|
295
|
-
throw new Error("Function types cannot be represented in JSON Schema");
|
|
296
|
-
break;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
const v = this.metadataRegistry.get(e);
|
|
302
|
-
return v && Object.assign(p.schema, v), this.io === "input" && m(e) && (delete p.schema.examples, delete p.schema.default), this.io === "input" && p.schema._prefault && ((o = p.schema).default ?? (o.default = p.schema._prefault)), delete p.schema._prefault, this.seen.get(e).schema;
|
|
303
|
-
}
|
|
304
|
-
emit(e, r) {
|
|
305
|
-
const o = {
|
|
306
|
-
cycles: r?.cycles ?? "ref",
|
|
307
|
-
reused: r?.reused ?? "inline",
|
|
308
|
-
// unrepresentable: _params?.unrepresentable ?? "throw",
|
|
309
|
-
// uri: _params?.uri ?? ((id) => `${id}`),
|
|
310
|
-
external: r?.external ?? void 0
|
|
311
|
-
}, s = this.seen.get(e);
|
|
312
|
-
if (!s)
|
|
313
|
-
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
314
|
-
const u = (l) => {
|
|
315
|
-
const n = this.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
316
|
-
if (o.external) {
|
|
317
|
-
const i = o.external.registry.get(l[0])?.id, a = o.external.uri ?? ((f) => f);
|
|
318
|
-
if (i)
|
|
319
|
-
return { ref: a(i) };
|
|
320
|
-
const h = l[1].defId ?? l[1].schema.id ?? `schema${this.counter++}`;
|
|
321
|
-
return l[1].defId = h, { defId: h, ref: `${a("__shared")}#/${n}/${h}` };
|
|
322
|
-
}
|
|
323
|
-
if (l[1] === s)
|
|
324
|
-
return { ref: "#" };
|
|
325
|
-
const c = `#/${n}/`, t = l[1].schema.id ?? `__schema${this.counter++}`;
|
|
326
|
-
return { defId: t, ref: c + t };
|
|
327
|
-
}, g = (l) => {
|
|
328
|
-
if (l[1].schema.$ref)
|
|
329
|
-
return;
|
|
330
|
-
const n = l[1], { ref: S, defId: c } = u(l);
|
|
331
|
-
n.def = { ...n.schema }, c && (n.defId = c);
|
|
332
|
-
const t = n.schema;
|
|
333
|
-
for (const i in t)
|
|
334
|
-
delete t[i];
|
|
335
|
-
t.$ref = S;
|
|
336
|
-
};
|
|
337
|
-
if (o.cycles === "throw")
|
|
338
|
-
for (const l of this.seen.entries()) {
|
|
339
|
-
const n = l[1];
|
|
340
|
-
if (n.cycle)
|
|
341
|
-
throw new Error(`Cycle detected: #/${n.cycle?.join("/")}/<root>
|
|
342
|
-
|
|
343
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
344
|
-
}
|
|
345
|
-
for (const l of this.seen.entries()) {
|
|
346
|
-
const n = l[1];
|
|
347
|
-
if (e === l[0]) {
|
|
348
|
-
g(l);
|
|
349
|
-
continue;
|
|
350
|
-
}
|
|
351
|
-
if (o.external) {
|
|
352
|
-
const c = o.external.registry.get(l[0])?.id;
|
|
353
|
-
if (e !== l[0] && c) {
|
|
354
|
-
g(l);
|
|
355
|
-
continue;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
if (this.metadataRegistry.get(l[0])?.id) {
|
|
359
|
-
g(l);
|
|
360
|
-
continue;
|
|
361
|
-
}
|
|
362
|
-
if (n.cycle) {
|
|
363
|
-
g(l);
|
|
364
|
-
continue;
|
|
365
|
-
}
|
|
366
|
-
if (n.count > 1 && o.reused === "ref") {
|
|
367
|
-
g(l);
|
|
368
|
-
continue;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
const p = (l, n) => {
|
|
372
|
-
const S = this.seen.get(l), c = S.def ?? S.schema, t = { ...c };
|
|
373
|
-
if (S.ref === null)
|
|
374
|
-
return;
|
|
375
|
-
const i = S.ref;
|
|
376
|
-
if (S.ref = null, i) {
|
|
377
|
-
p(i, n);
|
|
378
|
-
const a = this.seen.get(i).schema;
|
|
379
|
-
a.$ref && (n.target === "draft-7" || n.target === "draft-4" || n.target === "openapi-3.0") ? (c.allOf = c.allOf ?? [], c.allOf.push(a)) : (Object.assign(c, a), Object.assign(c, t));
|
|
380
|
-
}
|
|
381
|
-
S.isParent || this.override({
|
|
382
|
-
zodSchema: l,
|
|
383
|
-
jsonSchema: c,
|
|
384
|
-
path: S.path ?? []
|
|
385
|
-
});
|
|
386
|
-
};
|
|
387
|
-
for (const l of [...this.seen.entries()].reverse())
|
|
388
|
-
p(l[0], { target: this.target });
|
|
389
|
-
const b = {};
|
|
390
|
-
if (this.target === "draft-2020-12" ? b.$schema = "https://json-schema.org/draft/2020-12/schema" : this.target === "draft-7" ? b.$schema = "http://json-schema.org/draft-07/schema#" : this.target === "draft-4" ? b.$schema = "http://json-schema.org/draft-04/schema#" : this.target === "openapi-3.0" || console.warn(`Invalid target: ${this.target}`), o.external?.uri) {
|
|
391
|
-
const l = o.external.registry.get(e)?.id;
|
|
392
|
-
if (!l)
|
|
393
|
-
throw new Error("Schema is missing an `id` property");
|
|
394
|
-
b.$id = o.external.uri(l);
|
|
395
|
-
}
|
|
396
|
-
Object.assign(b, s.def);
|
|
397
|
-
const v = o.external?.defs ?? {};
|
|
398
|
-
for (const l of this.seen.entries()) {
|
|
399
|
-
const n = l[1];
|
|
400
|
-
n.def && n.defId && (v[n.defId] = n.def);
|
|
401
|
-
}
|
|
402
|
-
o.external || Object.keys(v).length > 0 && (this.target === "draft-2020-12" ? b.$defs = v : b.definitions = v);
|
|
403
|
-
try {
|
|
404
|
-
return JSON.parse(JSON.stringify(b));
|
|
405
|
-
} catch {
|
|
406
|
-
throw new Error("Error converting schema to JSON.");
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
function C(y, e) {
|
|
411
|
-
if (y instanceof R) {
|
|
412
|
-
const o = new x(e), s = {};
|
|
413
|
-
for (const p of y._idmap.entries()) {
|
|
414
|
-
const [b, v] = p;
|
|
415
|
-
o.process(v);
|
|
416
|
-
}
|
|
417
|
-
const u = {}, g = {
|
|
418
|
-
registry: y,
|
|
419
|
-
uri: e?.uri,
|
|
420
|
-
defs: s
|
|
421
|
-
};
|
|
422
|
-
for (const p of y._idmap.entries()) {
|
|
423
|
-
const [b, v] = p;
|
|
424
|
-
u[b] = o.emit(v, {
|
|
425
|
-
...e,
|
|
426
|
-
external: g
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
if (Object.keys(s).length > 0) {
|
|
430
|
-
const p = o.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
431
|
-
u.__shared = {
|
|
432
|
-
[p]: s
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
return { schemas: u };
|
|
436
|
-
}
|
|
437
|
-
const r = new x(e);
|
|
438
|
-
return r.process(y), r.emit(y, e);
|
|
439
|
-
}
|
|
440
|
-
function m(y, e) {
|
|
441
|
-
const r = e ?? { seen: /* @__PURE__ */ new Set() };
|
|
442
|
-
if (r.seen.has(y))
|
|
443
|
-
return !1;
|
|
444
|
-
r.seen.add(y);
|
|
445
|
-
const s = y._zod.def;
|
|
446
|
-
switch (s.type) {
|
|
447
|
-
case "string":
|
|
448
|
-
case "number":
|
|
449
|
-
case "bigint":
|
|
450
|
-
case "boolean":
|
|
451
|
-
case "date":
|
|
452
|
-
case "symbol":
|
|
453
|
-
case "undefined":
|
|
454
|
-
case "null":
|
|
455
|
-
case "any":
|
|
456
|
-
case "unknown":
|
|
457
|
-
case "never":
|
|
458
|
-
case "void":
|
|
459
|
-
case "literal":
|
|
460
|
-
case "enum":
|
|
461
|
-
case "nan":
|
|
462
|
-
case "file":
|
|
463
|
-
case "template_literal":
|
|
464
|
-
return !1;
|
|
465
|
-
case "array":
|
|
466
|
-
return m(s.element, r);
|
|
467
|
-
case "object": {
|
|
468
|
-
for (const u in s.shape)
|
|
469
|
-
if (m(s.shape[u], r))
|
|
470
|
-
return !0;
|
|
471
|
-
return !1;
|
|
472
|
-
}
|
|
473
|
-
case "union": {
|
|
474
|
-
for (const u of s.options)
|
|
475
|
-
if (m(u, r))
|
|
476
|
-
return !0;
|
|
477
|
-
return !1;
|
|
478
|
-
}
|
|
479
|
-
case "intersection":
|
|
480
|
-
return m(s.left, r) || m(s.right, r);
|
|
481
|
-
case "tuple": {
|
|
482
|
-
for (const u of s.items)
|
|
483
|
-
if (m(u, r))
|
|
484
|
-
return !0;
|
|
485
|
-
return !!(s.rest && m(s.rest, r));
|
|
486
|
-
}
|
|
487
|
-
case "record":
|
|
488
|
-
return m(s.keyType, r) || m(s.valueType, r);
|
|
489
|
-
case "map":
|
|
490
|
-
return m(s.keyType, r) || m(s.valueType, r);
|
|
491
|
-
case "set":
|
|
492
|
-
return m(s.valueType, r);
|
|
493
|
-
// inner types
|
|
494
|
-
case "promise":
|
|
495
|
-
case "optional":
|
|
496
|
-
case "nonoptional":
|
|
497
|
-
case "nullable":
|
|
498
|
-
case "readonly":
|
|
499
|
-
return m(s.innerType, r);
|
|
500
|
-
case "lazy":
|
|
501
|
-
return m(s.getter(), r);
|
|
502
|
-
case "default":
|
|
503
|
-
return m(s.innerType, r);
|
|
504
|
-
case "prefault":
|
|
505
|
-
return m(s.innerType, r);
|
|
506
|
-
case "custom":
|
|
507
|
-
return !1;
|
|
508
|
-
case "transform":
|
|
509
|
-
return !0;
|
|
510
|
-
case "pipe":
|
|
511
|
-
return m(s.in, r) || m(s.out, r);
|
|
512
|
-
case "success":
|
|
513
|
-
return !1;
|
|
514
|
-
case "catch":
|
|
515
|
-
return !1;
|
|
516
|
-
case "function":
|
|
517
|
-
return !1;
|
|
518
|
-
}
|
|
519
|
-
throw new Error(`Unknown schema type: ${s.type}`);
|
|
520
|
-
}
|
|
521
|
-
const F = $, A = T, V = z, _ = $(
|
|
522
|
-
I({
|
|
523
|
-
type: T(Object.values(L).map((y) => N(y)))
|
|
524
|
-
})
|
|
525
|
-
);
|
|
526
|
-
I({
|
|
527
|
-
type: T(Object.values(H).map((y) => N(y)))
|
|
528
|
-
});
|
|
529
|
-
P({
|
|
530
|
-
inputs: _,
|
|
531
|
-
outputs: _
|
|
532
|
-
});
|
|
533
|
-
const Y = "[Registry] The type «{type}» already exists.", E = "[Registry] The type «{type}» does not exist.";
|
|
534
|
-
class q {
|
|
535
|
-
catalog = /* @__PURE__ */ new Map();
|
|
536
|
-
combinedSchema = V();
|
|
537
|
-
get schema() {
|
|
538
|
-
return F(this.combinedSchema);
|
|
539
|
-
}
|
|
540
|
-
get(e) {
|
|
541
|
-
return this.catalog.get(e);
|
|
542
|
-
}
|
|
543
|
-
values() {
|
|
544
|
-
return this.catalog.values();
|
|
545
|
-
}
|
|
546
|
-
register(e) {
|
|
547
|
-
if (this.catalog.has(e.type))
|
|
548
|
-
throw new Error(Y.replace("{type}", e.type));
|
|
549
|
-
this.catalog.set(e.type, e), this.rebuildSchema();
|
|
550
|
-
}
|
|
551
|
-
unregister(e) {
|
|
552
|
-
if (!this.catalog.delete(e))
|
|
553
|
-
throw new Error(E.replace("{type}", e));
|
|
554
|
-
this.rebuildSchema();
|
|
555
|
-
}
|
|
556
|
-
update(e) {
|
|
557
|
-
if (!this.catalog.has(e.type))
|
|
558
|
-
throw new Error(E.replace("{type}", e.type));
|
|
559
|
-
this.catalog.set(e.type, e), this.rebuildSchema();
|
|
560
|
-
}
|
|
561
|
-
rebuildSchema() {
|
|
562
|
-
const e = Array.from(this.catalog.values()).map((r) => r.schema);
|
|
563
|
-
this.combinedSchema = A(e);
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
const B = "[DescriptorService] Unsupported <<type>>";
|
|
567
|
-
class j {
|
|
568
|
-
registry = new q();
|
|
569
|
-
loadedTypes = /* @__PURE__ */ new Set();
|
|
570
|
-
temporalOutputs = null;
|
|
571
|
-
constructor(e = "") {
|
|
572
|
-
this.backendUrl = e;
|
|
573
|
-
}
|
|
574
|
-
get reg() {
|
|
575
|
-
return this.registry;
|
|
576
|
-
}
|
|
577
|
-
set tmpOutputs(e) {
|
|
578
|
-
this.temporalOutputs = e;
|
|
579
|
-
}
|
|
580
|
-
async mount(e, r) {
|
|
581
|
-
await this.ensureComponents(e);
|
|
582
|
-
const o = this.renderDescriptors(e);
|
|
583
|
-
r.innerHTML = this.descriptorsToInnerHtml(o);
|
|
584
|
-
}
|
|
585
|
-
async ensureComponents(e) {
|
|
586
|
-
const r = [
|
|
587
|
-
import("./error-card-DHdkE18B.js"),
|
|
588
|
-
import("./ml-layout-BJax9HVW.js"),
|
|
589
|
-
import("./field-wrapper-CBmpN5T_.js")
|
|
590
|
-
];
|
|
591
|
-
for (const o of e) {
|
|
592
|
-
const s = o.type, u = this.reg.get(s);
|
|
593
|
-
if (!u)
|
|
594
|
-
throw new Error(B.replace("type", s));
|
|
595
|
-
this.loadedTypes.has(s) || (this.loadedTypes.add(s), r.push(u.loader()));
|
|
596
|
-
}
|
|
597
|
-
await Promise.all(r);
|
|
598
|
-
}
|
|
599
|
-
renderDescriptors(e) {
|
|
600
|
-
this.reg.schema.parse(e);
|
|
601
|
-
const r = [];
|
|
602
|
-
for (const o of e) {
|
|
603
|
-
const s = o.type, u = this.reg.get(s), g = u.parse(o);
|
|
604
|
-
r.push(
|
|
605
|
-
u.buildDescriptor(g)
|
|
606
|
-
);
|
|
607
|
-
}
|
|
608
|
-
return r;
|
|
609
|
-
}
|
|
610
|
-
descriptorsToInnerHtml(e) {
|
|
611
|
-
return `<ml-layout>
|
|
612
|
-
<div slot="inputs">${e.filter((o) => o.slot === "inputs").map((o) => this.renderDescriptor(o)).join("")}</div>
|
|
613
|
-
<div slot="report"></div>
|
|
614
|
-
<div slot="error"></div>
|
|
615
|
-
</ml-layout>`;
|
|
616
|
-
}
|
|
617
|
-
reportDescriptorsToInnerHtml(e) {
|
|
618
|
-
return e.filter((r) => r.slot === "report").map((r) => this.renderDescriptor(r)).join("");
|
|
619
|
-
}
|
|
620
|
-
async render(e) {
|
|
621
|
-
const r = this.reg.schema.parse(e);
|
|
622
|
-
await this.ensureComponents(r);
|
|
623
|
-
const o = this.renderDescriptors(r), s = document.querySelector('div[slot="report"]');
|
|
624
|
-
s && (s.innerHTML = this.reportDescriptorsToInnerHtml(o));
|
|
625
|
-
}
|
|
626
|
-
async submit(e) {
|
|
627
|
-
let r;
|
|
628
|
-
try {
|
|
629
|
-
const o = await fetch(this.backendUrl, {
|
|
630
|
-
method: "POST",
|
|
631
|
-
credentials: "include",
|
|
632
|
-
body: JSON.stringify(e),
|
|
633
|
-
headers: {
|
|
634
|
-
"Content-Type": "application/json"
|
|
635
|
-
}
|
|
636
|
-
});
|
|
637
|
-
if (!o.ok) throw new Error(await o.text());
|
|
638
|
-
r = await o.json();
|
|
639
|
-
const s = this.reg.schema.parse(this.temporalOutputs);
|
|
640
|
-
s[0].execution_time = r.outputs[0].execution_time, s[0].type === "regressor" ? s[0].values = r.outputs[0].values : s[0].type === "classifier" && (s[0].probabilities = r.outputs[0].probabilities);
|
|
641
|
-
const u = this.reg.schema.parse(s);
|
|
642
|
-
this.render(u), r = u;
|
|
643
|
-
} catch (o) {
|
|
644
|
-
throw new Error(
|
|
645
|
-
`Error al enviar los datos al backend: ${o instanceof Error ? o.message : String(o)}`
|
|
646
|
-
);
|
|
647
|
-
}
|
|
648
|
-
return { outputs: r };
|
|
649
|
-
}
|
|
650
|
-
renderDescriptor(e) {
|
|
651
|
-
const r = this.propsToAttrs(e.props);
|
|
652
|
-
return e.child ? `<${e.tag} ${r}>${this.renderDescriptor(e.child)}</${e.tag}>` : `<${e.tag} ${r}></${e.tag}>`;
|
|
653
|
-
}
|
|
654
|
-
/** Serializa el objeto `props` a atributos HTML. */
|
|
655
|
-
propsToAttrs(e) {
|
|
656
|
-
return Object.entries(e).filter(([, r]) => r != null).map(
|
|
657
|
-
([r, o]) => typeof o == "boolean" && o ? `${r}=""` : `${r}="${String(o)}"`
|
|
658
|
-
).join(" ");
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
class X {
|
|
662
|
-
backendUrl;
|
|
663
|
-
fieldService;
|
|
664
|
-
modelService;
|
|
665
|
-
_lastInputs = null;
|
|
666
|
-
_lastResponse = null;
|
|
667
|
-
_listeners = /* @__PURE__ */ new Set();
|
|
668
|
-
constructor(e) {
|
|
669
|
-
this.backendUrl = e, this.fieldService = new j(), this.modelService = new j(this.backendUrl);
|
|
670
|
-
}
|
|
671
|
-
register(e) {
|
|
672
|
-
e instanceof k ? this.fieldService.reg.register(e) : this.modelService.reg.register(e);
|
|
673
|
-
}
|
|
674
|
-
update(e) {
|
|
675
|
-
e instanceof k ? this.fieldService.reg.update(e) : this.modelService.reg.update(e);
|
|
676
|
-
}
|
|
677
|
-
unregister(e) {
|
|
678
|
-
e instanceof k ? this.fieldService.reg.unregister(e.type) : this.modelService.reg.unregister(e.type);
|
|
679
|
-
}
|
|
680
|
-
/** Lectura sincrónica del último envío */
|
|
681
|
-
get lastInputs() {
|
|
682
|
-
return this._lastInputs;
|
|
683
|
-
}
|
|
684
|
-
get lastResponse() {
|
|
685
|
-
return this._lastResponse;
|
|
686
|
-
}
|
|
687
|
-
/** Suscripción reactiva; devuelve la función para des‑suscribirse */
|
|
688
|
-
onSubmit(e) {
|
|
689
|
-
return this._listeners.add(e), () => this._listeners.delete(e);
|
|
690
|
-
}
|
|
691
|
-
async toHTMLElement(e, r) {
|
|
692
|
-
const o = this.fieldService.reg.schema.parse(e.inputs);
|
|
693
|
-
this.modelService.tmpOutputs = e.outputs, await this.fieldService.mount(o, r);
|
|
694
|
-
const s = r.firstChild;
|
|
695
|
-
return s.modelService = this.modelService, s.__mlSubmitHandler && s.removeEventListener("ml-submit", s.__mlSubmitHandler), s.__mlSubmitHandler = (u) => {
|
|
696
|
-
const { inputs: g, response: p } = u.detail;
|
|
697
|
-
this._lastInputs = g, this._lastResponse = p, this._listeners.forEach((b) => b(g, p));
|
|
698
|
-
}, s.addEventListener("ml-submit", s.__mlSubmitHandler, {
|
|
699
|
-
passive: !0
|
|
700
|
-
}), r;
|
|
701
|
-
}
|
|
702
|
-
async validateSchema(e) {
|
|
703
|
-
return this.fieldService.reg.schema.safeParseAsync(e.inputs);
|
|
704
|
-
}
|
|
705
|
-
schema() {
|
|
706
|
-
return C(
|
|
707
|
-
P({
|
|
708
|
-
inputs: this.fieldService.reg.schema,
|
|
709
|
-
outputs: U(this.modelService.reg.schema)
|
|
710
|
-
}),
|
|
711
|
-
{ target: "draft-2020-12" }
|
|
712
|
-
);
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
export {
|
|
716
|
-
X as MLForm
|
|
717
|
-
};
|
|
1
|
+
import { A as e, B as t, C as n, D as r, E as i, F as a, G as o, H as s, K as c, M as l, N as u, O as d, P as f, R as p, S as m, T as h, U as g, V as _, W as v, _ as y, a as b, b as x, c as S, d as C, f as w, g as T, h as E, i as D, j as O, k, l as A, m as j, n as M, o as N, p as P, q as F, r as I, s as L, t as R, u as z, v as B, w as V, x as H, y as U, z as W } from "./transport-A1RsnZhD.js";
|
|
2
|
+
import { A as G, D as K, M as q, i as J, j as Y, n as X, r as Z } from "./engine-nnhWPT2L.js";
|
|
3
|
+
import { i as Q, n as $, r as ee, t as te } from "./kit-Dt_1Fxlc.js";
|
|
4
|
+
export { c as TransportError, p as assertPayloadWithinLimits, W as assertTransportCapabilities, t as cloneCapabilities, J as createExplanationController, b as createFallbackTransport, N as createFanoutTransport, f as createGraphqlTransport, r as createGrpcSessionTransport, d as createGrpcStreamTransport, k as createGrpcTransport, e as createGrpcUnaryTransport, M as createHedgedTransport, a as createJsonTransport, S as createLoadBalancedTransport, y as createMemoryCircuitBreakerState, E as createMemorySharedRateLimiter, w as createMemoryTransportCacheStore, R as createMemoryTransportHealthState, D as createPipelineTransport, L as createQuorumFanoutTransport, I as createRacingTransport, A as createRoutingTransport, l as createSessionTransport, u as createSseTransport, O as createWebSocketSessionTransport, z as createWeightedRoutingTransport, ee as defaultKitDesignSystem, Q as defaultKitLabels, K as defineExplanationDefinition, q as defineExplanationKind, Y as defineFieldKind, G as defineReportKind, Z as executeExplanations, X as executeFormPipeline, _ as inferTransportCapabilities, s as mergeTransportCapabilities, te as mountForm, g as normalizeTransportCapabilities, i as pipe, v as transportDefaults, F as transportErrorCodes, o as transportErrorMessages, $ as unmountForm, B as withAuth, C as withCache, T as withCircuitBreaker, P as withDedup, H as withLogging, U as withMetrics, j as withRateLimit, m as withRequestTransform, n as withResponseTransform, h as withRetry, V as withTimeout, x as withTracing };
|