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
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ExplanationController, ExplanationDescriptor, ExplanationFetchRequest, ExplanationFetchTransport, FieldController, FieldDescriptor, FormController, FormState, FormStatus, ReportController, ReportDescriptor, SubmitResult } from '../../engine';
|
|
2
|
+
import { PrimitiveText, PrimitiveTextOverrides } from './constants';
|
|
3
|
+
export type PrimitiveLayout = "stacked" | "split";
|
|
4
|
+
export type PrimitiveContainerStrategy = "error" | "replace";
|
|
5
|
+
export interface PrimitiveRegistry {
|
|
6
|
+
registerField(component: string, tagName: string): PrimitiveRegistry;
|
|
7
|
+
unregisterField(component: string): PrimitiveRegistry;
|
|
8
|
+
resolveField(component: string): string | undefined;
|
|
9
|
+
registerReport(component: string, tagName: string): PrimitiveRegistry;
|
|
10
|
+
unregisterReport(component: string): PrimitiveRegistry;
|
|
11
|
+
resolveReport(component: string): string | undefined;
|
|
12
|
+
registerExplanation(component: string, tagName: string): PrimitiveRegistry;
|
|
13
|
+
unregisterExplanation(component: string): PrimitiveRegistry;
|
|
14
|
+
resolveExplanation(component: string): string | undefined;
|
|
15
|
+
clone(): PrimitiveRegistry;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Request passed to a PrimitiveReportTransport when a report becomes ready.
|
|
19
|
+
* Contains the full submit result so a report renderer can fetch any
|
|
20
|
+
* post-submit data it needs, plus the `reportId` identifying that report.
|
|
21
|
+
*/
|
|
22
|
+
export interface PrimitiveReportRequest {
|
|
23
|
+
reportId: string;
|
|
24
|
+
backend?: string;
|
|
25
|
+
values: Record<string, unknown>;
|
|
26
|
+
fieldValues: Record<string, unknown>;
|
|
27
|
+
serializedValues: Record<string, unknown>;
|
|
28
|
+
serializedFieldValues: Record<string, unknown>;
|
|
29
|
+
reports: Record<string, unknown>;
|
|
30
|
+
meta: Record<string, unknown>;
|
|
31
|
+
raw: unknown;
|
|
32
|
+
signal?: AbortSignal;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Transport for fetching post-submit report content.
|
|
36
|
+
* Receives the full submit result + report context; may return any value.
|
|
37
|
+
* Renderers decide how to display loading, success, and error states.
|
|
38
|
+
*/
|
|
39
|
+
export interface PrimitiveReportTransport {
|
|
40
|
+
submit: (request: PrimitiveReportRequest) => Promise<unknown>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Re-exports of engine explanation types for convenience in the primitives
|
|
44
|
+
* layer. Explanation transport is now per-plugin (defined in ExplanationDefinition)
|
|
45
|
+
* rather than a global mount-time option.
|
|
46
|
+
*/
|
|
47
|
+
export type ExplanationRequest = ExplanationFetchRequest;
|
|
48
|
+
export type ExplanationTransport = ExplanationFetchTransport;
|
|
49
|
+
export interface MountFormOptions {
|
|
50
|
+
registry?: PrimitiveRegistry;
|
|
51
|
+
layout?: PrimitiveLayout;
|
|
52
|
+
containerStrategy?: PrimitiveContainerStrategy;
|
|
53
|
+
formLabel?: string;
|
|
54
|
+
reportsLabel?: string;
|
|
55
|
+
submitLabel?: string;
|
|
56
|
+
validatingLabel?: string;
|
|
57
|
+
submittingLabel?: string;
|
|
58
|
+
reportPane?: "auto" | "always" | "hidden";
|
|
59
|
+
text?: PrimitiveTextOverrides;
|
|
60
|
+
/** Optional transport for report renderers that fetch extra data after submit. */
|
|
61
|
+
reportTransport?: PrimitiveReportTransport;
|
|
62
|
+
}
|
|
63
|
+
export interface MountedForm {
|
|
64
|
+
readonly form: FormController;
|
|
65
|
+
readonly host: HTMLElement;
|
|
66
|
+
readonly registry: PrimitiveRegistry;
|
|
67
|
+
readonly text: PrimitiveText;
|
|
68
|
+
unmount(): void;
|
|
69
|
+
}
|
|
70
|
+
export interface PrimitiveFieldRenderContext {
|
|
71
|
+
controlId: string;
|
|
72
|
+
label: string;
|
|
73
|
+
description?: string;
|
|
74
|
+
errors: readonly string[];
|
|
75
|
+
descriptionId?: string;
|
|
76
|
+
errorId?: string;
|
|
77
|
+
describedBy?: string;
|
|
78
|
+
invalid: boolean;
|
|
79
|
+
required: boolean;
|
|
80
|
+
disabled: boolean;
|
|
81
|
+
readOnly: boolean;
|
|
82
|
+
}
|
|
83
|
+
export interface PrimitiveReportRenderContext {
|
|
84
|
+
regionId: string;
|
|
85
|
+
label: string;
|
|
86
|
+
description?: string;
|
|
87
|
+
}
|
|
88
|
+
export interface PrimitiveExplanationRenderContext {
|
|
89
|
+
regionId: string;
|
|
90
|
+
label?: string;
|
|
91
|
+
description?: string;
|
|
92
|
+
}
|
|
93
|
+
export interface PrimitiveFieldRendererElement extends HTMLElement {
|
|
94
|
+
controller?: FieldController;
|
|
95
|
+
descriptor?: FieldDescriptor | null;
|
|
96
|
+
context?: PrimitiveFieldRenderContext;
|
|
97
|
+
text?: PrimitiveText;
|
|
98
|
+
}
|
|
99
|
+
export interface PrimitiveReportRendererElement extends HTMLElement {
|
|
100
|
+
controller?: ReportController;
|
|
101
|
+
descriptor?: ReportDescriptor | null;
|
|
102
|
+
context?: PrimitiveReportRenderContext;
|
|
103
|
+
text?: PrimitiveText;
|
|
104
|
+
transport?: PrimitiveReportTransport;
|
|
105
|
+
request?: PrimitiveReportRequest | null;
|
|
106
|
+
}
|
|
107
|
+
export interface PrimitiveExplanationRendererElement extends HTMLElement {
|
|
108
|
+
controller?: ExplanationController;
|
|
109
|
+
descriptor?: ExplanationDescriptor | null;
|
|
110
|
+
context?: PrimitiveExplanationRenderContext;
|
|
111
|
+
text?: PrimitiveText;
|
|
112
|
+
}
|
|
113
|
+
export interface PrimitiveSubmitStartDetail {
|
|
114
|
+
form: FormController;
|
|
115
|
+
state: FormState;
|
|
116
|
+
}
|
|
117
|
+
export interface PrimitiveSubmitSuccessDetail {
|
|
118
|
+
form: FormController;
|
|
119
|
+
state: FormState;
|
|
120
|
+
result: SubmitResult;
|
|
121
|
+
}
|
|
122
|
+
export interface PrimitiveSubmitErrorDetail {
|
|
123
|
+
form: FormController;
|
|
124
|
+
state: FormState;
|
|
125
|
+
error: unknown;
|
|
126
|
+
status: FormStatus;
|
|
127
|
+
}
|
|
128
|
+
export type { PrimitiveText, PrimitiveTextOverrides } from './constants';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const questionnaireTagNames: {
|
|
2
|
+
readonly questionnaire: "mlf-questionnaire";
|
|
3
|
+
readonly stepIndicator: "mlf-step-indicator";
|
|
4
|
+
};
|
|
5
|
+
export declare const questionnaireEventNames: {
|
|
6
|
+
readonly stepChange: "mlf-step-change";
|
|
7
|
+
readonly stepValidationError: "mlf-step-validation-error";
|
|
8
|
+
readonly submitStart: "mlf-q-submit-start";
|
|
9
|
+
readonly submitAbort: "mlf-q-submit-abort";
|
|
10
|
+
readonly submitSuccess: "mlf-q-submit-success";
|
|
11
|
+
readonly submitError: "mlf-q-submit-error";
|
|
12
|
+
};
|
|
13
|
+
export interface QuestionnaireLabels {
|
|
14
|
+
prev?: string;
|
|
15
|
+
next?: string;
|
|
16
|
+
submit?: string;
|
|
17
|
+
validating?: string;
|
|
18
|
+
submitting?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface QuestionnaireText {
|
|
21
|
+
stepLabel: (current: number, total: number) => string;
|
|
22
|
+
prevLabel: string;
|
|
23
|
+
nextLabel: string;
|
|
24
|
+
submitLabel: string;
|
|
25
|
+
validatingLabel: string;
|
|
26
|
+
submittingLabel: string;
|
|
27
|
+
}
|
|
28
|
+
export type QuestionnaireTextOverrides = Partial<QuestionnaireText>;
|
|
29
|
+
export declare const questionnaireDefaultLabels: Required<QuestionnaireLabels>;
|
|
30
|
+
export declare const questionnaireStaticText: QuestionnaireText;
|
|
31
|
+
export declare const resolveQuestionnaireText: (overrides?: QuestionnaireTextOverrides) => QuestionnaireText;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DesignSystemConfig, DesignSystemRegistry } from '../../design-system';
|
|
2
|
+
import { Registry } from '../../engine';
|
|
3
|
+
import { PrimitiveRegistry } from '../../primitives';
|
|
4
|
+
export declare const defaultQuestionnaireDesignSystem: DesignSystemConfig;
|
|
5
|
+
export declare const cloneQuestionnaireEngineRegistry: (registry?: Registry) => Registry;
|
|
6
|
+
export declare const resolveQuestionnairePrimitiveRegistry: (registry?: PrimitiveRegistry) => PrimitiveRegistry;
|
|
7
|
+
export declare const resolveQuestionnaireDesignSystemRegistry: (registry?: DesignSystemRegistry) => DesignSystemRegistry;
|
|
8
|
+
export declare const resolveQuestionnaireDesignSystem: (config?: DesignSystemConfig) => DesignSystemConfig;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FormController } from '../../../engine';
|
|
2
|
+
import { IQuestionnaireController, NormalizedStepConfig, QuestionnaireState } from '../types';
|
|
3
|
+
export declare class QuestionnaireController implements IQuestionnaireController {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(form: FormController, steps: readonly NormalizedStepConfig[]);
|
|
6
|
+
get steps(): readonly NormalizedStepConfig[];
|
|
7
|
+
get form(): FormController;
|
|
8
|
+
get state(): QuestionnaireState;
|
|
9
|
+
next(): Promise<boolean>;
|
|
10
|
+
prev(): void;
|
|
11
|
+
subscribe(listener: (state: QuestionnaireState) => void): () => void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FormSchema, Registry } from '../../../engine';
|
|
2
|
+
import { NormalizedStepConfig, QuestionnaireSchema } from '../types';
|
|
3
|
+
export interface NormalizedQuestionnaireSchema {
|
|
4
|
+
steps: NormalizedStepConfig[];
|
|
5
|
+
formSchema: FormSchema;
|
|
6
|
+
}
|
|
7
|
+
export declare const normalizeQuestionnaireSchema: (schema: QuestionnaireSchema, _registry: Registry) => NormalizedQuestionnaireSchema;
|
|
8
|
+
/** Identity helper for typed schema construction. */
|
|
9
|
+
export declare const createQuestionnaireSchema: (schema: QuestionnaireSchema) => QuestionnaireSchema;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { mountQuestionnaire, unmountQuestionnaire } from './mount';
|
|
2
|
+
export { QuestionnaireController } from './engine/controller';
|
|
3
|
+
export { createQuestionnaireSchema, normalizeQuestionnaireSchema } from './engine/schema';
|
|
4
|
+
export { QuestionnaireError } from './errors';
|
|
5
|
+
export { questionnaireDefaultLabels, questionnaireEventNames, questionnaireStaticText, questionnaireTagNames, resolveQuestionnaireText, } from './constants';
|
|
6
|
+
export type { IQuestionnaireController, MountedQuestionnaire, MountQuestionnaireOptions, NormalizedStepConfig, QuestionnaireLabels, QuestionnaireSchema, QuestionnaireState, QuestionnaireStepConfig, QuestionnaireStepProgress, QuestionnaireText, QuestionnaireTextOverrides, } from './types';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { MountQuestionnaireOptions, MountedQuestionnaire } from './types';
|
|
2
|
+
export declare const mountQuestionnaire: (container: HTMLElement, options: MountQuestionnaireOptions) => MountedQuestionnaire;
|
|
3
|
+
export declare const unmountQuestionnaire: (mounted: MountedQuestionnaire) => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { PrimitiveText } from '../../../../primitives/constants';
|
|
3
|
+
import { PrimitiveRegistry } from '../../../../primitives/types';
|
|
4
|
+
import { questionnaireTagNames, QuestionnaireText } from '../../constants';
|
|
5
|
+
import { IQuestionnaireController } from '../../types';
|
|
6
|
+
export declare class QuestionnaireRootElement extends LitElement {
|
|
7
|
+
#private;
|
|
8
|
+
static styles: import('lit').CSSResult;
|
|
9
|
+
accessor controller: IQuestionnaireController | undefined;
|
|
10
|
+
accessor registry: PrimitiveRegistry | undefined;
|
|
11
|
+
accessor text: QuestionnaireText;
|
|
12
|
+
accessor primitiveText: PrimitiveText;
|
|
13
|
+
private accessor qState;
|
|
14
|
+
private accessor formStatus;
|
|
15
|
+
protected willUpdate(changed: Map<string, unknown>): void;
|
|
16
|
+
disconnectedCallback(): void;
|
|
17
|
+
render(): import('lit').TemplateResult<1>;
|
|
18
|
+
}
|
|
19
|
+
declare global {
|
|
20
|
+
interface HTMLElementTagNameMap {
|
|
21
|
+
[questionnaireTagNames.questionnaire]: QuestionnaireRootElement;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { questionnaireTagNames } from '../../constants';
|
|
3
|
+
export declare class QuestionnaireStepIndicatorElement extends LitElement {
|
|
4
|
+
static styles: import('lit').CSSResult;
|
|
5
|
+
accessor current: number;
|
|
6
|
+
accessor total: number;
|
|
7
|
+
accessor label: string;
|
|
8
|
+
render(): import('lit').TemplateResult<1>;
|
|
9
|
+
}
|
|
10
|
+
declare global {
|
|
11
|
+
interface HTMLElementTagNameMap {
|
|
12
|
+
[questionnaireTagNames.stepIndicator]: QuestionnaireStepIndicatorElement;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { AttachedDesignSystem, DesignSystemConfig, DesignSystemRegistry, ResolvedDesignSystem } from '../../design-system';
|
|
2
|
+
import { FieldConfig, FieldController, FormController, FormHooks, FormValidator, InactiveFieldPolicy, Registry, Transport } from '../../engine';
|
|
3
|
+
import { PrimitiveRegistry, PrimitiveTextOverrides } from '../../primitives';
|
|
4
|
+
import { QuestionnaireLabels, QuestionnaireText, QuestionnaireTextOverrides } from './constants';
|
|
5
|
+
export type { QuestionnaireLabels, QuestionnaireText, QuestionnaireTextOverrides };
|
|
6
|
+
export interface QuestionnaireStepConfig {
|
|
7
|
+
id?: string;
|
|
8
|
+
title: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
fields: FieldConfig[];
|
|
11
|
+
}
|
|
12
|
+
export interface QuestionnaireSchema {
|
|
13
|
+
steps: QuestionnaireStepConfig[];
|
|
14
|
+
}
|
|
15
|
+
export interface NormalizedStepConfig {
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
fieldIds: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface QuestionnaireStepProgress {
|
|
22
|
+
current: number;
|
|
23
|
+
total: number;
|
|
24
|
+
}
|
|
25
|
+
export interface QuestionnaireState {
|
|
26
|
+
stepIndex: number;
|
|
27
|
+
canGoNext: boolean;
|
|
28
|
+
canGoPrev: boolean;
|
|
29
|
+
isLastStep: boolean;
|
|
30
|
+
stepProgress: QuestionnaireStepProgress;
|
|
31
|
+
currentStep: NormalizedStepConfig;
|
|
32
|
+
}
|
|
33
|
+
export interface IQuestionnaireController {
|
|
34
|
+
readonly steps: readonly NormalizedStepConfig[];
|
|
35
|
+
readonly state: QuestionnaireState;
|
|
36
|
+
readonly form: FormController;
|
|
37
|
+
next(): Promise<boolean>;
|
|
38
|
+
prev(): void;
|
|
39
|
+
subscribe(listener: (state: QuestionnaireState) => void): () => void;
|
|
40
|
+
}
|
|
41
|
+
export type StepFieldEntry = {
|
|
42
|
+
id: string;
|
|
43
|
+
controller: FieldController;
|
|
44
|
+
};
|
|
45
|
+
export interface MountQuestionnaireOptions {
|
|
46
|
+
schema: QuestionnaireSchema;
|
|
47
|
+
transport: Transport;
|
|
48
|
+
registry?: Registry;
|
|
49
|
+
primitiveRegistry?: PrimitiveRegistry;
|
|
50
|
+
designSystem?: DesignSystemConfig;
|
|
51
|
+
designSystemRegistry?: DesignSystemRegistry;
|
|
52
|
+
initialValues?: Record<string, unknown>;
|
|
53
|
+
validators?: FormValidator[];
|
|
54
|
+
hooks?: FormHooks;
|
|
55
|
+
inactiveFieldPolicy?: InactiveFieldPolicy;
|
|
56
|
+
listenerErrorPolicy?: "ignore" | "throw-aggregate";
|
|
57
|
+
onListenerError?: (error: unknown) => void;
|
|
58
|
+
labels?: QuestionnaireLabels;
|
|
59
|
+
text?: QuestionnaireTextOverrides;
|
|
60
|
+
primitiveText?: PrimitiveTextOverrides;
|
|
61
|
+
onDesignSystemChange?: (resolved: ResolvedDesignSystem) => void;
|
|
62
|
+
}
|
|
63
|
+
export interface MountedQuestionnaire {
|
|
64
|
+
readonly controller: IQuestionnaireController;
|
|
65
|
+
readonly form: FormController;
|
|
66
|
+
readonly host: HTMLElement;
|
|
67
|
+
readonly designSystem: AttachedDesignSystem;
|
|
68
|
+
unmount(): void;
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MLFormError } from './errors';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CapabilityRequirement, SubmitRequest, Transport, TransportCapabilities } from './types';
|
|
2
|
+
export declare const normalizeTransportCapabilities: (capabilities?: Partial<TransportCapabilities>, inferred?: Partial<TransportCapabilities>) => TransportCapabilities;
|
|
3
|
+
export declare const mergeTransportCapabilities: (current?: TransportCapabilities, next?: TransportCapabilities) => TransportCapabilities | undefined;
|
|
4
|
+
export declare const inferTransportCapabilities: (transport: Pick<Transport, "stream" | "openSession" | "capabilities">) => TransportCapabilities;
|
|
5
|
+
export declare const cloneCapabilities: (capabilities: TransportCapabilities | undefined) => TransportCapabilities | undefined;
|
|
6
|
+
export declare const assertTransportCapabilities: (transport: Transport, requirement: CapabilityRequirement, context: string) => void;
|
|
7
|
+
export declare const assertPayloadWithinLimits: (transport: Transport, request: SubmitRequest, context: string) => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal deep clone for transport-layer data: plain objects, arrays, Date,
|
|
3
|
+
* Map, Set, and primitives. Does **not** handle File, Blob, TypedArray, or
|
|
4
|
+
* DataView — use the engine-level {@link cloneValue} for those.
|
|
5
|
+
*/
|
|
6
|
+
export declare const cloneValue: <T>(value: T) => T;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { FanoutTransportOptions, QuorumFanoutTransportOptions, Transport } from '../types';
|
|
2
|
+
export declare const createFanoutTransport: <TTransportId extends string = string>(options: FanoutTransportOptions<TTransportId>) => Transport;
|
|
3
|
+
export declare const createQuorumFanoutTransport: <TTransportId extends string = string>(options: QuorumFanoutTransportOptions<TTransportId>) => Transport;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { RoutingTransportOptions, Transport, WeightedRoutingTransportOptions } from '../types';
|
|
2
|
+
export declare const createRoutingTransport: <TTransportId extends string = string>(options: RoutingTransportOptions<TTransportId>) => Transport;
|
|
3
|
+
export declare const createWeightedRoutingTransport: <TTransportId extends string = string>(options: WeightedRoutingTransportOptions<TTransportId>) => Transport;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const transportDefaults: {
|
|
2
|
+
readonly method: "POST";
|
|
3
|
+
readonly acceptHeader: "application/json";
|
|
4
|
+
readonly contentTypeHeader: "application/json";
|
|
5
|
+
readonly requestBodyKey: "inputs";
|
|
6
|
+
};
|
|
7
|
+
export declare const transportErrorMessages: {
|
|
8
|
+
readonly missingFetch: "A fetch implementation is required to use the default transport.";
|
|
9
|
+
readonly unsupportedMethod: (method: string) => string;
|
|
10
|
+
readonly requestFailed: (status: number, statusText: string) => string;
|
|
11
|
+
readonly emptyComposedTransport: (factoryName: string) => string;
|
|
12
|
+
readonly unknownComposedTransport: (factoryName: string, transportId: string, availableTransportIds: readonly string[]) => string;
|
|
13
|
+
readonly duplicateFanoutReport: (reportId: string, firstSource: string, secondSource: string) => string;
|
|
14
|
+
readonly fanoutFailed: (failedSources: readonly string[]) => string;
|
|
15
|
+
readonly fanoutEmpty: "createFanoutTransport: all transports filtered out. No submissions dispatched.";
|
|
16
|
+
readonly fallbackFailed: (failedSources: readonly string[]) => string;
|
|
17
|
+
readonly emptyPipeline: "createPipelineTransport requires at least one stage.";
|
|
18
|
+
readonly pipelineAborted: (stageId: string) => string;
|
|
19
|
+
readonly racingAllFailed: "createRacingTransport: all transports failed.";
|
|
20
|
+
readonly missingStream: (source: string) => string;
|
|
21
|
+
readonly retryInvalidAttempts: "withRetry: attempts must be at least 1.";
|
|
22
|
+
readonly timeoutInvalid: "withTimeout: timeout must be a positive number.";
|
|
23
|
+
readonly retryUnsafe: "withRetry: transport declares retrySafe=false. Pass `allowUnsafeRetry: true` to override.";
|
|
24
|
+
readonly cacheUnsafe: "withCache: transport declares cacheable=false. Pass `allowUnsafeCache: true` to override.";
|
|
25
|
+
readonly circuitInvalidFailureThreshold: "withCircuitBreaker: failureThreshold must be at least 1.";
|
|
26
|
+
readonly circuitInvalidResetTimeout: "withCircuitBreaker: resetTimeout must be a positive number.";
|
|
27
|
+
readonly rateLimitInvalid: "withRateLimit: provide at least one positive maxConcurrent or perSecond limit.";
|
|
28
|
+
readonly rateLimitQueueFull: "withRateLimit: queue limit exceeded.";
|
|
29
|
+
readonly cacheInvalidTtl: "withCache: ttl must be a positive number.";
|
|
30
|
+
readonly circuitOpen: (source: string) => string;
|
|
31
|
+
readonly hedgedUnsafe: "createHedgedTransport: every transport must declare retrySafe !== false or allowUnsafeHedging must be true.";
|
|
32
|
+
readonly sseInvalidEvent: "createSseTransport: failed to parse SSE event payload.";
|
|
33
|
+
readonly websocketMissing: "createWebSocketSessionTransport requires a WebSocket implementation in this environment.";
|
|
34
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { MLFormError } from '../../shared';
|
|
2
|
+
export declare const transportErrorCodes: {
|
|
3
|
+
readonly TIMEOUT: "TIMEOUT";
|
|
4
|
+
readonly AUTH_FAILED: "AUTH_FAILED";
|
|
5
|
+
readonly RATE_LIMITED: "RATE_LIMITED";
|
|
6
|
+
readonly OPEN_CIRCUIT: "OPEN_CIRCUIT";
|
|
7
|
+
readonly PARSE_FAILED: "PARSE_FAILED";
|
|
8
|
+
readonly UPSTREAM_5XX: "UPSTREAM_5XX";
|
|
9
|
+
readonly ABORTED: "ABORTED";
|
|
10
|
+
readonly CAPABILITY_MISMATCH: "CAPABILITY_MISMATCH";
|
|
11
|
+
readonly PAYLOAD_TOO_LARGE: "PAYLOAD_TOO_LARGE";
|
|
12
|
+
readonly SESSION_RESULT_MISSING: "SESSION_RESULT_MISSING";
|
|
13
|
+
readonly GRAPHQL_ERROR: "GRAPHQL_ERROR";
|
|
14
|
+
readonly WEBSOCKET_BUFFER_OVERFLOW: "WEBSOCKET_BUFFER_OVERFLOW";
|
|
15
|
+
readonly POLICY_STORE_CONFLICT: "POLICY_STORE_CONFLICT";
|
|
16
|
+
readonly QUORUM_NOT_REACHED: "QUORUM_NOT_REACHED";
|
|
17
|
+
};
|
|
18
|
+
export type TransportErrorCode = (typeof transportErrorCodes)[keyof typeof transportErrorCodes] | (string & {});
|
|
19
|
+
export declare class TransportError extends MLFormError {
|
|
20
|
+
readonly cause: unknown;
|
|
21
|
+
readonly source?: string;
|
|
22
|
+
readonly status?: number;
|
|
23
|
+
readonly code?: TransportErrorCode;
|
|
24
|
+
readonly retryable?: boolean;
|
|
25
|
+
readonly details?: unknown;
|
|
26
|
+
readonly response?: unknown;
|
|
27
|
+
constructor(message: string, options?: {
|
|
28
|
+
cause?: unknown;
|
|
29
|
+
source?: string;
|
|
30
|
+
status?: number;
|
|
31
|
+
code?: TransportErrorCode;
|
|
32
|
+
retryable?: boolean;
|
|
33
|
+
details?: unknown;
|
|
34
|
+
response?: unknown;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export { TransportError, transportErrorCodes, type TransportErrorCode } from './errors';
|
|
3
|
+
export { transportDefaults, transportErrorMessages } from './constants';
|
|
4
|
+
export { assertPayloadWithinLimits, assertTransportCapabilities, cloneCapabilities, inferTransportCapabilities, mergeTransportCapabilities, normalizeTransportCapabilities, } from './capabilities';
|
|
5
|
+
export { getTransportPolicyContext, withTransportPolicyContext } from './policy-context';
|
|
6
|
+
export * from './protocols';
|
|
7
|
+
export * from './middleware';
|
|
8
|
+
export * from './composition';
|
|
9
|
+
export * from './state';
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { TransportError } from './errors';
|
|
2
|
+
import { CapabilityRequirement, MaybePromise, SubmitRequest, Transport, TransportCapabilities, TransportCollection, TransportResponse, TransportSession, TransportSessionEvent, TransportStreamEvent } from './types';
|
|
3
|
+
export type TransportEntry = {
|
|
4
|
+
id: string | undefined;
|
|
5
|
+
index: number;
|
|
6
|
+
label: string;
|
|
7
|
+
transport: Transport;
|
|
8
|
+
};
|
|
9
|
+
export type StreamFactory = (request: SubmitRequest) => AsyncIterable<TransportStreamEvent> | PromiseLike<AsyncIterable<TransportStreamEvent>>;
|
|
10
|
+
type SessionFactory = (request: SubmitRequest) => TransportSession | PromiseLike<TransportSession>;
|
|
11
|
+
export type AsyncQueue<T> = {
|
|
12
|
+
push(value: T): void;
|
|
13
|
+
close(): void;
|
|
14
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
15
|
+
};
|
|
16
|
+
export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
|
|
17
|
+
export declare const isAbortError: (error: unknown) => boolean;
|
|
18
|
+
export declare const createTransport: (submit: Transport["submit"], stream?: StreamFactory, options?: {
|
|
19
|
+
openSession?: SessionFactory;
|
|
20
|
+
capabilities?: TransportCapabilities;
|
|
21
|
+
}) => Transport;
|
|
22
|
+
export declare const createAsyncQueue: <T>() => AsyncQueue<T>;
|
|
23
|
+
export declare const resolveStream: (transport: Transport, request: SubmitRequest) => Promise<AsyncIterable<TransportStreamEvent>>;
|
|
24
|
+
export declare const mergeHeaders: (baseHeaders: HeadersInit | undefined, extraHeaders: HeadersInit | undefined) => Headers;
|
|
25
|
+
export declare const resolveRequestCredentials: (optionsCredentials: RequestCredentials | undefined, request: SubmitRequest) => RequestCredentials | undefined;
|
|
26
|
+
export declare const withRequestTransportContext: (request: SubmitRequest, context: NonNullable<SubmitRequest["transport"]>) => SubmitRequest;
|
|
27
|
+
export declare const ensureRequestPolicyContext: (request: SubmitRequest) => SubmitRequest;
|
|
28
|
+
export declare const withCapabilityRequirement: (request: SubmitRequest, requirement: CapabilityRequirement | undefined, transport: Transport, context: string) => SubmitRequest;
|
|
29
|
+
export declare const normalizeRequest: (request: SubmitRequest, transport: Transport, context: string) => SubmitRequest;
|
|
30
|
+
export declare const getTransportScope: (request: SubmitRequest, fallback: string) => string;
|
|
31
|
+
export declare const withRequestPolicyScope: (request: SubmitRequest, scope: string, extras?: {
|
|
32
|
+
source?: string;
|
|
33
|
+
backend?: string;
|
|
34
|
+
requestId?: string;
|
|
35
|
+
}) => SubmitRequest;
|
|
36
|
+
export declare const getErrorMessage: (error: unknown) => string;
|
|
37
|
+
export declare const toTransportError: (error: unknown, defaults?: {
|
|
38
|
+
source?: string;
|
|
39
|
+
status?: number;
|
|
40
|
+
code?: string;
|
|
41
|
+
retryable?: boolean;
|
|
42
|
+
response?: unknown;
|
|
43
|
+
details?: unknown;
|
|
44
|
+
}) => TransportError;
|
|
45
|
+
export declare const assertRetrySafe: (transport: Transport, allowUnsafeRetry?: boolean) => void;
|
|
46
|
+
export declare const assertCacheSafe: (transport: Transport, allowUnsafeCache?: boolean) => void;
|
|
47
|
+
export declare const assertHedgingSafe: (transport: Transport, allowUnsafeHedging?: boolean) => void;
|
|
48
|
+
export declare const defaultDedupKey: (request: SubmitRequest) => string;
|
|
49
|
+
export declare const normalizeTransportResponse: (response: unknown) => TransportResponse;
|
|
50
|
+
export declare const normalizeStreamEvent: (event: unknown) => TransportStreamEvent;
|
|
51
|
+
export declare const resolveTransportEntries: (transports: TransportCollection, factoryName: string) => readonly TransportEntry[];
|
|
52
|
+
export declare const createAggregateFailure: (message: string, failures: readonly {
|
|
53
|
+
label: string;
|
|
54
|
+
error: unknown;
|
|
55
|
+
}[]) => TransportError;
|
|
56
|
+
export declare const combineSignals: (signals: (AbortSignal | undefined)[]) => {
|
|
57
|
+
signal: AbortSignal;
|
|
58
|
+
cleanup: () => void;
|
|
59
|
+
};
|
|
60
|
+
export declare const waitForDelay: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
61
|
+
export declare const withEventMeta: (event: TransportStreamEvent, meta: Record<string, unknown>) => TransportStreamEvent;
|
|
62
|
+
export declare const toSessionStreamEvent: (event: TransportSessionEvent) => TransportStreamEvent | null;
|
|
63
|
+
export declare const createSubmitBackedStream: (transport: Transport, request: SubmitRequest) => AsyncIterable<TransportStreamEvent>;
|
|
64
|
+
export declare const resolveStreamOrSubmit: (transport: Transport, request: SubmitRequest) => AsyncIterable<TransportStreamEvent> | PromiseLike<AsyncIterable<TransportStreamEvent>>;
|
|
65
|
+
export declare const resolveGraphqlValue: <TValue>(value: TValue | ((request: SubmitRequest) => MaybePromise<TValue>), request: SubmitRequest) => Promise<TValue>;
|
|
66
|
+
export declare const parseSseBlocks: (stream: ReadableStream<Uint8Array>) => AsyncIterable<{
|
|
67
|
+
id?: string;
|
|
68
|
+
event?: string;
|
|
69
|
+
data: string;
|
|
70
|
+
retry?: number;
|
|
71
|
+
}>;
|
|
72
|
+
export declare const defaultDecodeSseEvent: (event: {
|
|
73
|
+
id?: string;
|
|
74
|
+
event?: string;
|
|
75
|
+
data: string;
|
|
76
|
+
retry?: number;
|
|
77
|
+
}) => Promise<TransportStreamEvent>;
|
|
78
|
+
export declare const defaultBody: (request: Parameters<Transport["submit"]>[0]) => {
|
|
79
|
+
inputs: Record<string, unknown>;
|
|
80
|
+
};
|
|
81
|
+
export declare const defaultParse: (response: Response) => Promise<unknown>;
|
|
82
|
+
export declare const resolveErrorMessage: (status: number, statusText: string, payload: unknown) => string;
|
|
83
|
+
export declare const resolveErrorCode: (payload: unknown) => string | undefined;
|
|
84
|
+
export declare const resolveMethod: (method: string | undefined) => "POST" | "PUT" | "PATCH" | "DELETE";
|
|
85
|
+
export declare const resolveSecret: (value: string | (() => MaybePromise<string>)) => Promise<string>;
|
|
86
|
+
export declare const chooseWeightedTransport: <TTransportId extends string>(request: SubmitRequest, transportIds: readonly TTransportId[], weights: Partial<Record<TTransportId, number>> | ((request: SubmitRequest, transportId: TTransportId) => MaybePromise<number>), filter?: (transportId: TTransportId, request: SubmitRequest) => MaybePromise<boolean>) => Promise<TTransportId>;
|
|
87
|
+
export declare const toFanoutMeta: (results: readonly {
|
|
88
|
+
id: string | undefined;
|
|
89
|
+
index: number;
|
|
90
|
+
response: TransportResponse;
|
|
91
|
+
}[], failures: readonly {
|
|
92
|
+
id: string | undefined;
|
|
93
|
+
index: number;
|
|
94
|
+
error: unknown;
|
|
95
|
+
}[]) => Record<string, unknown>;
|
|
96
|
+
export declare const toFanoutRaw: (results: readonly {
|
|
97
|
+
id: string | undefined;
|
|
98
|
+
index: number;
|
|
99
|
+
response: TransportResponse;
|
|
100
|
+
}[]) => unknown;
|
|
101
|
+
export declare const mergeFanoutResponses: (results: readonly {
|
|
102
|
+
id: string | undefined;
|
|
103
|
+
index: number;
|
|
104
|
+
response: TransportResponse;
|
|
105
|
+
}[], failures: readonly {
|
|
106
|
+
id: string | undefined;
|
|
107
|
+
index: number;
|
|
108
|
+
error: unknown;
|
|
109
|
+
}[]) => TransportResponse;
|
|
110
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './pipe';
|
|
2
|
+
export * from './retry';
|
|
3
|
+
export * from './timeout';
|
|
4
|
+
export * from './transform';
|
|
5
|
+
export * from './logging';
|
|
6
|
+
export * from './tracing';
|
|
7
|
+
export * from './metrics';
|
|
8
|
+
export * from './auth';
|
|
9
|
+
export * from './circuit-breaker';
|
|
10
|
+
export * from './rate-limit';
|
|
11
|
+
export * from './dedup';
|
|
12
|
+
export * from './cache';
|